Rebuild order flow: settle after pricing, notifications, and invoice expiry.

Hide prices until admin sends the invoice, enforce status transitions, add customer/admin SMS+in-app notifications, schedule cash invoice reminders, and ship updated dist/prisma-client/deploy-bundle for git-pull deploys.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-09 12:00:13 +03:30
co-authored by Cursor
parent 06e5f48d07
commit d4aaa8e997
102 changed files with 2989 additions and 509 deletions
+6
View File
@@ -13,6 +13,7 @@ export declare class CompaniesController {
isActive: boolean;
displayOrder: number;
maxMeteragePerInvoice: number;
ownMaxMeteragePerInvoice: number | undefined;
cashInvoiceValidityHours: number;
cashInvoiceValidUntilHour: number | undefined;
catalogCount: number;
@@ -31,6 +32,7 @@ export declare class CompaniesController {
isActive: boolean;
displayOrder: number;
maxMeteragePerInvoice: number;
ownMaxMeteragePerInvoice: number | undefined;
cashInvoiceValidityHours: number;
cashInvoiceValidUntilHour: number | undefined;
catalogCount: number;
@@ -63,6 +65,7 @@ export declare class CompaniesController {
isActive: boolean;
displayOrder: number;
maxMeteragePerInvoice: number;
ownMaxMeteragePerInvoice: number | undefined;
cashInvoiceValidityHours: number;
cashInvoiceValidUntilHour: number | undefined;
catalogCount: number;
@@ -81,6 +84,7 @@ export declare class CompaniesController {
isActive: boolean;
displayOrder: number;
maxMeteragePerInvoice: number;
ownMaxMeteragePerInvoice: number | undefined;
cashInvoiceValidityHours: number;
cashInvoiceValidUntilHour: number | undefined;
catalogCount: number;
@@ -99,6 +103,7 @@ export declare class CompaniesController {
isActive: boolean;
displayOrder: number;
maxMeteragePerInvoice: number;
ownMaxMeteragePerInvoice: number | undefined;
cashInvoiceValidityHours: number;
cashInvoiceValidUntilHour: number | undefined;
catalogCount: number;
@@ -117,6 +122,7 @@ export declare class CompaniesController {
isActive: boolean;
displayOrder: number;
maxMeteragePerInvoice: number;
ownMaxMeteragePerInvoice: number | undefined;
cashInvoiceValidityHours: number;
cashInvoiceValidUntilHour: number | undefined;
catalogCount: number;
+6
View File
@@ -13,6 +13,7 @@ export declare class CompaniesService {
isActive: boolean;
displayOrder: number;
maxMeteragePerInvoice: number;
ownMaxMeteragePerInvoice: number | undefined;
cashInvoiceValidityHours: number;
cashInvoiceValidUntilHour: number | undefined;
catalogCount: number;
@@ -45,6 +46,7 @@ export declare class CompaniesService {
isActive: boolean;
displayOrder: number;
maxMeteragePerInvoice: number;
ownMaxMeteragePerInvoice: number | undefined;
cashInvoiceValidityHours: number;
cashInvoiceValidUntilHour: number | undefined;
catalogCount: number;
@@ -53,6 +55,7 @@ export declare class CompaniesService {
createdAt: string;
updatedAt: string;
}>;
private settingsMaxMeterage;
create(dto: CreateCompanyDto): Promise<{
id: string;
name: string;
@@ -63,6 +66,7 @@ export declare class CompaniesService {
isActive: boolean;
displayOrder: number;
maxMeteragePerInvoice: number;
ownMaxMeteragePerInvoice: number | undefined;
cashInvoiceValidityHours: number;
cashInvoiceValidUntilHour: number | undefined;
catalogCount: number;
@@ -81,6 +85,7 @@ export declare class CompaniesService {
isActive: boolean;
displayOrder: number;
maxMeteragePerInvoice: number;
ownMaxMeteragePerInvoice: number | undefined;
cashInvoiceValidityHours: number;
cashInvoiceValidUntilHour: number | undefined;
catalogCount: number;
@@ -99,6 +104,7 @@ export declare class CompaniesService {
isActive: boolean;
displayOrder: number;
maxMeteragePerInvoice: number;
ownMaxMeteragePerInvoice: number | undefined;
cashInvoiceValidityHours: number;
cashInvoiceValidUntilHour: number | undefined;
catalogCount: number;
+36 -21
View File
@@ -13,40 +13,54 @@ exports.CompaniesService = void 0;
const common_1 = require("@nestjs/common");
const client_1 = require("@prisma/client");
const prisma_service_1 = require("../prisma/prisma.service");
const meterage_1 = require("../common/utils/meterage");
let CompaniesService = class CompaniesService {
prisma;
constructor(prisma) {
this.prisma = prisma;
}
async findAll(activeOnly = false) {
const companies = await this.prisma.company.findMany({
where: activeOnly ? { isActive: true } : undefined,
orderBy: [{ displayOrder: 'asc' }, { name: 'asc' }],
include: {
_count: {
select: { catalogs: true, products: true, bankAccounts: true },
const [companies, fallbackMeterage] = await Promise.all([
this.prisma.company.findMany({
where: activeOnly ? { isActive: true } : undefined,
orderBy: [{ displayOrder: 'asc' }, { name: 'asc' }],
include: {
_count: {
select: { catalogs: true, products: true, bankAccounts: true },
},
},
},
});
return companies.map((c) => this.mapCompany(c));
}),
this.settingsMaxMeterage(),
]);
return companies.map((c) => this.mapCompany(c, fallbackMeterage));
}
async findOne(id) {
const company = await this.prisma.company.findUnique({
where: { id },
include: {
bankAccounts: { orderBy: { displayOrder: 'asc' } },
_count: {
select: { catalogs: true, products: true, bankAccounts: true },
const [company, fallbackMeterage] = await Promise.all([
this.prisma.company.findUnique({
where: { id },
include: {
bankAccounts: { orderBy: { displayOrder: 'asc' } },
_count: {
select: { catalogs: true, products: true, bankAccounts: true },
},
},
},
});
}),
this.settingsMaxMeterage(),
]);
if (!company)
throw new common_1.NotFoundException('شرکت یافت نشد');
return {
...this.mapCompany(company),
...this.mapCompany(company, fallbackMeterage),
bankAccounts: company.bankAccounts.map((b) => this.mapBankAccount(b)),
};
}
async settingsMaxMeterage() {
const settings = await this.prisma.systemSettings.findUnique({
where: { id: 'default' },
select: { maxMeteragePerInvoice: true },
});
return settings?.maxMeteragePerInvoice ?? null;
}
async create(dto) {
try {
const company = await this.prisma.company.create({
@@ -56,7 +70,7 @@ let CompaniesService = class CompaniesService {
description: dto.description?.trim() || null,
logoUrl: dto.logoUrl?.trim() || null,
displayOrder: dto.displayOrder ?? 0,
maxMeteragePerInvoice: dto.maxMeteragePerInvoice ?? 5000,
maxMeteragePerInvoice: dto.maxMeteragePerInvoice ?? null,
cashInvoiceValidityHours: dto.cashInvoiceValidityHours ?? 8,
cashInvoiceValidUntilHour: dto.cashInvoiceValidUntilHour ?? null,
isActive: dto.isActive ?? true,
@@ -186,7 +200,7 @@ let CompaniesService = class CompaniesService {
throw new common_1.NotFoundException('حساب بانکی یافت نشد');
return account;
}
mapCompany(company) {
mapCompany(company, fallbackMaxMeterage = null) {
return {
id: company.id,
name: company.name,
@@ -196,7 +210,8 @@ let CompaniesService = class CompaniesService {
logo: company.logoUrl ?? undefined,
isActive: company.isActive,
displayOrder: company.displayOrder,
maxMeteragePerInvoice: company.maxMeteragePerInvoice,
maxMeteragePerInvoice: (0, meterage_1.resolveMaxMeterage)(company.maxMeteragePerInvoice, fallbackMaxMeterage),
ownMaxMeteragePerInvoice: company.maxMeteragePerInvoice ?? undefined,
cashInvoiceValidityHours: company.cashInvoiceValidityHours,
cashInvoiceValidUntilHour: company.cashInvoiceValidUntilHour ?? undefined,
catalogCount: company._count?.catalogs ?? 0,
File diff suppressed because one or more lines are too long