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:
Vendored
+4
@@ -10,6 +10,7 @@ exports.AppModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const core_1 = require("@nestjs/core");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const schedule_1 = require("@nestjs/schedule");
|
||||
const prisma_module_1 = require("./prisma/prisma.module");
|
||||
const auth_module_1 = require("./auth/auth.module");
|
||||
const jwt_auth_guard_1 = require("./common/guards/jwt-auth.guard");
|
||||
@@ -25,6 +26,7 @@ const shipments_module_1 = require("./shipments/shipments.module");
|
||||
const dashboard_module_1 = require("./dashboard/dashboard.module");
|
||||
const settings_module_1 = require("./settings/settings.module");
|
||||
const carts_module_1 = require("./carts/carts.module");
|
||||
const notifications_module_1 = require("./notifications/notifications.module");
|
||||
let AppModule = class AppModule {
|
||||
};
|
||||
exports.AppModule = AppModule;
|
||||
@@ -32,6 +34,7 @@ exports.AppModule = AppModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [
|
||||
config_1.ConfigModule.forRoot({ isGlobal: true }),
|
||||
schedule_1.ScheduleModule.forRoot(),
|
||||
prisma_module_1.PrismaModule,
|
||||
auth_module_1.AuthModule,
|
||||
companies_module_1.CompaniesModule,
|
||||
@@ -46,6 +49,7 @@ exports.AppModule = AppModule = __decorate([
|
||||
dashboard_module_1.DashboardModule,
|
||||
settings_module_1.SettingsModule,
|
||||
carts_module_1.CartsModule,
|
||||
notifications_module_1.NotificationsModule,
|
||||
],
|
||||
providers: [
|
||||
{
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,uCAAyC;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ACP,qBAAY,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;YACxC,yBAAc,CAAC,OAAO,EAAE;YACxB,4BAAY;YACZ,wBAAU;YACV,kCAAe;YACf,gCAAc;YACd,gCAAc;YACd,kCAAe;YACf,qCAAgB;YAChB,4BAAY;YACZ,4BAAY;YACZ,yCAAkB;YAClB,kCAAe;YACf,kCAAe;YACf,gCAAc;YACd,0BAAW;YACX,0CAAmB;SACpB;QACD,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,gBAAS;gBAClB,QAAQ,EAAE,6BAAY;aACvB;SACF;KACF,CAAC;GACW,SAAS,CAAG"}
|
||||
Vendored
-6
@@ -18,7 +18,6 @@ export declare class CartsController {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
@@ -42,7 +41,6 @@ export declare class CartsController {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
@@ -66,7 +64,6 @@ export declare class CartsController {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
@@ -90,7 +87,6 @@ export declare class CartsController {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
@@ -114,7 +110,6 @@ export declare class CartsController {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
@@ -138,7 +133,6 @@ export declare class CartsController {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
|
||||
Vendored
-6
@@ -17,7 +17,6 @@ export declare class CartsService {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
@@ -41,7 +40,6 @@ export declare class CartsService {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
@@ -65,7 +63,6 @@ export declare class CartsService {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
@@ -89,7 +86,6 @@ export declare class CartsService {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
@@ -113,7 +109,6 @@ export declare class CartsService {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
@@ -137,7 +132,6 @@ export declare class CartsService {
|
||||
productCode: string;
|
||||
color: string;
|
||||
meterage: number;
|
||||
unitPrice: number | undefined;
|
||||
notes: string | undefined;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
|
||||
Vendored
-3
@@ -47,7 +47,6 @@ let CartsService = class CartsService {
|
||||
data: {
|
||||
meterage: newMeterage,
|
||||
notes: dto.notes?.trim() || existing.notes,
|
||||
unitPrice: product.basePrice,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -61,7 +60,6 @@ let CartsService = class CartsService {
|
||||
productCode: product.code,
|
||||
color: product.color,
|
||||
meterage: dto.meterage,
|
||||
unitPrice: product.basePrice,
|
||||
notes: dto.notes?.trim() || null,
|
||||
companyId: product.companyId,
|
||||
companyName: product.company.name,
|
||||
@@ -168,7 +166,6 @@ let CartsService = class CartsService {
|
||||
productCode: item.productCode,
|
||||
color: item.color,
|
||||
meterage: item.meterage,
|
||||
unitPrice: item.unitPrice ?? undefined,
|
||||
notes: item.notes ?? undefined,
|
||||
companyId: item.companyId,
|
||||
companyName: item.companyName,
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+2
@@ -10,11 +10,13 @@ exports.CashPaymentsModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const cash_payments_controller_1 = require("./cash-payments.controller");
|
||||
const cash_payments_service_1 = require("./cash-payments.service");
|
||||
const notifications_module_1 = require("../notifications/notifications.module");
|
||||
let CashPaymentsModule = class CashPaymentsModule {
|
||||
};
|
||||
exports.CashPaymentsModule = CashPaymentsModule;
|
||||
exports.CashPaymentsModule = CashPaymentsModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [notifications_module_1.NotificationsModule],
|
||||
controllers: [cash_payments_controller_1.CashPaymentsController],
|
||||
providers: [cash_payments_service_1.CashPaymentsService],
|
||||
exports: [cash_payments_service_1.CashPaymentsService],
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"cash-payments.module.js","sourceRoot":"","sources":["../../src/cash-payments/cash-payments.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yEAAoE;AACpE,mEAA8D;AAOvD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAL9B,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,iDAAsB,CAAC;QACrC,SAAS,EAAE,CAAC,2CAAmB,CAAC;QAChC,OAAO,EAAE,CAAC,2CAAmB,CAAC;KAC/B,CAAC;GACW,kBAAkB,CAAG"}
|
||||
{"version":3,"file":"cash-payments.module.js","sourceRoot":"","sources":["../../src/cash-payments/cash-payments.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,yEAAoE;AACpE,mEAA8D;AAC9D,gFAA4E;AAQrE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;CAAG,CAAA;AAArB,gDAAkB;6BAAlB,kBAAkB;IAN9B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0CAAmB,CAAC;QAC9B,WAAW,EAAE,CAAC,iDAAsB,CAAC;QACrC,SAAS,EAAE,CAAC,2CAAmB,CAAC;QAChC,OAAO,EAAE,CAAC,2CAAmB,CAAC;KAC/B,CAAC;GACW,kBAAkB,CAAG"}
|
||||
+3
-1
@@ -1,9 +1,11 @@
|
||||
import { CashPaymentStatus } from '@prisma/client';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { SubmitCashReceiptDto, UpdateCashPaymentStatusDto } from './dto/cash-payment.dto';
|
||||
import { NotificationsService } from '../notifications/notifications.service';
|
||||
export declare class CashPaymentsService {
|
||||
private readonly prisma;
|
||||
constructor(prisma: PrismaService);
|
||||
private readonly notifications;
|
||||
constructor(prisma: PrismaService, notifications: NotificationsService);
|
||||
submitReceipt(userId: string, orderId: string, dto: SubmitCashReceiptDto): Promise<{
|
||||
id: string;
|
||||
orderId: string;
|
||||
|
||||
+21
-8
@@ -14,12 +14,8 @@ const common_1 = require("@nestjs/common");
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_service_1 = require("../prisma/prisma.service");
|
||||
const name_1 = require("../common/utils/name");
|
||||
const notifications_service_1 = require("../notifications/notifications.service");
|
||||
const RECEIPT_SUBMITTABLE_STATUSES = [
|
||||
client_1.OrderStatus.awaiting_review,
|
||||
client_1.OrderStatus.pricing,
|
||||
client_1.OrderStatus.needs_correction,
|
||||
client_1.OrderStatus.awaiting_settlement,
|
||||
client_1.OrderStatus.awaiting_settlement_fix,
|
||||
client_1.OrderStatus.cash_in_progress,
|
||||
client_1.OrderStatus.cash_invoice_issued,
|
||||
client_1.OrderStatus.awaiting_cash_payment,
|
||||
@@ -28,8 +24,10 @@ const RECEIPT_SUBMITTABLE_STATUSES = [
|
||||
];
|
||||
let CashPaymentsService = class CashPaymentsService {
|
||||
prisma;
|
||||
constructor(prisma) {
|
||||
notifications;
|
||||
constructor(prisma, notifications) {
|
||||
this.prisma = prisma;
|
||||
this.notifications = notifications;
|
||||
}
|
||||
async submitReceipt(userId, orderId, dto) {
|
||||
const order = await this.prisma.order.findUnique({
|
||||
@@ -98,6 +96,11 @@ let CashPaymentsService = class CashPaymentsService {
|
||||
});
|
||||
return saved;
|
||||
});
|
||||
this.notifications.dispatchAdmin({
|
||||
title: 'رسید پرداخت نقدی ثبت شد',
|
||||
body: `مشتری برای سفارش ${order.orderNumber} رسید به مبلغ ${Math.round(dto.amount).toLocaleString('fa-IR')} تومان ثبت کرد.`,
|
||||
link: `/orders/${orderId}`,
|
||||
});
|
||||
return this.mapReceipt(receipt, order.orderNumber, '');
|
||||
}
|
||||
async findAll(status) {
|
||||
@@ -135,7 +138,7 @@ let CashPaymentsService = class CashPaymentsService {
|
||||
nextStatus = client_1.OrderStatus.cash_confirmed;
|
||||
}
|
||||
else if (dto.status === client_1.CashPaymentStatus.rejected) {
|
||||
nextStatus = client_1.OrderStatus.needs_correction;
|
||||
nextStatus = client_1.OrderStatus.awaiting_cash_payment;
|
||||
}
|
||||
else if (dto.status === client_1.CashPaymentStatus.expired) {
|
||||
nextStatus = client_1.OrderStatus.expired;
|
||||
@@ -157,6 +160,15 @@ let CashPaymentsService = class CashPaymentsService {
|
||||
}
|
||||
return result;
|
||||
});
|
||||
if (dto.status === client_1.CashPaymentStatus.approved) {
|
||||
this.notifications.dispatchOrderEvent(receipt.orderId, 'receipt_approved');
|
||||
}
|
||||
else if (dto.status === client_1.CashPaymentStatus.rejected) {
|
||||
this.notifications.dispatchOrderEvent(receipt.orderId, 'receipt_rejected', { note: dto.note ?? null });
|
||||
}
|
||||
else if (dto.status === client_1.CashPaymentStatus.expired) {
|
||||
this.notifications.dispatchOrderEvent(receipt.orderId, 'cash_invoice_expired');
|
||||
}
|
||||
return this.mapReceipt(updated, updated.order.orderNumber, (0, name_1.joinFullName)(updated.order.user.firstName, updated.order.user.lastName));
|
||||
}
|
||||
mapReceipt(r, orderNumber, customerName) {
|
||||
@@ -185,6 +197,7 @@ let CashPaymentsService = class CashPaymentsService {
|
||||
exports.CashPaymentsService = CashPaymentsService;
|
||||
exports.CashPaymentsService = CashPaymentsService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService,
|
||||
notifications_service_1.NotificationsService])
|
||||
], CashPaymentsService);
|
||||
//# sourceMappingURL=cash-payments.service.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
@@ -10,11 +10,13 @@ exports.ChecksModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const checks_controller_1 = require("./checks.controller");
|
||||
const checks_service_1 = require("./checks.service");
|
||||
const notifications_module_1 = require("../notifications/notifications.module");
|
||||
let ChecksModule = class ChecksModule {
|
||||
};
|
||||
exports.ChecksModule = ChecksModule;
|
||||
exports.ChecksModule = ChecksModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [notifications_module_1.NotificationsModule],
|
||||
controllers: [checks_controller_1.ChecksController],
|
||||
providers: [checks_service_1.ChecksService],
|
||||
exports: [checks_service_1.ChecksService],
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"checks.module.js","sourceRoot":"","sources":["../../src/checks/checks.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2DAAuD;AACvD,qDAAiD;AAO1C,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IALxB,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,YAAY,CAAG"}
|
||||
{"version":3,"file":"checks.module.js","sourceRoot":"","sources":["../../src/checks/checks.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2DAAuD;AACvD,qDAAiD;AACjD,gFAA4E;AAQrE,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IANxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0CAAmB,CAAC;QAC9B,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,YAAY,CAAG"}
|
||||
Vendored
+3
-1
@@ -1,8 +1,10 @@
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { UpdateCheckStatusDto } from './dto/check.dto';
|
||||
import { NotificationsService } from '../notifications/notifications.service';
|
||||
export declare class ChecksService {
|
||||
private readonly prisma;
|
||||
constructor(prisma: PrismaService);
|
||||
private readonly notifications;
|
||||
constructor(prisma: PrismaService, notifications: NotificationsService);
|
||||
findByOrder(orderId: string): Promise<{
|
||||
id: string;
|
||||
orderId: string;
|
||||
|
||||
Vendored
+17
-6
@@ -13,10 +13,13 @@ exports.ChecksService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_service_1 = require("../prisma/prisma.service");
|
||||
const notifications_service_1 = require("../notifications/notifications.service");
|
||||
let ChecksService = class ChecksService {
|
||||
prisma;
|
||||
constructor(prisma) {
|
||||
notifications;
|
||||
constructor(prisma, notifications) {
|
||||
this.prisma = prisma;
|
||||
this.notifications = notifications;
|
||||
}
|
||||
async findByOrder(orderId) {
|
||||
const order = await this.prisma.order.findUnique({
|
||||
@@ -37,6 +40,7 @@ let ChecksService = class ChecksService {
|
||||
});
|
||||
if (!check)
|
||||
throw new common_1.NotFoundException('چک یافت نشد');
|
||||
let notifyStatus = null;
|
||||
const updated = await this.prisma.$transaction(async (tx) => {
|
||||
const result = await tx.check.update({
|
||||
where: { id },
|
||||
@@ -54,14 +58,11 @@ let ChecksService = class ChecksService {
|
||||
const anyRejected = siblings.some((c) => c.status === client_1.CheckStatus.rejected);
|
||||
let nextStatus = null;
|
||||
if (anyRejected) {
|
||||
nextStatus = client_1.OrderStatus.check_rejected;
|
||||
nextStatus = client_1.OrderStatus.check_needs_fix;
|
||||
}
|
||||
else if (allApproved) {
|
||||
nextStatus = client_1.OrderStatus.checks_approved;
|
||||
}
|
||||
else if (dto.status === client_1.CheckStatus.rejected) {
|
||||
nextStatus = client_1.OrderStatus.check_needs_fix;
|
||||
}
|
||||
if (nextStatus && nextStatus !== check.order.status) {
|
||||
await tx.order.update({
|
||||
where: { id: check.orderId },
|
||||
@@ -76,9 +77,18 @@ let ChecksService = class ChecksService {
|
||||
note: dto.note || `وضعیت چک به ${dto.status} تغییر کرد`,
|
||||
},
|
||||
});
|
||||
notifyStatus = nextStatus;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
if (notifyStatus === client_1.OrderStatus.checks_approved) {
|
||||
this.notifications.dispatchOrderEvent(check.orderId, 'checks_approved');
|
||||
}
|
||||
else if (notifyStatus === client_1.OrderStatus.check_needs_fix) {
|
||||
this.notifications.dispatchOrderEvent(check.orderId, 'checks_need_fix', {
|
||||
note: dto.note ?? null,
|
||||
});
|
||||
}
|
||||
return this.map(updated);
|
||||
}
|
||||
map(c) {
|
||||
@@ -108,6 +118,7 @@ let ChecksService = class ChecksService {
|
||||
exports.ChecksService = ChecksService;
|
||||
exports.ChecksService = ChecksService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService,
|
||||
notifications_service_1.NotificationsService])
|
||||
], ChecksService);
|
||||
//# sourceMappingURL=checks.service.js.map
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"checks.service.js","sourceRoot":"","sources":["../../src/checks/checks.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA+D;AAC/D,2CAA0D;AAC1D,6DAAyD;AAIlD,IAAM,aAAa,GAAnB,MAAM,aAAa;IACK;IAA7B,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAEtD,KAAK,CAAC,WAAW,CAAC,OAAe;QAC/B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;YAC/C,KAAK,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE;SACvB,CAAC,CAAC;QACH,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,0BAAiB,CAAC,gBAAgB,CAAC,CAAC;QAE1D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;YAC9C,KAAK,EAAE,EAAE,OAAO,EAAE;YAClB,OAAO,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;SACxB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,OAAe,EAAE,GAAyB;QACvE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;YAC/C,KAAK,EAAE,EAAE,EAAE,EAAE;YACb,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;SAClD,CAAC,CAAC;QACH,IAAI,CAAC,KAAK;YAAE,MAA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,EAAE,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE;SACrC,CAAC;IACJ,CAAC;CACF,CAAA;AAlIY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAGgB,8BAAa;QACN,4CAAoB;GAH3C,aAAa,CAkIzB"}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export declare const FALLBACK_MAX_METERAGE = 5000;
|
||||
export declare function resolveMaxMeterage(companyValue: number | null | undefined, settingsValue: number | null | undefined): number;
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FALLBACK_MAX_METERAGE = void 0;
|
||||
exports.resolveMaxMeterage = resolveMaxMeterage;
|
||||
exports.FALLBACK_MAX_METERAGE = 5000;
|
||||
function resolveMaxMeterage(companyValue, settingsValue) {
|
||||
if (companyValue != null && companyValue > 0)
|
||||
return companyValue;
|
||||
if (settingsValue != null && settingsValue > 0)
|
||||
return settingsValue;
|
||||
return exports.FALLBACK_MAX_METERAGE;
|
||||
}
|
||||
//# sourceMappingURL=meterage.js.map
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"meterage.js","sourceRoot":"","sources":["../../../src/common/utils/meterage.ts"],"names":[],"mappings":";;;AAMA,gDAOC;AAZY,QAAA,qBAAqB,GAAG,IAAI,CAAC;AAK1C,SAAgB,kBAAkB,CAChC,YAAuC,EACvC,aAAwC;IAExC,IAAI,YAAY,IAAI,IAAI,IAAI,YAAY,GAAG,CAAC;QAAE,OAAO,YAAY,CAAC;IAClE,IAAI,aAAa,IAAI,IAAI,IAAI,aAAa,GAAG,CAAC;QAAE,OAAO,aAAa,CAAC;IACrE,OAAO,6BAAqB,CAAC;AAC/B,CAAC"}
|
||||
Vendored
+10
-8
@@ -7,22 +7,24 @@ const client_1 = require("@prisma/client");
|
||||
exports.ADMIN_STATUS_MAP = {
|
||||
pending_review: [
|
||||
client_1.OrderStatus.cart,
|
||||
client_1.OrderStatus.awaiting_settlement,
|
||||
client_1.OrderStatus.cash_in_progress,
|
||||
client_1.OrderStatus.check_in_progress,
|
||||
client_1.OrderStatus.submitted,
|
||||
client_1.OrderStatus.awaiting_review,
|
||||
client_1.OrderStatus.pricing,
|
||||
],
|
||||
awaiting_customer: [
|
||||
client_1.OrderStatus.awaiting_settlement,
|
||||
client_1.OrderStatus.awaiting_settlement_fix,
|
||||
client_1.OrderStatus.check_in_progress,
|
||||
client_1.OrderStatus.cash_in_progress,
|
||||
client_1.OrderStatus.cash_invoice_issued,
|
||||
client_1.OrderStatus.awaiting_cash_payment,
|
||||
],
|
||||
pending_check: [client_1.OrderStatus.awaiting_check_review],
|
||||
pending_payment: [
|
||||
client_1.OrderStatus.cash_payment_submitted,
|
||||
client_1.OrderStatus.awaiting_cash_confirmation,
|
||||
],
|
||||
pending_check: [client_1.OrderStatus.awaiting_check_review],
|
||||
needs_correction: [
|
||||
client_1.OrderStatus.needs_correction,
|
||||
client_1.OrderStatus.awaiting_settlement_fix,
|
||||
],
|
||||
needs_correction: [client_1.OrderStatus.needs_correction],
|
||||
check_correction: [client_1.OrderStatus.check_needs_fix, client_1.OrderStatus.check_rejected],
|
||||
final_approval: [
|
||||
client_1.OrderStatus.final_approved,
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"order-status.js","sourceRoot":"","sources":["../../../src/common/utils/order-status.ts"],"names":[],"mappings":";;;AAyCA,4DASC;AAED,sCAMC;AA1DD,2CAA6C;AAGhC,QAAA,gBAAgB,GAAkC;IAC7D,cAAc,EAAE;QACd,oBAAW,CAAC,IAAI;QAChB,oBAAW,CAAC,mBAAmB;QAC/B,oBAAW,CAAC,gBAAgB;QAC5B,oBAAW,CAAC,iBAAiB;QAC7B,oBAAW,CAAC,SAAS;QACrB,oBAAW,CAAC,eAAe;QAC3B,oBAAW,CAAC,OAAO;QACnB,oBAAW,CAAC,mBAAmB;QAC/B,oBAAW,CAAC,q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IACD,IAAI,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IACtD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAEY,QAAA,mBAAmB,GAAgC;IAC9D,IAAI,EAAE,UAAU;IAChB,mBAAmB,EAAE,iBAAiB;IACtC,gBAAgB,EAAE,iBAAiB;IACnC,iBAAiB,EAAE,eAAe;IAClC,SAAS,EAAE,SAAS;IACpB,eAAe,EAAE,iBAAiB;IAClC,OAAO,EAAE,YAAY;IACrB,gBAAgB,EAAE,eAAe;IACjC,uBAAuB,EAAE,aAAa;IACtC,mBAAmB,EAAE,kBAAkB;IACvC,qBAAqB,EAAE,uBAAuB;IAC9C,sBAAsB,EAAE,qBAAqB;IAC7C,0BAA0B,EAAE,mBAAmB;IAC/C,cAAc,EAAE,sBAAsB;IACtC,qBAAqB,EAAE,UAAU;IACjC,eAAe,EAAE,UAAU;IAC3B,cAAc,EAAE,OAAO;IACvB,eAAe,EAAE,aAAa;IAC9B,cAAc,EAAE,aAAa;IAC7B,SAAS,EAAE,YAAY;IACvB,aAAa,EAAE,aAAa;IAC5B,OAAO,EAAE,WAAW;IACpB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,OAAO;CACjB,CAAC"}
|
||||
{"version":3,"file":"order-status.js","sourceRoot":"","sources":["../../../src/common/utils/order-status.ts"],"names":[],"mappings":";;;AA2CA,4DASC;AAED,sCAMC;AA5DD,2CAA6C;AAGhC,QAAA,gBAAgB,GAAkC;IAC7D,cAAc,EAAE;QACd,oBAAW,CAAC,IAAI;QAChB,oBAAW,CAAC,SAAS;QACrB,oBAAW,CAAC,eAAe;QAC3B,oBAAW,CAAC,OAAO;KACpB;IACD,iBAAiB,EAAE;QACjB,oBAAW,CAAC,mBAAmB;QAC/B,oBAAW,CAAC,uBAAuB;QACnC,oBAAW,CAAC,iBAAiB;QAC7B,oBAAW,CA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,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC;IAC1C,CAAC;IACD,IAAI,iBAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IACtD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAEY,QAAA,mBAAmB,GAAgC;IAC9D,IAAI,EAAE,UAAU;IAChB,mBAAmB,EAAE,iBAAiB;IACtC,gBAAgB,EAAE,iBAAiB;IACnC,iBAAiB,EAAE,eAAe;IAClC,SAAS,EAAE,SAAS;IACpB,eAAe,EAAE,iBAAiB;IAClC,OAAO,EAAE,YAAY;IACrB,gBAAgB,EAAE,eAAe;IACjC,uBAAuB,EAAE,aAAa;IACtC,mBAAmB,EAAE,kBAAkB;IACvC,qBAAqB,EAAE,uBAAuB;IAC9C,sBAAsB,EAAE,qBAAqB;IAC7C,0BAA0B,EAAE,mBAAmB;IAC/C,cAAc,EAAE,sBAAsB;IACtC,qBAAqB,EAAE,UAAU;IACjC,eAAe,EAAE,UAAU;IAC3B,cAAc,EAAE,OAAO;IACvB,eAAe,EAAE,aAAa;IAC9B,cAAc,EAAE,aAAa;IAC7B,SAAS,EAAE,YAAY;IACvB,aAAa,EAAE,aAAa;IAC5B,OAAO,EAAE,WAAW;IACpB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,OAAO;CACjB,CAAC"}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import { OrderStatus } from '@prisma/client';
|
||||
export declare const ORDER_TRANSITIONS: Record<OrderStatus, OrderStatus[]>;
|
||||
export declare function isFinalStatus(status: OrderStatus): boolean;
|
||||
export declare function allowedTransitions(from: OrderStatus): OrderStatus[];
|
||||
export declare function canTransition(from: OrderStatus, to: OrderStatus): boolean;
|
||||
export declare function assertTransition(from: OrderStatus, to: OrderStatus): void;
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ORDER_TRANSITIONS = void 0;
|
||||
exports.isFinalStatus = isFinalStatus;
|
||||
exports.allowedTransitions = allowedTransitions;
|
||||
exports.canTransition = canTransition;
|
||||
exports.assertTransition = assertTransition;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const client_1 = require("@prisma/client");
|
||||
const order_status_1 = require("./order-status");
|
||||
exports.ORDER_TRANSITIONS = {
|
||||
awaiting_review: [client_1.OrderStatus.pricing],
|
||||
pricing: [client_1.OrderStatus.awaiting_settlement],
|
||||
awaiting_settlement: [
|
||||
client_1.OrderStatus.awaiting_cash_payment,
|
||||
client_1.OrderStatus.check_in_progress,
|
||||
client_1.OrderStatus.pricing,
|
||||
],
|
||||
awaiting_cash_payment: [
|
||||
client_1.OrderStatus.awaiting_cash_confirmation,
|
||||
client_1.OrderStatus.expired,
|
||||
],
|
||||
awaiting_cash_confirmation: [
|
||||
client_1.OrderStatus.cash_confirmed,
|
||||
client_1.OrderStatus.awaiting_cash_payment,
|
||||
],
|
||||
cash_confirmed: [client_1.OrderStatus.final_approved],
|
||||
check_in_progress: [client_1.OrderStatus.awaiting_check_review],
|
||||
awaiting_check_review: [
|
||||
client_1.OrderStatus.checks_approved,
|
||||
client_1.OrderStatus.check_needs_fix,
|
||||
],
|
||||
check_needs_fix: [client_1.OrderStatus.awaiting_check_review],
|
||||
checks_approved: [client_1.OrderStatus.final_approved],
|
||||
final_approved: [client_1.OrderStatus.preparing],
|
||||
preparing: [client_1.OrderStatus.ready_to_ship],
|
||||
ready_to_ship: [client_1.OrderStatus.shipped],
|
||||
shipped: [client_1.OrderStatus.delivered],
|
||||
delivered: [],
|
||||
cancelled: [],
|
||||
rejected: [],
|
||||
expired: [],
|
||||
cart: [client_1.OrderStatus.awaiting_review],
|
||||
submitted: [client_1.OrderStatus.awaiting_review],
|
||||
needs_correction: [client_1.OrderStatus.awaiting_review, client_1.OrderStatus.pricing],
|
||||
awaiting_settlement_fix: [client_1.OrderStatus.awaiting_settlement],
|
||||
cash_in_progress: [client_1.OrderStatus.awaiting_cash_payment],
|
||||
cash_invoice_issued: [client_1.OrderStatus.awaiting_cash_payment],
|
||||
cash_payment_submitted: [client_1.OrderStatus.awaiting_cash_confirmation],
|
||||
check_rejected: [client_1.OrderStatus.check_needs_fix],
|
||||
};
|
||||
const ADMIN_TERMINAL_TRANSITIONS = [
|
||||
client_1.OrderStatus.cancelled,
|
||||
client_1.OrderStatus.rejected,
|
||||
];
|
||||
const FINAL_STATUSES = [
|
||||
client_1.OrderStatus.delivered,
|
||||
client_1.OrderStatus.cancelled,
|
||||
client_1.OrderStatus.rejected,
|
||||
client_1.OrderStatus.expired,
|
||||
];
|
||||
function isFinalStatus(status) {
|
||||
return FINAL_STATUSES.includes(status);
|
||||
}
|
||||
function allowedTransitions(from) {
|
||||
const next = [...(exports.ORDER_TRANSITIONS[from] ?? [])];
|
||||
if (!isFinalStatus(from)) {
|
||||
for (const terminal of ADMIN_TERMINAL_TRANSITIONS) {
|
||||
if (!next.includes(terminal))
|
||||
next.push(terminal);
|
||||
}
|
||||
}
|
||||
return next;
|
||||
}
|
||||
function canTransition(from, to) {
|
||||
return allowedTransitions(from).includes(to);
|
||||
}
|
||||
function assertTransition(from, to) {
|
||||
if (canTransition(from, to))
|
||||
return;
|
||||
throw new common_1.BadRequestException(`تغییر وضعیت از «${order_status_1.ORDER_STATUS_LABELS[from]}» به «${order_status_1.ORDER_STATUS_LABELS[to]}» مجاز نیست`);
|
||||
}
|
||||
//# sourceMappingURL=order-transitions.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"order-transitions.js","sourceRoot":"","sources":["../../../src/common/utils/order-transitions.ts"],"names":[],"mappings":";;;AA4EA,sCAEC;AAGD,gDAQC;AAED,sCAEC;AAED,4CAKC;AApGD,2CAAqD;AACrD,2CAA6C;AAC7C,iDAAqD;AASxC,QAAA,iBAAiB,GAAuC;IACnE,eAAe,EAAE,CAAC,oBAAW,CAAC,OAAO,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AC"}
|
||||
+6
@@ -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
@@ -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;
|
||||
|
||||
Vendored
+36
-21
@@ -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,
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+6
-4
@@ -18,17 +18,19 @@ export declare class DashboardController {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -50,8 +52,8 @@ export declare class DashboardController {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
|
||||
+6
-4
@@ -20,17 +20,19 @@ export declare class DashboardService {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -52,8 +54,8 @@ export declare class DashboardService {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import { NotificationTone, OrderStatus } from '@prisma/client';
|
||||
export type CustomerEvent = 'order_submitted' | 'invoice_priced' | 'checks_approved' | 'checks_need_fix' | 'receipt_approved' | 'receipt_rejected' | 'cash_invoice_reminder' | 'cash_invoice_expired' | 'order_preparing' | 'order_ready_to_ship' | 'order_shipped' | 'order_delivered' | 'order_cancelled';
|
||||
type SmsSwitch = 'smsOrderRegistered' | 'smsPricingReady' | 'smsPaymentReminder' | 'smsCheckReview' | 'smsShippingUpdate' | null;
|
||||
export type CustomerEventTemplate = {
|
||||
title: string;
|
||||
body: (ctx: EventContext) => string;
|
||||
sms?: (ctx: EventContext) => string;
|
||||
tone: NotificationTone;
|
||||
smsSwitch: SmsSwitch;
|
||||
};
|
||||
export type EventContext = {
|
||||
orderNumber: string;
|
||||
appName: string;
|
||||
amount?: number | null;
|
||||
note?: string | null;
|
||||
deadline?: string | null;
|
||||
carrier?: string | null;
|
||||
trackingNumber?: string | null;
|
||||
};
|
||||
export declare function eventForStatus(status: OrderStatus): CustomerEvent | null;
|
||||
export declare const CUSTOMER_EVENTS: Record<CustomerEvent, CustomerEventTemplate>;
|
||||
export {};
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CUSTOMER_EVENTS = void 0;
|
||||
exports.eventForStatus = eventForStatus;
|
||||
const client_1 = require("@prisma/client");
|
||||
function money(amount) {
|
||||
if (!amount)
|
||||
return '—';
|
||||
return `${Math.round(amount).toLocaleString('fa-IR')} تومان`;
|
||||
}
|
||||
function eventForStatus(status) {
|
||||
switch (status) {
|
||||
case client_1.OrderStatus.awaiting_settlement:
|
||||
return 'invoice_priced';
|
||||
case client_1.OrderStatus.preparing:
|
||||
case client_1.OrderStatus.final_approved:
|
||||
return 'order_preparing';
|
||||
case client_1.OrderStatus.ready_to_ship:
|
||||
return 'order_ready_to_ship';
|
||||
case client_1.OrderStatus.shipped:
|
||||
return 'order_shipped';
|
||||
case client_1.OrderStatus.delivered:
|
||||
return 'order_delivered';
|
||||
case client_1.OrderStatus.cancelled:
|
||||
case client_1.OrderStatus.rejected:
|
||||
return 'order_cancelled';
|
||||
case client_1.OrderStatus.expired:
|
||||
return 'cash_invoice_expired';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
exports.CUSTOMER_EVENTS = {
|
||||
order_submitted: {
|
||||
title: 'سفارش شما ثبت شد',
|
||||
body: (c) => `سفارش ${c.orderNumber} ثبت شد و برای بررسی و قیمتگذاری به کارشناسان ما رسید.`,
|
||||
sms: (c) => `سفارش ${c.orderNumber} در ${c.appName} ثبت شد. پس از قیمتگذاری، فاکتور برای شما ارسال میشود.`,
|
||||
tone: client_1.NotificationTone.info,
|
||||
smsSwitch: 'smsOrderRegistered',
|
||||
},
|
||||
invoice_priced: {
|
||||
title: 'فاکتور سفارش شما صادر شد',
|
||||
body: (c) => `مبلغ فاکتور سفارش ${c.orderNumber} ${money(c.amount)} است. برای ادامه، روش تسویه را انتخاب کنید.`,
|
||||
sms: (c) => `فاکتور سفارش ${c.orderNumber} به مبلغ ${money(c.amount)} صادر شد. برای انتخاب روش تسویه به پنل ${c.appName} مراجعه کنید.`,
|
||||
tone: client_1.NotificationTone.success,
|
||||
smsSwitch: 'smsPricingReady',
|
||||
},
|
||||
checks_approved: {
|
||||
title: 'چکهای شما تایید شد',
|
||||
body: (c) => `همه چکهای سفارش ${c.orderNumber} تایید شدند.`,
|
||||
sms: (c) => `چکهای سفارش ${c.orderNumber} تایید شد و سفارش به مرحله آمادهسازی میرود.`,
|
||||
tone: client_1.NotificationTone.success,
|
||||
smsSwitch: 'smsCheckReview',
|
||||
},
|
||||
checks_need_fix: {
|
||||
title: 'چک شما نیاز به اصلاح دارد',
|
||||
body: (c) => `یک یا چند چک سفارش ${c.orderNumber} تایید نشد${c.note ? `: ${c.note}` : '.'} لطفاً چکها را اصلاح و مجدداً ارسال کنید.`,
|
||||
sms: (c) => `چک سفارش ${c.orderNumber} تایید نشد. برای اصلاح چکها به پنل ${c.appName} مراجعه کنید.`,
|
||||
tone: client_1.NotificationTone.danger,
|
||||
smsSwitch: 'smsCheckReview',
|
||||
},
|
||||
receipt_approved: {
|
||||
title: 'پرداخت شما تایید شد',
|
||||
body: (c) => `رسید پرداخت سفارش ${c.orderNumber} تایید شد.`,
|
||||
sms: (c) => `رسید پرداخت سفارش ${c.orderNumber} تایید شد. سفارش شما در حال آمادهسازی است.`,
|
||||
tone: client_1.NotificationTone.success,
|
||||
smsSwitch: 'smsPaymentReminder',
|
||||
},
|
||||
receipt_rejected: {
|
||||
title: 'رسید پرداخت تایید نشد',
|
||||
body: (c) => `رسید پرداخت سفارش ${c.orderNumber} تایید نشد${c.note ? `: ${c.note}` : '.'} لطفاً رسید صحیح را ثبت کنید.`,
|
||||
sms: (c) => `رسید پرداخت سفارش ${c.orderNumber} تایید نشد. لطفاً در پنل ${c.appName} رسید را اصلاح کنید.`,
|
||||
tone: client_1.NotificationTone.danger,
|
||||
smsSwitch: 'smsPaymentReminder',
|
||||
},
|
||||
cash_invoice_reminder: {
|
||||
title: 'یادآوری مهلت پرداخت',
|
||||
body: (c) => `مهلت پرداخت فاکتور سفارش ${c.orderNumber} به پایان نزدیک است. مبلغ قابل پرداخت ${money(c.amount)}.`,
|
||||
sms: (c) => `مهلت پرداخت فاکتور سفارش ${c.orderNumber} در حال پایان است. مبلغ ${money(c.amount)}.`,
|
||||
tone: client_1.NotificationTone.warning,
|
||||
smsSwitch: 'smsPaymentReminder',
|
||||
},
|
||||
cash_invoice_expired: {
|
||||
title: 'مهلت پرداخت فاکتور تمام شد',
|
||||
body: (c) => `مهلت پرداخت فاکتور سفارش ${c.orderNumber} به پایان رسید. برای ثبت سفارش تازه با پشتیبانی تماس بگیرید.`,
|
||||
sms: (c) => `مهلت پرداخت فاکتور سفارش ${c.orderNumber} به پایان رسید.`,
|
||||
tone: client_1.NotificationTone.danger,
|
||||
smsSwitch: 'smsPaymentReminder',
|
||||
},
|
||||
order_preparing: {
|
||||
title: 'سفارش در حال آمادهسازی',
|
||||
body: (c) => `سفارش ${c.orderNumber} تایید نهایی شد و در حال آمادهسازی است.`,
|
||||
tone: client_1.NotificationTone.info,
|
||||
smsSwitch: null,
|
||||
},
|
||||
order_ready_to_ship: {
|
||||
title: 'سفارش آماده ارسال است',
|
||||
body: (c) => `سفارش ${c.orderNumber} آماده ارسال شد.`,
|
||||
sms: (c) => `سفارش ${c.orderNumber} آماده ارسال شد.`,
|
||||
tone: client_1.NotificationTone.info,
|
||||
smsSwitch: 'smsShippingUpdate',
|
||||
},
|
||||
order_shipped: {
|
||||
title: 'سفارش ارسال شد',
|
||||
body: (c) => `سفارش ${c.orderNumber} ارسال شد${c.carrier ? ` (${c.carrier})` : ''}${c.trackingNumber ? ` با کد رهگیری ${c.trackingNumber}` : ''}.`,
|
||||
sms: (c) => `سفارش ${c.orderNumber} ارسال شد${c.trackingNumber ? `. کد رهگیری: ${c.trackingNumber}` : '.'}`,
|
||||
tone: client_1.NotificationTone.success,
|
||||
smsSwitch: 'smsShippingUpdate',
|
||||
},
|
||||
order_delivered: {
|
||||
title: 'سفارش تحویل شد',
|
||||
body: (c) => `سفارش ${c.orderNumber} تحویل داده شد. از خرید شما سپاسگزاریم.`,
|
||||
sms: (c) => `سفارش ${c.orderNumber} تحویل داده شد. از خرید شما سپاسگزاریم.`,
|
||||
tone: client_1.NotificationTone.success,
|
||||
smsSwitch: 'smsShippingUpdate',
|
||||
},
|
||||
order_cancelled: {
|
||||
title: 'سفارش لغو شد',
|
||||
body: (c) => `سفارش ${c.orderNumber} لغو شد${c.note ? `: ${c.note}` : '.'} برای اطلاعات بیشتر با پشتیبانی تماس بگیرید.`,
|
||||
sms: (c) => `سفارش ${c.orderNumber} لغو شد.`,
|
||||
tone: client_1.NotificationTone.danger,
|
||||
smsSwitch: null,
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=notification-events.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"notification-events.js","sourceRoot":"","sources":["../../src/notifications/notification-events.ts"],"names":[],"mappings":";;;AAwDA,wCAqBC;AA7ED,2CAA+D;AA+C/D,SAAS,KAAK,CAAC,MAAsB;IACnC,IAAI,CAAC,MAAM;QAAE,OAAO,GAAG,CAAC;IACxB,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC;AAC/D,CAAC;AAMD,SAAgB,cAAc,CAAC,MAAmB;IAChD,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,oBAAW,CAAC,mBAAmB;YAClC,OAAO,gBAAgB,CAAC;QAC1B,KAAK,oBAAW,CAAC,SAAS,CAAC;QAC3B,KAAK,oBAAW,CAAC,cAAc;YAC7B,OAAO,iBAAiB,CAAC;QAC3B,KAAK,oBAAW,CAAC,aAAa;YAC5B,OAAO,qBAAqB,CAAC;QAC/B,KAAK,oBAAW,CAAC,OAAO;YACtB,OAAO,eAAe,CAAC;QACzB,KAAK,oBAAW,CAAC,SAAS;YACxB,OAAO,iBAAiB,CAAC;QAC3B,KAAK,oB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,CAAC,EAC3D,GAAG;QACL,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CACT,SAAS,CAAC,CAAC,WAAW,YACpB,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,GAC1D,EAAE;QACJ,IAAI,EAAE,yBAAgB,CAAC,OAAO;QAC9B,SAAS,EAAE,mBAAmB;KAC/B;IACD,eAAe,EAAE;QACf,KAAK,EAAE,gBAAgB;QACvB,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CACV,SAAS,CAAC,CAAC,WAAW,yCAAyC;QACjE,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,WAAW,yCAAyC;QAC3E,IAAI,EAAE,yBAAgB,CAAC,OAAO;QAC9B,SAAS,EAAE,mBAAmB;KAC/B;IACD,eAAe,EAAE;QACf,KAAK,EAAE,cAAc;QACrB,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CACV,SAAS,CAAC,CAAC,WAAW,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,8CAA8C;QAC5G,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,WAAW,UAAU;QAC5C,IAAI,EAAE,yBAAgB,CAAC,MAAM;QAC7B,SAAS,EAAE,IAAI;KAChB;CACF,CAAC"}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { NotificationsService } from './notifications.service';
|
||||
import type { AuthPrincipal } from '../common/decorators/current-user.decorator';
|
||||
export declare class CustomerNotificationsController {
|
||||
private readonly notifications;
|
||||
constructor(notifications: NotificationsService);
|
||||
list(user: AuthPrincipal): Promise<{
|
||||
id: string;
|
||||
orderId: string | undefined;
|
||||
event: string;
|
||||
title: string;
|
||||
body: string;
|
||||
tone: import("@prisma/client").$Enums.NotificationTone;
|
||||
link: string | undefined;
|
||||
isRead: boolean;
|
||||
sentAt: string;
|
||||
}[]>;
|
||||
unreadCount(user: AuthPrincipal): Promise<{
|
||||
count: number;
|
||||
}>;
|
||||
markAllRead(user: AuthPrincipal): Promise<{
|
||||
count: number;
|
||||
}>;
|
||||
markRead(user: AuthPrincipal, id: string): Promise<{
|
||||
count: number;
|
||||
}>;
|
||||
}
|
||||
export declare class AdminNotificationsController {
|
||||
private readonly notifications;
|
||||
constructor(notifications: NotificationsService);
|
||||
markAllRead(): Promise<{
|
||||
ok: boolean;
|
||||
}>;
|
||||
markRead(id: string): Promise<{
|
||||
ok: boolean;
|
||||
}>;
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AdminNotificationsController = exports.CustomerNotificationsController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const notifications_service_1 = require("./notifications.service");
|
||||
const auth_decorators_1 = require("../common/decorators/auth.decorators");
|
||||
const current_user_decorator_1 = require("../common/decorators/current-user.decorator");
|
||||
let CustomerNotificationsController = class CustomerNotificationsController {
|
||||
notifications;
|
||||
constructor(notifications) {
|
||||
this.notifications = notifications;
|
||||
}
|
||||
list(user) {
|
||||
return this.notifications.listForCustomer(user.id);
|
||||
}
|
||||
unreadCount(user) {
|
||||
return this.notifications.unreadCount(user.id);
|
||||
}
|
||||
markAllRead(user) {
|
||||
return this.notifications.markAllRead(user.id);
|
||||
}
|
||||
markRead(user, id) {
|
||||
return this.notifications.markRead(user.id, id);
|
||||
}
|
||||
};
|
||||
exports.CustomerNotificationsController = CustomerNotificationsController;
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomerNotificationsController.prototype, "list", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('unread-count'),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomerNotificationsController.prototype, "unreadCount", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)('read-all'),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomerNotificationsController.prototype, "markAllRead", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)(':id/read'),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__param(1, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomerNotificationsController.prototype, "markRead", null);
|
||||
exports.CustomerNotificationsController = CustomerNotificationsController = __decorate([
|
||||
(0, common_1.Controller)('notifications'),
|
||||
(0, auth_decorators_1.AuthType)('customer'),
|
||||
__metadata("design:paramtypes", [notifications_service_1.NotificationsService])
|
||||
], CustomerNotificationsController);
|
||||
let AdminNotificationsController = class AdminNotificationsController {
|
||||
notifications;
|
||||
constructor(notifications) {
|
||||
this.notifications = notifications;
|
||||
}
|
||||
markAllRead() {
|
||||
return this.notifications.markAllAdminRead();
|
||||
}
|
||||
markRead(id) {
|
||||
return this.notifications.markAdminRead(id);
|
||||
}
|
||||
};
|
||||
exports.AdminNotificationsController = AdminNotificationsController;
|
||||
__decorate([
|
||||
(0, common_1.Patch)('read-all'),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminNotificationsController.prototype, "markAllRead", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)(':id/read'),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminNotificationsController.prototype, "markRead", null);
|
||||
exports.AdminNotificationsController = AdminNotificationsController = __decorate([
|
||||
(0, common_1.Controller)('admin/notifications'),
|
||||
(0, auth_decorators_1.AuthType)('admin'),
|
||||
__metadata("design:paramtypes", [notifications_service_1.NotificationsService])
|
||||
], AdminNotificationsController);
|
||||
//# sourceMappingURL=notifications.controller.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"notifications.controller.js","sourceRoot":"","sources":["../../src/notifications/notifications.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+D;AAC/D,mEAA+D;AAC/D,0EAAgE;AAChE,wFAA0E;AAKnE,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IACb;IAA7B,YAA6B,aAAmC;QAAnC,kBAAa,GAAb,aAAa,CAAsB;IAAG,CAAC;IAGpE,IAAI,CAAgB,IAAmB;QACrC,OAAO,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IAGD,WAAW,CAAgB,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EAA4B;AAIvC;IADC,IAAA,cAAK,EAAC,UAAU,CAAC;;;;+DAGjB;AAGD;IADC,IAAA,cAAK,EAAC,UAAU,CAAC;IACR,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;4DAEpB;uCAXU,4BAA4B;IAFxC,IAAA,mBAAU,EAAC,qBAAqB,CAAC;IACjC,IAAA,0BAAQ,EAAC,OAAO,CAAC;qCAE4B,4CAAoB;GADrD,4BAA4B,CAYxC"}
|
||||
@@ -0,0 +1,2 @@
|
||||
export declare class NotificationsModule {
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NotificationsModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const notifications_service_1 = require("./notifications.service");
|
||||
const notifications_controller_1 = require("./notifications.controller");
|
||||
const sms_module_1 = require("../sms/sms.module");
|
||||
let NotificationsModule = class NotificationsModule {
|
||||
};
|
||||
exports.NotificationsModule = NotificationsModule;
|
||||
exports.NotificationsModule = NotificationsModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [sms_module_1.SmsModule],
|
||||
controllers: [notifications_controller_1.CustomerNotificationsController, notifications_controller_1.AdminNotificationsController],
|
||||
providers: [notifications_service_1.NotificationsService],
|
||||
exports: [notifications_service_1.NotificationsService],
|
||||
})
|
||||
], NotificationsModule);
|
||||
//# sourceMappingURL=notifications.module.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"notifications.module.js","sourceRoot":"","sources":["../../src/notifications/notifications.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mEAA+D;AAC/D,yEAGoC;AACpC,kDAA8C;AAQvC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAAG,CAAA;AAAtB,kDAAmB;8BAAnB,mBAAmB;IAN/B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,sBAAS,CAAC;QACpB,WAAW,EAAE,CAAC,0DAA+B,EAAE,uDAA4B,CAAC;QAC5E,SAAS,EAAE,CAAC,4CAAoB,CAAC;QACjC,OAAO,EAAE,CAAC,4CAAoB,CAAC;KAChC,CAAC;GACW,mBAAmB,CAAG"}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { NotificationTone } from '@prisma/client';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { SmsService } from '../sms/sms.service';
|
||||
import { type CustomerEvent } from './notification-events';
|
||||
type NotifyOptions = {
|
||||
amount?: number | null;
|
||||
note?: string | null;
|
||||
carrier?: string | null;
|
||||
trackingNumber?: string | null;
|
||||
};
|
||||
export declare class NotificationsService {
|
||||
private readonly prisma;
|
||||
private readonly sms;
|
||||
private readonly config;
|
||||
private readonly logger;
|
||||
constructor(prisma: PrismaService, sms: SmsService, config: ConfigService);
|
||||
notifyOrderEvent(orderId: string, event: CustomerEvent, options?: NotifyOptions): Promise<void>;
|
||||
dispatchOrderEvent(orderId: string, event: CustomerEvent, options?: NotifyOptions): void;
|
||||
notifyAdmin(input: {
|
||||
title: string;
|
||||
body: string;
|
||||
tone?: NotificationTone;
|
||||
link?: string;
|
||||
}): Promise<void>;
|
||||
dispatchAdmin(input: {
|
||||
title: string;
|
||||
body: string;
|
||||
tone?: NotificationTone;
|
||||
link?: string;
|
||||
}): void;
|
||||
listForCustomer(customerId: string, limit?: number): Promise<{
|
||||
id: string;
|
||||
orderId: string | undefined;
|
||||
event: string;
|
||||
title: string;
|
||||
body: string;
|
||||
tone: import("@prisma/client").$Enums.NotificationTone;
|
||||
link: string | undefined;
|
||||
isRead: boolean;
|
||||
sentAt: string;
|
||||
}[]>;
|
||||
unreadCount(customerId: string): Promise<{
|
||||
count: number;
|
||||
}>;
|
||||
markRead(customerId: string, id: string): Promise<{
|
||||
count: number;
|
||||
}>;
|
||||
markAllRead(customerId: string): Promise<{
|
||||
count: number;
|
||||
}>;
|
||||
markAdminRead(id: string): Promise<{
|
||||
ok: boolean;
|
||||
}>;
|
||||
markAllAdminRead(): Promise<{
|
||||
ok: boolean;
|
||||
}>;
|
||||
private appName;
|
||||
private isSmsEventEnabled;
|
||||
}
|
||||
export {};
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var NotificationsService_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NotificationsService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_service_1 = require("../prisma/prisma.service");
|
||||
const sms_service_1 = require("../sms/sms.service");
|
||||
const notification_events_1 = require("./notification-events");
|
||||
let NotificationsService = NotificationsService_1 = class NotificationsService {
|
||||
prisma;
|
||||
sms;
|
||||
config;
|
||||
logger = new common_1.Logger(NotificationsService_1.name);
|
||||
constructor(prisma, sms, config) {
|
||||
this.prisma = prisma;
|
||||
this.sms = sms;
|
||||
this.config = config;
|
||||
}
|
||||
async notifyOrderEvent(orderId, event, options = {}) {
|
||||
try {
|
||||
const order = await this.prisma.order.findUnique({
|
||||
where: { id: orderId },
|
||||
select: {
|
||||
id: true,
|
||||
orderNumber: true,
|
||||
userId: true,
|
||||
finalAmount: true,
|
||||
totalAmount: true,
|
||||
user: { select: { phone: true } },
|
||||
},
|
||||
});
|
||||
if (!order)
|
||||
return;
|
||||
const template = notification_events_1.CUSTOMER_EVENTS[event];
|
||||
const ctx = {
|
||||
orderNumber: order.orderNumber,
|
||||
appName: this.appName(),
|
||||
amount: options.amount ?? order.finalAmount ?? order.totalAmount ?? undefined,
|
||||
note: options.note ?? null,
|
||||
carrier: options.carrier ?? null,
|
||||
trackingNumber: options.trackingNumber ?? null,
|
||||
};
|
||||
const notification = await this.prisma.customerNotification.create({
|
||||
data: {
|
||||
customerId: order.userId,
|
||||
orderId: order.id,
|
||||
event,
|
||||
title: template.title,
|
||||
body: template.body(ctx),
|
||||
tone: template.tone,
|
||||
link: `/orders/${order.id}`,
|
||||
},
|
||||
});
|
||||
if (!template.sms || !template.smsSwitch)
|
||||
return;
|
||||
const enabled = await this.isSmsEventEnabled(template.smsSwitch);
|
||||
if (!enabled || !this.sms.isEnabled())
|
||||
return;
|
||||
const result = await this.sms.send(order.user.phone, template.sms(ctx));
|
||||
if (result.success) {
|
||||
await this.prisma.customerNotification.update({
|
||||
where: { id: notification.id },
|
||||
data: { smsSent: true },
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
this.logger.error(`notifyOrderEvent(${event}) failed for order ${orderId}`, err instanceof Error ? err.stack : err);
|
||||
}
|
||||
}
|
||||
dispatchOrderEvent(orderId, event, options = {}) {
|
||||
void this.notifyOrderEvent(orderId, event, options);
|
||||
}
|
||||
async notifyAdmin(input) {
|
||||
try {
|
||||
await this.prisma.adminNotification.create({
|
||||
data: {
|
||||
title: input.title,
|
||||
body: input.body,
|
||||
tone: input.tone ?? client_1.NotificationTone.info,
|
||||
link: input.link ?? null,
|
||||
},
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
this.logger.error('notifyAdmin failed', err instanceof Error ? err.stack : err);
|
||||
}
|
||||
}
|
||||
dispatchAdmin(input) {
|
||||
void this.notifyAdmin(input);
|
||||
}
|
||||
async listForCustomer(customerId, limit = 50) {
|
||||
const rows = await this.prisma.customerNotification.findMany({
|
||||
where: { customerId },
|
||||
orderBy: { sentAt: 'desc' },
|
||||
take: limit,
|
||||
});
|
||||
return rows.map((n) => ({
|
||||
id: n.id,
|
||||
orderId: n.orderId ?? undefined,
|
||||
event: n.event,
|
||||
title: n.title,
|
||||
body: n.body,
|
||||
tone: n.tone ?? client_1.NotificationTone.info,
|
||||
link: n.link ?? undefined,
|
||||
isRead: n.isRead,
|
||||
sentAt: n.sentAt.toISOString(),
|
||||
}));
|
||||
}
|
||||
async unreadCount(customerId) {
|
||||
const count = await this.prisma.customerNotification.count({
|
||||
where: { customerId, isRead: false },
|
||||
});
|
||||
return { count };
|
||||
}
|
||||
async markRead(customerId, id) {
|
||||
const existing = await this.prisma.customerNotification.findFirst({
|
||||
where: { id, customerId },
|
||||
select: { id: true },
|
||||
});
|
||||
if (!existing)
|
||||
throw new common_1.NotFoundException('اعلان یافت نشد');
|
||||
await this.prisma.customerNotification.update({
|
||||
where: { id },
|
||||
data: { isRead: true },
|
||||
});
|
||||
return this.unreadCount(customerId);
|
||||
}
|
||||
async markAllRead(customerId) {
|
||||
await this.prisma.customerNotification.updateMany({
|
||||
where: { customerId, isRead: false },
|
||||
data: { isRead: true },
|
||||
});
|
||||
return { count: 0 };
|
||||
}
|
||||
async markAdminRead(id) {
|
||||
await this.prisma.adminNotification.updateMany({
|
||||
where: { id },
|
||||
data: { isRead: true },
|
||||
});
|
||||
return { ok: true };
|
||||
}
|
||||
async markAllAdminRead() {
|
||||
await this.prisma.adminNotification.updateMany({
|
||||
where: { isRead: false },
|
||||
data: { isRead: true },
|
||||
});
|
||||
return { ok: true };
|
||||
}
|
||||
appName() {
|
||||
return this.config.get('SMS_APP_NAME', 'پارچه') ?? 'پارچه';
|
||||
}
|
||||
async isSmsEventEnabled(key) {
|
||||
const settings = await this.prisma.systemSettings.findUnique({
|
||||
where: { id: 'default' },
|
||||
select: {
|
||||
smsOrderRegistered: true,
|
||||
smsPricingReady: true,
|
||||
smsPaymentReminder: true,
|
||||
smsCheckReview: true,
|
||||
smsShippingUpdate: true,
|
||||
},
|
||||
});
|
||||
return settings ? settings[key] : true;
|
||||
}
|
||||
};
|
||||
exports.NotificationsService = NotificationsService;
|
||||
exports.NotificationsService = NotificationsService = NotificationsService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService,
|
||||
sms_service_1.SmsService,
|
||||
config_1.ConfigService])
|
||||
], NotificationsService);
|
||||
//# sourceMappingURL=notifications.service.js.map
|
||||
File diff suppressed because one or more lines are too long
+11
@@ -0,0 +1,11 @@
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { NotificationsService } from '../notifications/notifications.service';
|
||||
export declare class CashInvoiceSchedulerService {
|
||||
private readonly prisma;
|
||||
private readonly notifications;
|
||||
private readonly logger;
|
||||
constructor(prisma: PrismaService, notifications: NotificationsService);
|
||||
handleCashInvoices(): Promise<void>;
|
||||
sendReminders(): Promise<number>;
|
||||
expireOverdueInvoices(): Promise<number>;
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var CashInvoiceSchedulerService_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CashInvoiceSchedulerService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const schedule_1 = require("@nestjs/schedule");
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_service_1 = require("../prisma/prisma.service");
|
||||
const notifications_service_1 = require("../notifications/notifications.service");
|
||||
const PAYABLE_STATUSES = [
|
||||
client_1.OrderStatus.awaiting_cash_payment,
|
||||
client_1.OrderStatus.cash_invoice_issued,
|
||||
];
|
||||
const REMINDER_WINDOW_MS = 60 * 60 * 1000;
|
||||
let CashInvoiceSchedulerService = CashInvoiceSchedulerService_1 = class CashInvoiceSchedulerService {
|
||||
prisma;
|
||||
notifications;
|
||||
logger = new common_1.Logger(CashInvoiceSchedulerService_1.name);
|
||||
constructor(prisma, notifications) {
|
||||
this.prisma = prisma;
|
||||
this.notifications = notifications;
|
||||
}
|
||||
async handleCashInvoices() {
|
||||
await this.sendReminders();
|
||||
await this.expireOverdueInvoices();
|
||||
}
|
||||
async sendReminders() {
|
||||
const now = new Date();
|
||||
const soon = new Date(now.getTime() + REMINDER_WINDOW_MS);
|
||||
try {
|
||||
const orders = await this.prisma.order.findMany({
|
||||
where: {
|
||||
status: { in: PAYABLE_STATUSES },
|
||||
cashReminderSentAt: null,
|
||||
cashInvoiceExpiresAt: { gt: now, lte: soon },
|
||||
},
|
||||
select: { id: true, finalAmount: true },
|
||||
});
|
||||
for (const order of orders) {
|
||||
await this.prisma.order.update({
|
||||
where: { id: order.id },
|
||||
data: { cashReminderSentAt: now },
|
||||
});
|
||||
await this.notifications.notifyOrderEvent(order.id, 'cash_invoice_reminder', { amount: order.finalAmount });
|
||||
}
|
||||
return orders.length;
|
||||
}
|
||||
catch (err) {
|
||||
this.logger.error('sendReminders failed', err instanceof Error ? err.stack : err);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
async expireOverdueInvoices() {
|
||||
const now = new Date();
|
||||
try {
|
||||
const orders = await this.prisma.order.findMany({
|
||||
where: {
|
||||
status: { in: PAYABLE_STATUSES },
|
||||
cashInvoiceExpiresAt: { lt: now },
|
||||
},
|
||||
select: { id: true, orderNumber: true, status: true },
|
||||
});
|
||||
for (const order of orders) {
|
||||
await this.prisma.$transaction([
|
||||
this.prisma.order.update({
|
||||
where: { id: order.id },
|
||||
data: { status: client_1.OrderStatus.expired },
|
||||
}),
|
||||
this.prisma.orderStatusHistory.create({
|
||||
data: {
|
||||
orderId: order.id,
|
||||
fromStatus: order.status,
|
||||
toStatus: client_1.OrderStatus.expired,
|
||||
changedBy: 'system',
|
||||
note: 'پایان مهلت پرداخت فاکتور نقدی',
|
||||
},
|
||||
}),
|
||||
]);
|
||||
await this.notifications.notifyOrderEvent(order.id, 'cash_invoice_expired');
|
||||
this.notifications.dispatchAdmin({
|
||||
title: 'فاکتور نقدی منقضی شد',
|
||||
body: `مهلت پرداخت سفارش ${order.orderNumber} به پایان رسید و سفارش منقضی شد.`,
|
||||
link: '/orders',
|
||||
});
|
||||
}
|
||||
if (orders.length) {
|
||||
this.logger.log(`${orders.length} فاکتور نقدی منقضی شد`);
|
||||
}
|
||||
return orders.length;
|
||||
}
|
||||
catch (err) {
|
||||
this.logger.error('expireOverdueInvoices failed', err instanceof Error ? err.stack : err);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.CashInvoiceSchedulerService = CashInvoiceSchedulerService;
|
||||
__decorate([
|
||||
(0, schedule_1.Cron)(schedule_1.CronExpression.EVERY_10_MINUTES),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], CashInvoiceSchedulerService.prototype, "handleCashInvoices", null);
|
||||
exports.CashInvoiceSchedulerService = CashInvoiceSchedulerService = CashInvoiceSchedulerService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService,
|
||||
notifications_service_1.NotificationsService])
|
||||
], CashInvoiceSchedulerService);
|
||||
//# sourceMappingURL=cash-invoice-scheduler.service.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cash-invoice-scheduler.service.js","sourceRoot":"","sources":["../../src/orders/cash-invoice-scheduler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,+CAAwD;AACxD,2CAA6C;AAC7C,6DAAyD;AACzD,kFAA8E;AAG9E,MAAM,gBAAgB,GAAkB;IACtC,oBAAW,CAAC,qBAAqB;IACjC,oBAAW,CAAC,mBAAmB;CAChC,CAAC;AAGF,MAAM,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAGnC,IAAM,2BAA2B,mCAAjC,MAAM,2BAA2B;IAInB;IACA;IAJF,MAAM,GAAG,IAAI,eAAM,CAAC,6BAA2B,CAAC,IAAI,CAAC,CAAC;IAEvE,YACmB,MAAqB,EACrB,aAAmC;QADnC,WAAM,GAAN,MAAM,CAAe;QACrB,kBAAa,GAAb,aAAa,CAAsB;IACnD,CAAC;IAGE,AAAN,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC3B,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACrC,CAAC;IAGD,KAAK,CAAC,aAAa;QACjB,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,kBAAkB,CAAC,CAAC;QAE1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,MAAM,CAAC;QACvB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,8BAA8B,EAC9B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CACvC,CAAC;YACF,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;CACF,CAAA;AAvGY,kEAA2B;AAShC;IADL,IAAA,eAAI,EAAC,yBAAc,CAAC,gBAAgB,CAAC;;;;qEAIrC;sCAZU,2BAA2B;IADvC,IAAA,mBAAU,GAAE;qCAKgB,8BAAa;QACN,4CAAoB;GAL3C,2BAA2B,CAuGvC"}
|
||||
Vendored
+6
-1
@@ -22,13 +22,17 @@ export declare class SubmitOrderCheckDto {
|
||||
}
|
||||
export declare class SubmitOrderDto {
|
||||
companyId: string;
|
||||
settlementType: SettlementType;
|
||||
settlementType?: SettlementType;
|
||||
settlementMethod?: SettlementType;
|
||||
checkMode?: CheckRegistrationMode;
|
||||
notes?: string;
|
||||
items: SubmitOrderItemDto[];
|
||||
checks?: SubmitOrderCheckDto[];
|
||||
}
|
||||
export declare class ChooseSettlementDto {
|
||||
settlementType: SettlementType;
|
||||
checkMode?: CheckRegistrationMode;
|
||||
}
|
||||
export declare class AdminCreateOrderDto {
|
||||
userId?: string;
|
||||
customerPhone?: string;
|
||||
@@ -57,6 +61,7 @@ export declare class UpdateOrderStatusDto {
|
||||
status: OrderStatus;
|
||||
note?: string;
|
||||
reason?: string;
|
||||
force?: boolean;
|
||||
}
|
||||
export declare class UpdateOrderChecksDto {
|
||||
checks: SubmitOrderCheckDto[];
|
||||
|
||||
Vendored
+23
-1
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UpdateOrderChecksDto = exports.UpdateOrderStatusDto = exports.UpdateOrderPricingDto = exports.OrderItemPricingDto = exports.AdminCreateOrderDto = exports.SubmitOrderDto = exports.SubmitOrderCheckDto = exports.SubmitOrderItemDto = void 0;
|
||||
exports.UpdateOrderChecksDto = exports.UpdateOrderStatusDto = exports.UpdateOrderPricingDto = exports.OrderItemPricingDto = exports.AdminCreateOrderDto = exports.ChooseSettlementDto = exports.SubmitOrderDto = exports.SubmitOrderCheckDto = exports.SubmitOrderItemDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const class_transformer_1 = require("class-transformer");
|
||||
const client_1 = require("@prisma/client");
|
||||
@@ -137,6 +137,7 @@ __decorate([
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderDto.prototype, "companyId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsEnum)(client_1.SettlementType),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderDto.prototype, "settlementType", void 0);
|
||||
@@ -169,6 +170,20 @@ __decorate([
|
||||
(0, class_transformer_1.Type)(() => SubmitOrderCheckDto),
|
||||
__metadata("design:type", Array)
|
||||
], SubmitOrderDto.prototype, "checks", void 0);
|
||||
class ChooseSettlementDto {
|
||||
settlementType;
|
||||
checkMode;
|
||||
}
|
||||
exports.ChooseSettlementDto = ChooseSettlementDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsEnum)(client_1.SettlementType),
|
||||
__metadata("design:type", String)
|
||||
], ChooseSettlementDto.prototype, "settlementType", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsEnum)(client_1.CheckRegistrationMode),
|
||||
__metadata("design:type", String)
|
||||
], ChooseSettlementDto.prototype, "checkMode", void 0);
|
||||
class AdminCreateOrderDto {
|
||||
userId;
|
||||
customerPhone;
|
||||
@@ -305,6 +320,7 @@ class UpdateOrderStatusDto {
|
||||
status;
|
||||
note;
|
||||
reason;
|
||||
force;
|
||||
}
|
||||
exports.UpdateOrderStatusDto = UpdateOrderStatusDto;
|
||||
__decorate([
|
||||
@@ -321,6 +337,12 @@ __decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], UpdateOrderStatusDto.prototype, "reason", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_transformer_1.Type)(() => Boolean),
|
||||
(0, class_validator_1.IsBoolean)(),
|
||||
__metadata("design:type", Boolean)
|
||||
], UpdateOrderStatusDto.prototype, "force", void 0);
|
||||
class UpdateOrderChecksDto {
|
||||
checks;
|
||||
checkMode;
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+158
-37
@@ -1,6 +1,6 @@
|
||||
import { OrdersService } from './orders.service';
|
||||
import type { AuthPrincipal } from '../common/decorators/current-user.decorator';
|
||||
import { AdminCreateOrderDto, SubmitOrderDto, UpdateOrderChecksDto, UpdateOrderPricingDto, UpdateOrderStatusDto } from './dto/order.dto';
|
||||
import { AdminCreateOrderDto, ChooseSettlementDto, SubmitOrderDto, UpdateOrderChecksDto, UpdateOrderPricingDto, UpdateOrderStatusDto } from './dto/order.dto';
|
||||
export declare class CustomerOrdersController {
|
||||
private readonly ordersService;
|
||||
constructor(ordersService: OrdersService);
|
||||
@@ -10,17 +10,19 @@ export declare class CustomerOrdersController {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -42,8 +44,8 @@ export declare class CustomerOrdersController {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -111,17 +113,19 @@ export declare class CustomerOrdersController {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -143,8 +147,8 @@ export declare class CustomerOrdersController {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -212,17 +216,19 @@ export declare class CustomerOrdersController {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -244,8 +250,111 @@ export declare class CustomerOrdersController {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
}[];
|
||||
checks: {
|
||||
id: string;
|
||||
orderId: string;
|
||||
row: number;
|
||||
amount: number;
|
||||
dueDate: string;
|
||||
sayadId: string | undefined;
|
||||
checkNumber: string | undefined;
|
||||
ownerNationalId: string | undefined;
|
||||
ownerFirstName: string | undefined;
|
||||
ownerLastName: string | undefined;
|
||||
bankName: string;
|
||||
branchName: string | undefined;
|
||||
frontImage: string | undefined;
|
||||
backImage: string | undefined;
|
||||
notes: string | undefined;
|
||||
mode: import("@prisma/client").$Enums.CheckRegistrationMode;
|
||||
status: import("@prisma/client").$Enums.CheckStatus;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}[];
|
||||
cashReceipt: {
|
||||
id: string;
|
||||
amount: number;
|
||||
paidAmount: number | null;
|
||||
transferDate: string | null;
|
||||
transferTime: string | undefined;
|
||||
trackingNumber: string | undefined;
|
||||
trackingCode: string | undefined;
|
||||
destinationAccountId: string | undefined;
|
||||
receiptImage: string | undefined;
|
||||
notes: string | undefined;
|
||||
expiresAt: string | undefined;
|
||||
status: import("@prisma/client").$Enums.CashPaymentStatus;
|
||||
submittedAt: string | undefined;
|
||||
createdAt: string;
|
||||
} | undefined;
|
||||
shipment: {
|
||||
id: string;
|
||||
orderId: string;
|
||||
carrier: string;
|
||||
trackingNumber: string;
|
||||
meterage: number;
|
||||
status: import("@prisma/client").$Enums.ShipmentStatus;
|
||||
shippedAt: string | null;
|
||||
deliveredAt: string | null;
|
||||
} | undefined;
|
||||
statusHistory: {
|
||||
id: string;
|
||||
fromStatus: import("@prisma/client").$Enums.OrderStatus | null;
|
||||
toStatus: import("@prisma/client").$Enums.OrderStatus;
|
||||
changedBy: string;
|
||||
note: string | undefined;
|
||||
reason: string | undefined;
|
||||
changedAt: string;
|
||||
}[];
|
||||
}>;
|
||||
chooseSettlement(user: AuthPrincipal, id: string, dto: ChooseSettlementDto): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
cashInvoiceExpiresAt: string | undefined;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
customerName: string;
|
||||
customerPhone: string;
|
||||
customerNationalId: string | undefined;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
items: {
|
||||
id: string;
|
||||
productId: string | undefined;
|
||||
catalogCode: string;
|
||||
productName: string;
|
||||
productCode: string | undefined;
|
||||
color: string;
|
||||
requestedMeterage: number;
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -313,17 +422,19 @@ export declare class CustomerOrdersController {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -345,8 +456,8 @@ export declare class CustomerOrdersController {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -418,17 +529,19 @@ export declare class AdminOrdersController {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -450,8 +563,8 @@ export declare class AdminOrdersController {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -519,17 +632,19 @@ export declare class AdminOrdersController {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -551,8 +666,8 @@ export declare class AdminOrdersController {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -620,17 +735,19 @@ export declare class AdminOrdersController {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -652,8 +769,8 @@ export declare class AdminOrdersController {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -721,17 +838,19 @@ export declare class AdminOrdersController {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -753,8 +872,8 @@ export declare class AdminOrdersController {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -822,17 +941,19 @@ export declare class AdminOrdersController {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -854,8 +975,8 @@ export declare class AdminOrdersController {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
|
||||
Vendored
+13
@@ -32,6 +32,9 @@ let CustomerOrdersController = class CustomerOrdersController {
|
||||
submit(user, dto) {
|
||||
return this.ordersService.submitOrder(user.id, dto);
|
||||
}
|
||||
chooseSettlement(user, id, dto) {
|
||||
return this.ordersService.chooseSettlement(user.id, id, dto);
|
||||
}
|
||||
updateChecks(user, id, dto) {
|
||||
return this.ordersService.updateChecks(user.id, id, dto);
|
||||
}
|
||||
@@ -63,6 +66,16 @@ __decorate([
|
||||
__metadata("design:paramtypes", [Object, order_dto_1.SubmitOrderDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomerOrdersController.prototype, "submit", null);
|
||||
__decorate([
|
||||
(0, auth_decorators_1.AuthType)('customer'),
|
||||
(0, common_1.Post)(':id/settlement'),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__param(1, (0, common_1.Param)('id')),
|
||||
__param(2, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, String, order_dto_1.ChooseSettlementDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomerOrdersController.prototype, "chooseSettlement", null);
|
||||
__decorate([
|
||||
(0, auth_decorators_1.AuthType)('customer'),
|
||||
(0, common_1.Patch)(':id/checks'),
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"orders.controller.js","sourceRoot":"","sources":["../../src/orders/orders.contro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AI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AAnCY,sDAAqB;AAIhC;IADC,IAAA,YAAG,GAAE;IACG,WAAA,IAAA,cAAK,EAAC,QAAQ,CAAC,CAAA;IAAmB,WAAA,IAAA,cAAK,EAAC,GAAG,CAAC,CAAA;;;;oDAEpD;AAGD;IADC,IAAA,YAAG,EAAC,KAAK,CAAC;IACF,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;oDAEnB;AAGD;IADC,IAAA,aAAI,GAAE;IACC,WAAA,IAAA,oCAAW,GAAE,CAAA;IAAuB,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,+BAAmB;;mDAE1E;AAGD;IADC,IAAA,cAAK,EAAC,aAAa,CAAC;IAElB,WAAA,IAAA,oCAAW,GAAE,CAAA;IACb,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,WAAA,IAAA,aAAI,GAAE,CAAA;;qDAAM,iCAAqB;;0DAGnC;AAGD;IADC,IAAA,cAAK,EAAC,YAAY,CAAC;IAEjB,WAAA,IAAA,oCAAW,GAAE,CAAA;IACb,WAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,WAAA,IAAA,aAAI,GAAE,CAAA;;qDAAM,gCAAoB;;yDAGlC;gCAlCU,qBAAqB;IAFjC,IAAA,mBAAU,EAAC,cAAc,CAAC;IAC1B,IAAA,0BAAQ,EAAC,OAAO,CAAC;qCAE4B,8BAAa;GAD9C,qBAAqB,CAmCjC"}
|
||||
Vendored
+4
-1
@@ -10,13 +10,16 @@ exports.OrdersModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const orders_controller_1 = require("./orders.controller");
|
||||
const orders_service_1 = require("./orders.service");
|
||||
const cash_invoice_scheduler_service_1 = require("./cash-invoice-scheduler.service");
|
||||
const notifications_module_1 = require("../notifications/notifications.module");
|
||||
let OrdersModule = class OrdersModule {
|
||||
};
|
||||
exports.OrdersModule = OrdersModule;
|
||||
exports.OrdersModule = OrdersModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [notifications_module_1.NotificationsModule],
|
||||
controllers: [orders_controller_1.CustomerOrdersController, orders_controller_1.AdminOrdersController],
|
||||
providers: [orders_service_1.OrdersService],
|
||||
providers: [orders_service_1.OrdersService, cash_invoice_scheduler_service_1.CashInvoiceSchedulerService],
|
||||
exports: [orders_service_1.OrdersService],
|
||||
})
|
||||
], OrdersModule);
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"orders.module.js","sourceRoot":"","sources":["../../src/orders/orders.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2DAG6B;AAC7B,qDAAiD;AAO1C,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IALxB,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,4CAAwB,EAAE,yCAAqB,CAAC;QAC9D,SAAS,EAAE,CAAC,8BAAa,CAAC;QAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,YAAY,CAAG"}
|
||||
{"version":3,"file":"orders.module.js","sourceRoot":"","sources":["../../src/orders/orders.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2DAG6B;AAC7B,qDAAiD;AACjD,qFAA+E;AAC/E,gFAA4E;AAQrE,IAAM,YAAY,GAAlB,MAAM,YAAY;CAAG,CAAA;AAAf,oCAAY;uBAAZ,YAAY;IANxB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0CAAmB,CAAC;QAC9B,WAAW,EAAE,CAAC,4CAAwB,EAAE,yCAAqB,CAAC;QAC9D,SAAS,EAAE,CAAC,8BAAa,EAAE,4DAA2B,CAAC;QACvD,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,YAAY,CAAG"}
|
||||
Vendored
+167
-42
@@ -1,6 +1,7 @@
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { AdminCreateOrderDto, SubmitOrderDto, UpdateOrderChecksDto, UpdateOrderPricingDto, UpdateOrderStatusDto } from './dto/order.dto';
|
||||
import { AdminCreateOrderDto, ChooseSettlementDto, SubmitOrderDto, UpdateOrderChecksDto, UpdateOrderPricingDto, UpdateOrderStatusDto } from './dto/order.dto';
|
||||
import { NotificationsService } from '../notifications/notifications.service';
|
||||
declare const orderInclude: {
|
||||
items: true;
|
||||
checks: {
|
||||
@@ -23,24 +24,27 @@ type OrderFull = Prisma.OrderGetPayload<{
|
||||
}>;
|
||||
export declare class OrdersService {
|
||||
private readonly prisma;
|
||||
constructor(prisma: PrismaService);
|
||||
private readonly notifications;
|
||||
constructor(prisma: PrismaService, notifications: NotificationsService);
|
||||
findMyOrders(userId: string): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -62,8 +66,8 @@ export declare class OrdersService {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -131,17 +135,19 @@ export declare class OrdersService {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -163,8 +169,8 @@ export declare class OrdersService {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -235,17 +241,19 @@ export declare class OrdersService {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -267,8 +275,8 @@ export declare class OrdersService {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -336,17 +344,19 @@ export declare class OrdersService {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -368,8 +378,8 @@ export declare class OrdersService {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -437,17 +447,19 @@ export declare class OrdersService {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -469,8 +481,111 @@ export declare class OrdersService {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
}[];
|
||||
checks: {
|
||||
id: string;
|
||||
orderId: string;
|
||||
row: number;
|
||||
amount: number;
|
||||
dueDate: string;
|
||||
sayadId: string | undefined;
|
||||
checkNumber: string | undefined;
|
||||
ownerNationalId: string | undefined;
|
||||
ownerFirstName: string | undefined;
|
||||
ownerLastName: string | undefined;
|
||||
bankName: string;
|
||||
branchName: string | undefined;
|
||||
frontImage: string | undefined;
|
||||
backImage: string | undefined;
|
||||
notes: string | undefined;
|
||||
mode: import("@prisma/client").$Enums.CheckRegistrationMode;
|
||||
status: import("@prisma/client").$Enums.CheckStatus;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}[];
|
||||
cashReceipt: {
|
||||
id: string;
|
||||
amount: number;
|
||||
paidAmount: number | null;
|
||||
transferDate: string | null;
|
||||
transferTime: string | undefined;
|
||||
trackingNumber: string | undefined;
|
||||
trackingCode: string | undefined;
|
||||
destinationAccountId: string | undefined;
|
||||
receiptImage: string | undefined;
|
||||
notes: string | undefined;
|
||||
expiresAt: string | undefined;
|
||||
status: import("@prisma/client").$Enums.CashPaymentStatus;
|
||||
submittedAt: string | undefined;
|
||||
createdAt: string;
|
||||
} | undefined;
|
||||
shipment: {
|
||||
id: string;
|
||||
orderId: string;
|
||||
carrier: string;
|
||||
trackingNumber: string;
|
||||
meterage: number;
|
||||
status: import("@prisma/client").$Enums.ShipmentStatus;
|
||||
shippedAt: string | null;
|
||||
deliveredAt: string | null;
|
||||
} | undefined;
|
||||
statusHistory: {
|
||||
id: string;
|
||||
fromStatus: import("@prisma/client").$Enums.OrderStatus | null;
|
||||
toStatus: import("@prisma/client").$Enums.OrderStatus;
|
||||
changedBy: string;
|
||||
note: string | undefined;
|
||||
reason: string | undefined;
|
||||
changedAt: string;
|
||||
}[];
|
||||
}>;
|
||||
chooseSettlement(userId: string, id: string, dto: ChooseSettlementDto): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
cashInvoiceExpiresAt: string | undefined;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
customerName: string;
|
||||
customerPhone: string;
|
||||
customerNationalId: string | undefined;
|
||||
customerType: import("@prisma/client").$Enums.CustomerType;
|
||||
items: {
|
||||
id: string;
|
||||
productId: string | undefined;
|
||||
catalogCode: string;
|
||||
productName: string;
|
||||
productCode: string | undefined;
|
||||
color: string;
|
||||
requestedMeterage: number;
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -538,17 +653,19 @@ export declare class OrdersService {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -570,8 +687,8 @@ export declare class OrdersService {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -639,17 +756,19 @@ export declare class OrdersService {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -671,8 +790,8 @@ export declare class OrdersService {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -740,17 +859,19 @@ export declare class OrdersService {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -772,8 +893,8 @@ export declare class OrdersService {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -841,17 +962,19 @@ export declare class OrdersService {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -873,8 +996,8 @@ export declare class OrdersService {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
@@ -946,17 +1069,19 @@ export declare class OrdersService {
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType | null;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType | null;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
allowedTransitions: import("@prisma/client").$Enums.OrderStatus[];
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
pricesVisible: boolean;
|
||||
notes: string | undefined;
|
||||
checkRassDays: number | undefined;
|
||||
checkRassDate: string | undefined;
|
||||
@@ -978,8 +1103,8 @@ export declare class OrdersService {
|
||||
confirmedMeterage: number | null;
|
||||
unitPrice: number | null;
|
||||
supplyPrice: number | null;
|
||||
unitDiscount: number;
|
||||
discount: number;
|
||||
unitDiscount: number | null;
|
||||
discount: number | null;
|
||||
lineTotal: number | null;
|
||||
totalAmount: number | null;
|
||||
notes: string | undefined;
|
||||
|
||||
Vendored
+132
-72
@@ -17,6 +17,10 @@ const order_number_1 = require("../common/utils/order-number");
|
||||
const check_rass_1 = require("../common/utils/check-rass");
|
||||
const cash_expiry_1 = require("../common/utils/cash-expiry");
|
||||
const order_status_1 = require("../common/utils/order-status");
|
||||
const order_transitions_1 = require("../common/utils/order-transitions");
|
||||
const meterage_1 = require("../common/utils/meterage");
|
||||
const notifications_service_1 = require("../notifications/notifications.service");
|
||||
const notification_events_1 = require("../notifications/notification-events");
|
||||
const name_1 = require("../common/utils/name");
|
||||
const phone_1 = require("../common/utils/phone");
|
||||
const orderInclude = {
|
||||
@@ -32,19 +36,21 @@ function roundMoney(value) {
|
||||
return Math.round(value * 100) / 100;
|
||||
}
|
||||
const CHECK_EDITABLE_STATUSES = [
|
||||
client_1.OrderStatus.awaiting_review,
|
||||
client_1.OrderStatus.pricing,
|
||||
client_1.OrderStatus.needs_correction,
|
||||
client_1.OrderStatus.awaiting_settlement_fix,
|
||||
client_1.OrderStatus.check_in_progress,
|
||||
client_1.OrderStatus.awaiting_check_review,
|
||||
client_1.OrderStatus.check_needs_fix,
|
||||
client_1.OrderStatus.check_rejected,
|
||||
];
|
||||
const PRICE_HIDDEN_STATUSES = [
|
||||
client_1.OrderStatus.awaiting_review,
|
||||
client_1.OrderStatus.pricing,
|
||||
];
|
||||
let OrdersService = class OrdersService {
|
||||
prisma;
|
||||
constructor(prisma) {
|
||||
notifications;
|
||||
constructor(prisma, notifications) {
|
||||
this.prisma = prisma;
|
||||
this.notifications = notifications;
|
||||
}
|
||||
async findMyOrders(userId) {
|
||||
const orders = await this.prisma.order.findMany({
|
||||
@@ -95,12 +101,17 @@ let OrdersService = class OrdersService {
|
||||
return this.mapOrder(order, true);
|
||||
}
|
||||
async submitOrder(userId, dto) {
|
||||
const company = await this.prisma.company.findUnique({
|
||||
where: { id: dto.companyId },
|
||||
});
|
||||
const [company, settings] = await Promise.all([
|
||||
this.prisma.company.findUnique({ where: { id: dto.companyId } }),
|
||||
this.prisma.systemSettings.findUnique({
|
||||
where: { id: 'default' },
|
||||
select: { maxMeteragePerInvoice: true },
|
||||
}),
|
||||
]);
|
||||
if (!company || !company.isActive) {
|
||||
throw new common_1.NotFoundException('شرکت یافت نشد یا غیرفعال است');
|
||||
}
|
||||
const maxMeterage = (0, meterage_1.resolveMaxMeterage)(company.maxMeteragePerInvoice, settings?.maxMeteragePerInvoice);
|
||||
const productIds = dto.items.map((i) => i.productId);
|
||||
const products = await this.prisma.product.findMany({
|
||||
where: { id: { in: productIds }, companyId: company.id, isActive: true },
|
||||
@@ -128,31 +139,12 @@ let OrdersService = class OrdersService {
|
||||
productCode: product.code,
|
||||
color: product.color,
|
||||
requestedMeterage: item.meterage,
|
||||
unitPrice: product.basePrice,
|
||||
notes: item.notes?.trim() || null,
|
||||
};
|
||||
});
|
||||
if (totalMeterage > company.maxMeteragePerInvoice) {
|
||||
throw new common_1.BadRequestException(`حداکثر متراژ مجاز هر فاکتور ${company.maxMeteragePerInvoice} متر است`);
|
||||
if (totalMeterage > maxMeterage) {
|
||||
throw new common_1.BadRequestException(`حداکثر متراژ مجاز هر فاکتور ${maxMeterage} متر است`);
|
||||
}
|
||||
const settlementType = dto.settlementType;
|
||||
if (settlementType === client_1.SettlementType.check) {
|
||||
if (!dto.checks?.length) {
|
||||
throw new common_1.BadRequestException('برای تسویه چکی حداقل یک چک لازم است');
|
||||
}
|
||||
}
|
||||
const checkMode = settlementType === client_1.SettlementType.check
|
||||
? (dto.checkMode ?? client_1.CheckRegistrationMode.full)
|
||||
: null;
|
||||
const rass = settlementType === client_1.SettlementType.check && dto.checks?.length
|
||||
? (0, check_rass_1.calculateCheckRass)(dto.checks.map((c) => ({
|
||||
amount: c.amount,
|
||||
dueDate: c.dueDate,
|
||||
})))
|
||||
: null;
|
||||
const cashInvoiceExpiresAt = settlementType === client_1.SettlementType.cash
|
||||
? (0, cash_expiry_1.computeCashInvoiceExpiry)(company)
|
||||
: null;
|
||||
const order = await this.createWithUniqueOrderNumber((orderNumber) => this.prisma.$transaction(async (tx) => {
|
||||
const created = await tx.order.create({
|
||||
data: {
|
||||
@@ -160,33 +152,19 @@ let OrdersService = class OrdersService {
|
||||
userId,
|
||||
companyId: company.id,
|
||||
companyName: company.name,
|
||||
settlementType,
|
||||
checkMode,
|
||||
settlementType: null,
|
||||
checkMode: null,
|
||||
status: client_1.OrderStatus.awaiting_review,
|
||||
totalMeterage,
|
||||
notes: dto.notes?.trim() || null,
|
||||
checkRassDays: rass?.rassDays ?? null,
|
||||
checkRassDate: rass?.rassDate ? new Date(rass.rassDate) : null,
|
||||
cashInvoiceExpiresAt,
|
||||
items: { create: itemsData },
|
||||
checks: settlementType === client_1.SettlementType.check && dto.checks
|
||||
? {
|
||||
create: dto.checks.map((c, index) => this.mapCheckCreate(c, index + 1, checkMode)),
|
||||
}
|
||||
: undefined,
|
||||
statusHistory: {
|
||||
create: [
|
||||
{
|
||||
fromStatus: null,
|
||||
toStatus: client_1.OrderStatus.submitted,
|
||||
changedBy: 'customer',
|
||||
note: 'سفارش ثبت شد',
|
||||
},
|
||||
{
|
||||
fromStatus: client_1.OrderStatus.submitted,
|
||||
toStatus: client_1.OrderStatus.awaiting_review,
|
||||
changedBy: 'customer',
|
||||
note: 'ارسال برای بررسی مدیریت',
|
||||
note: 'سفارش ثبت شد و برای بررسی مدیریت ارسال شد',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -201,13 +179,57 @@ let OrdersService = class OrdersService {
|
||||
}
|
||||
return created;
|
||||
}));
|
||||
this.notifications.dispatchOrderEvent(order.id, 'order_submitted');
|
||||
this.notifications.dispatchAdmin({
|
||||
title: 'سفارش جدید ثبت شد',
|
||||
body: `سفارش ${order.orderNumber} با ${order.items.length} قلم و ${order.totalMeterage} متر در انتظار قیمتگذاری است.`,
|
||||
link: `/orders/${order.id}`,
|
||||
});
|
||||
return this.mapOrder(order);
|
||||
}
|
||||
async adminCreate(adminId, dto) {
|
||||
const settlementType = dto.settlementType ?? dto.settlementMethod;
|
||||
if (!settlementType) {
|
||||
throw new common_1.BadRequestException('نوع تسویه الزامی است');
|
||||
async chooseSettlement(userId, id, dto) {
|
||||
const order = await this.getOrder(id);
|
||||
if (order.userId !== userId) {
|
||||
throw new common_1.ForbiddenException('دسترسی به این سفارش مجاز نیست');
|
||||
}
|
||||
if (order.status !== client_1.OrderStatus.awaiting_settlement) {
|
||||
throw new common_1.BadRequestException('انتخاب روش تسویه فقط پس از صدور فاکتور توسط مدیریت امکانپذیر است');
|
||||
}
|
||||
const isCash = dto.settlementType === client_1.SettlementType.cash;
|
||||
const nextStatus = isCash
|
||||
? client_1.OrderStatus.awaiting_cash_payment
|
||||
: client_1.OrderStatus.check_in_progress;
|
||||
(0, order_transitions_1.assertTransition)(order.status, nextStatus);
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
await tx.order.update({
|
||||
where: { id },
|
||||
data: {
|
||||
settlementType: dto.settlementType,
|
||||
checkMode: isCash
|
||||
? null
|
||||
: (dto.checkMode ?? client_1.CheckRegistrationMode.full),
|
||||
cashInvoiceExpiresAt: isCash
|
||||
? (0, cash_expiry_1.computeCashInvoiceExpiry)(order.company)
|
||||
: null,
|
||||
cashReminderSentAt: null,
|
||||
status: nextStatus,
|
||||
},
|
||||
});
|
||||
await tx.orderStatusHistory.create({
|
||||
data: {
|
||||
orderId: id,
|
||||
fromStatus: order.status,
|
||||
toStatus: nextStatus,
|
||||
changedBy: 'customer',
|
||||
note: isCash
|
||||
? 'مشتری تسویه نقدی را انتخاب کرد'
|
||||
: 'مشتری تسویه چکی را انتخاب کرد',
|
||||
},
|
||||
});
|
||||
});
|
||||
return this.findMyOrder(userId, id);
|
||||
}
|
||||
async adminCreate(adminId, dto) {
|
||||
const company = await this.prisma.company.findUnique({
|
||||
where: { id: dto.companyId },
|
||||
});
|
||||
@@ -245,7 +267,7 @@ let OrdersService = class OrdersService {
|
||||
userId: ownerId,
|
||||
companyId: company.id,
|
||||
companyName: company.name,
|
||||
settlementType,
|
||||
settlementType: null,
|
||||
status: client_1.OrderStatus.awaiting_review,
|
||||
totalMeterage,
|
||||
notes: dto.notes?.trim() || null,
|
||||
@@ -338,6 +360,18 @@ let OrdersService = class OrdersService {
|
||||
if (order.status === dto.status) {
|
||||
return this.mapOrder(order, true);
|
||||
}
|
||||
if (dto.force) {
|
||||
if (!dto.reason?.trim()) {
|
||||
throw new common_1.BadRequestException('برای تغییر دستی وضعیت، ذکر دلیل الزامی است');
|
||||
}
|
||||
}
|
||||
else {
|
||||
(0, order_transitions_1.assertTransition)(order.status, dto.status);
|
||||
}
|
||||
if (dto.status === client_1.OrderStatus.awaiting_settlement &&
|
||||
(order.finalAmount ?? 0) <= 0) {
|
||||
throw new common_1.BadRequestException('ابتدا سفارش را قیمتگذاری کنید تا فاکتور قابل ارسال باشد');
|
||||
}
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
await tx.order.update({
|
||||
where: { id },
|
||||
@@ -349,7 +383,9 @@ let OrdersService = class OrdersService {
|
||||
fromStatus: order.status,
|
||||
toStatus: dto.status,
|
||||
changedBy: `admin:${adminId}`,
|
||||
note: dto.note || null,
|
||||
note: dto.force
|
||||
? `تغییر دستی وضعیت${dto.note ? ` — ${dto.note}` : ''}`
|
||||
: dto.note || null,
|
||||
reason: dto.reason || null,
|
||||
},
|
||||
});
|
||||
@@ -365,6 +401,12 @@ let OrdersService = class OrdersService {
|
||||
}
|
||||
}
|
||||
});
|
||||
const event = (0, notification_events_1.eventForStatus)(dto.status);
|
||||
if (event) {
|
||||
this.notifications.dispatchOrderEvent(id, event, {
|
||||
note: dto.reason ?? dto.note ?? null,
|
||||
});
|
||||
}
|
||||
return this.findAdminOrder(id);
|
||||
}
|
||||
async updateChecks(userId, id, dto) {
|
||||
@@ -378,8 +420,18 @@ let OrdersService = class OrdersService {
|
||||
if (!CHECK_EDITABLE_STATUSES.includes(order.status)) {
|
||||
throw new common_1.BadRequestException('در وضعیت فعلی سفارش امکان ویرایش چکها وجود ندارد');
|
||||
}
|
||||
if (!dto.checks.length) {
|
||||
throw new common_1.BadRequestException('حداقل یک چک لازم است');
|
||||
}
|
||||
const checkMode = dto.checkMode ?? order.checkMode ?? client_1.CheckRegistrationMode.full;
|
||||
const rass = (0, check_rass_1.calculateCheckRass)(dto.checks.map((c) => ({ amount: c.amount, dueDate: c.dueDate })), order.createdAt);
|
||||
const goesToReview = order.status === client_1.OrderStatus.check_in_progress ||
|
||||
order.status === client_1.OrderStatus.check_needs_fix ||
|
||||
order.status === client_1.OrderStatus.check_rejected;
|
||||
const nextStatus = goesToReview
|
||||
? client_1.OrderStatus.awaiting_check_review
|
||||
: order.status;
|
||||
const isFix = order.status !== client_1.OrderStatus.check_in_progress;
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
await tx.check.deleteMany({ where: { orderId: id } });
|
||||
await tx.check.createMany({
|
||||
@@ -394,23 +446,30 @@ let OrdersService = class OrdersService {
|
||||
checkMode,
|
||||
checkRassDays: rass.rassDays,
|
||||
checkRassDate: rass.rassDate ? new Date(rass.rassDate) : null,
|
||||
status: order.status === client_1.OrderStatus.check_needs_fix
|
||||
? client_1.OrderStatus.awaiting_check_review
|
||||
: order.status,
|
||||
status: nextStatus,
|
||||
},
|
||||
});
|
||||
if (order.status === client_1.OrderStatus.check_needs_fix) {
|
||||
if (nextStatus !== order.status) {
|
||||
await tx.orderStatusHistory.create({
|
||||
data: {
|
||||
orderId: id,
|
||||
fromStatus: order.status,
|
||||
toStatus: client_1.OrderStatus.awaiting_check_review,
|
||||
toStatus: nextStatus,
|
||||
changedBy: 'customer',
|
||||
note: 'چکها اصلاح و مجدداً ارسال شد',
|
||||
note: isFix
|
||||
? 'چکها اصلاح و مجدداً ارسال شد'
|
||||
: 'چکها برای بررسی ارسال شد',
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
if (nextStatus !== order.status) {
|
||||
this.notifications.dispatchAdmin({
|
||||
title: isFix ? 'چکهای اصلاحشده رسید' : 'چکهای سفارش ثبت شد',
|
||||
body: `مشتری ${dto.checks.length} چک برای سفارش ${order.orderNumber} ثبت کرد و منتظر بررسی است.`,
|
||||
link: `/orders/${id}`,
|
||||
});
|
||||
}
|
||||
return this.findMyOrder(userId, id);
|
||||
}
|
||||
mapCheckCreate(c, row, defaultMode) {
|
||||
@@ -467,6 +526,7 @@ let OrdersService = class OrdersService {
|
||||
}
|
||||
mapOrder(order, adminView = false) {
|
||||
const customerName = (0, name_1.joinFullName)(order.user.firstName, order.user.lastName);
|
||||
const hidePrices = !adminView && PRICE_HIDDEN_STATUSES.includes(order.status);
|
||||
const base = {
|
||||
id: order.id,
|
||||
orderNumber: order.orderNumber,
|
||||
@@ -478,12 +538,14 @@ let OrdersService = class OrdersService {
|
||||
checkMode: order.checkMode ?? undefined,
|
||||
status: order.status,
|
||||
adminStatus: (0, order_status_1.toAdminStatus)(order.status),
|
||||
allowedTransitions: adminView ? (0, order_transitions_1.allowedTransitions)(order.status) : [],
|
||||
totalMeterage: order.totalMeterage,
|
||||
meterage: order.totalMeterage,
|
||||
totalAmount: order.totalAmount,
|
||||
shippingCost: order.shippingCost,
|
||||
totalDiscount: order.totalDiscount,
|
||||
finalAmount: order.finalAmount,
|
||||
totalAmount: hidePrices ? null : order.totalAmount,
|
||||
shippingCost: hidePrices ? null : order.shippingCost,
|
||||
totalDiscount: hidePrices ? null : order.totalDiscount,
|
||||
finalAmount: hidePrices ? null : order.finalAmount,
|
||||
pricesVisible: !hidePrices,
|
||||
notes: order.notes ?? undefined,
|
||||
checkRassDays: order.checkRassDays ?? undefined,
|
||||
checkRassDate: order.checkRassDate?.toISOString(),
|
||||
@@ -503,12 +565,12 @@ let OrdersService = class OrdersService {
|
||||
color: item.color,
|
||||
requestedMeterage: item.requestedMeterage,
|
||||
confirmedMeterage: item.confirmedMeterage,
|
||||
unitPrice: item.unitPrice,
|
||||
supplyPrice: item.unitPrice,
|
||||
unitDiscount: item.unitDiscount ?? 0,
|
||||
discount: item.unitDiscount ?? 0,
|
||||
lineTotal: item.lineTotal,
|
||||
totalAmount: item.lineTotal,
|
||||
unitPrice: hidePrices ? null : item.unitPrice,
|
||||
supplyPrice: hidePrices ? null : item.unitPrice,
|
||||
unitDiscount: hidePrices ? null : (item.unitDiscount ?? 0),
|
||||
discount: hidePrices ? null : (item.unitDiscount ?? 0),
|
||||
lineTotal: hidePrices ? null : item.lineTotal,
|
||||
totalAmount: hidePrices ? null : item.lineTotal,
|
||||
notes: item.notes ?? undefined,
|
||||
})),
|
||||
checks: order.checks.map((c) => ({
|
||||
@@ -573,15 +635,13 @@ let OrdersService = class OrdersService {
|
||||
changedAt: h.changedAt.toISOString(),
|
||||
})),
|
||||
};
|
||||
if (adminView) {
|
||||
return base;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
};
|
||||
exports.OrdersService = OrdersService;
|
||||
exports.OrdersService = OrdersService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService,
|
||||
notifications_service_1.NotificationsService])
|
||||
], OrdersService);
|
||||
//# sourceMappingURL=orders.service.js.map
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
@@ -4,6 +4,7 @@ export declare class UpdateSettingsDto {
|
||||
defaultSettlementCheck?: boolean;
|
||||
defaultSettlementCash?: boolean;
|
||||
smsOrderRegistered?: boolean;
|
||||
smsPricingReady?: boolean;
|
||||
smsPaymentReminder?: boolean;
|
||||
smsCheckReview?: boolean;
|
||||
smsShippingUpdate?: boolean;
|
||||
|
||||
Vendored
+6
@@ -18,6 +18,7 @@ class UpdateSettingsDto {
|
||||
defaultSettlementCheck;
|
||||
defaultSettlementCash;
|
||||
smsOrderRegistered;
|
||||
smsPricingReady;
|
||||
smsPaymentReminder;
|
||||
smsCheckReview;
|
||||
smsShippingUpdate;
|
||||
@@ -54,6 +55,11 @@ __decorate([
|
||||
(0, class_validator_1.IsBoolean)(),
|
||||
__metadata("design:type", Boolean)
|
||||
], UpdateSettingsDto.prototype, "smsOrderRegistered", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsBoolean)(),
|
||||
__metadata("design:type", Boolean)
|
||||
], UpdateSettingsDto.prototype, "smsPricingReady", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsBoolean)(),
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"settings.dto.js","sourceRoot":"","sources":["../../../src/settings/dto/settings.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA8E;AAC9E,yDAAyC;AAEzC,MAAa,i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heck: boolean;
|
||||
defaultSettlementCash: boolean;
|
||||
smsOrderRegistered: boolean;
|
||||
smsPricingReady: boolean;
|
||||
smsPaymentReminder: boolean;
|
||||
smsCheckReview: boolean;
|
||||
smsShippingUpdate: boolean;
|
||||
@@ -24,6 +25,7 @@ export declare class SettingsController {
|
||||
defaultSettlementCheck: boolean;
|
||||
defaultSettlementCash: boolean;
|
||||
smsOrderRegistered: boolean;
|
||||
smsPricingReady: boolean;
|
||||
smsPaymentReminder: boolean;
|
||||
smsCheckReview: boolean;
|
||||
smsShippingUpdate: boolean;
|
||||
|
||||
Vendored
+2
@@ -10,6 +10,7 @@ export declare class SettingsService {
|
||||
defaultSettlementCheck: boolean;
|
||||
defaultSettlementCash: boolean;
|
||||
smsOrderRegistered: boolean;
|
||||
smsPricingReady: boolean;
|
||||
smsPaymentReminder: boolean;
|
||||
smsCheckReview: boolean;
|
||||
smsShippingUpdate: boolean;
|
||||
@@ -24,6 +25,7 @@ export declare class SettingsService {
|
||||
defaultSettlementCheck: boolean;
|
||||
defaultSettlementCash: boolean;
|
||||
smsOrderRegistered: boolean;
|
||||
smsPricingReady: boolean;
|
||||
smsPaymentReminder: boolean;
|
||||
smsCheckReview: boolean;
|
||||
smsShippingUpdate: boolean;
|
||||
|
||||
Vendored
+2
@@ -31,6 +31,7 @@ let SettingsService = class SettingsService {
|
||||
defaultSettlementCheck: dto.defaultSettlementCheck,
|
||||
defaultSettlementCash: dto.defaultSettlementCash,
|
||||
smsOrderRegistered: dto.smsOrderRegistered,
|
||||
smsPricingReady: dto.smsPricingReady,
|
||||
smsPaymentReminder: dto.smsPaymentReminder,
|
||||
smsCheckReview: dto.smsCheckReview,
|
||||
smsShippingUpdate: dto.smsShippingUpdate,
|
||||
@@ -59,6 +60,7 @@ let SettingsService = class SettingsService {
|
||||
defaultSettlementCheck: settings.defaultSettlementCheck,
|
||||
defaultSettlementCash: settings.defaultSettlementCash,
|
||||
smsOrderRegistered: settings.smsOrderRegistered,
|
||||
smsPricingReady: settings.smsPricingReady,
|
||||
smsPaymentReminder: settings.smsPaymentReminder,
|
||||
smsCheckReview: settings.smsCheckReview,
|
||||
smsShippingUpdate: settings.smsShippingUpdate,
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"settings.service.js","sourceRoot":"","sources":["../../src/settings/settings.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6DAAyD;AAIlD,IAAM,eAAe,GAArB,MAAM,eAAe;IACG;IAA7B,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAEtD,KAAK,CAAC,GAAG;QACP,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAsB;QACjC,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC;YACvD,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE;YACxB,IAAI,EAAE;gBACJ,qBAAqB,EAAE,GAAG,CAAC,qBAAqB;gBAChD,wBAAwB,EAAE,GAAG,CAAC,wBAAwB;gBACtD,sBAAsB,EAAE,GAAG,CAAC,sBAAsB;gBAClD,qBAAqB,EAAE,GAAG,CAAC,qBAAqB;gBAChD,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;gBAC1C,kBAAkB,EAAE,GAAG,CAAC,kBAAkB;gBAC1C,cAAc,EAAE,GAAG,CAAC,cAAc;gBAClC,iBAAiB,EAAE,GAAG,CAAC,iBAAiB;gBACxC,YAAY,EACV,GAAG,CAAC,YAAY,KAAK,SAAS;oBAC5B,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,IAAI;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IAC5B,CAAC;IAEO,KAAK,CAAC,cAAc;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC;YACvC,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE;YACxB,MAAM,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE;YACzB,MAAM,EAAE,EAAE;SACX,CAAC,CAAC;IACL,CAAC;IAEO,GAAG,CAAC,QAcX;QACC,OAAO;YACL,EAAE,EAAE,QAAQ,CAAC,EAAE;YACf,qBAAqB,EAAE,QAAQ,CAAC,qBAAqB;YACrD,wBAAwB,EAAE,QAAQ,CAAC,wBAAwB;YAC3D,sBAAsB,EAAE,QAAQ,CAAC,sBAAsB;YACvD,qBAAqB,EAAE,QAAQ,CAAC,qBAAqB;YACrD,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;YAC/C,eAAe,EAAE,QAAQ,CAAC,eAAe;YACzC,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;YAC/C,cAAc,EAAE,QAAQ,CAAC,cAAc;YACvC,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB;YAC7C,YAAY,EAAE,QAAQ,CAAC,YAAY;YACnC,YAAY,EAAE,QAAQ,CAAC,YAAY;YACnC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE;SAC5C,CAAC;IACJ,CAAC;CACF,CAAA;AA1EY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;qCAE0B,8BAAa;GADvC,eAAe,CA0E3B"}
|
||||
Vendored
+2
@@ -10,11 +10,13 @@ exports.ShipmentsModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const shipments_controller_1 = require("./shipments.controller");
|
||||
const shipments_service_1 = require("./shipments.service");
|
||||
const notifications_module_1 = require("../notifications/notifications.module");
|
||||
let ShipmentsModule = class ShipmentsModule {
|
||||
};
|
||||
exports.ShipmentsModule = ShipmentsModule;
|
||||
exports.ShipmentsModule = ShipmentsModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [notifications_module_1.NotificationsModule],
|
||||
controllers: [shipments_controller_1.ShipmentsController],
|
||||
providers: [shipments_service_1.ShipmentsService],
|
||||
exports: [shipments_service_1.ShipmentsService],
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"shipments.module.js","sourceRoot":"","sources":["../../src/shipments/shipments.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iEAA6D;AAC7D,2DAAuD;AAOhD,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,0CAAe;0BAAf,eAAe;IAL3B,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,0CAAmB,CAAC;QAClC,SAAS,EAAE,CAAC,oCAAgB,CAAC;QAC7B,OAAO,EAAE,CAAC,oCAAgB,CAAC;KAC5B,CAAC;GACW,eAAe,CAAG"}
|
||||
{"version":3,"file":"shipments.module.js","sourceRoot":"","sources":["../../src/shipments/shipments.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iEAA6D;AAC7D,2DAAuD;AACvD,gFAA4E;AAQrE,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,0CAAe;0BAAf,eAAe;IAN3B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0CAAmB,CAAC;QAC9B,WAAW,EAAE,CAAC,0CAAmB,CAAC;QAClC,SAAS,EAAE,CAAC,oCAAgB,CAAC;QAC7B,OAAO,EAAE,CAAC,oCAAgB,CAAC;KAC5B,CAAC;GACW,eAAe,CAAG"}
|
||||
+4
-1
@@ -1,9 +1,11 @@
|
||||
import { ShipmentStatus } from '@prisma/client';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { AdvanceShipmentStatusDto, CreateShipmentDto, UpdateShipmentDto } from './dto/shipment.dto';
|
||||
import { NotificationsService } from '../notifications/notifications.service';
|
||||
export declare class ShipmentsService {
|
||||
private readonly prisma;
|
||||
constructor(prisma: PrismaService);
|
||||
private readonly notifications;
|
||||
constructor(prisma: PrismaService, notifications: NotificationsService);
|
||||
findAll(status?: ShipmentStatus): Promise<{
|
||||
id: string;
|
||||
orderId: string;
|
||||
@@ -74,6 +76,7 @@ export declare class ShipmentsService {
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}>;
|
||||
private notifyOrderStatus;
|
||||
private ensure;
|
||||
private map;
|
||||
}
|
||||
|
||||
Vendored
+21
-2
@@ -14,6 +14,8 @@ const common_1 = require("@nestjs/common");
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_service_1 = require("../prisma/prisma.service");
|
||||
const name_1 = require("../common/utils/name");
|
||||
const notifications_service_1 = require("../notifications/notifications.service");
|
||||
const notification_events_1 = require("../notifications/notification-events");
|
||||
const STATUS_FLOW = [
|
||||
client_1.ShipmentStatus.preparing,
|
||||
client_1.ShipmentStatus.ready,
|
||||
@@ -28,8 +30,10 @@ const SHIPMENT_TO_ORDER = {
|
||||
};
|
||||
let ShipmentsService = class ShipmentsService {
|
||||
prisma;
|
||||
constructor(prisma) {
|
||||
notifications;
|
||||
constructor(prisma, notifications) {
|
||||
this.prisma = prisma;
|
||||
this.notifications = notifications;
|
||||
}
|
||||
async findAll(status) {
|
||||
const shipments = await this.prisma.shipment.findMany({
|
||||
@@ -92,6 +96,10 @@ let ShipmentsService = class ShipmentsService {
|
||||
}
|
||||
return created;
|
||||
});
|
||||
this.notifyOrderStatus(order.id, SHIPMENT_TO_ORDER[status], {
|
||||
carrier: shipment.carrier,
|
||||
trackingNumber: shipment.trackingNumber,
|
||||
});
|
||||
return this.map(shipment);
|
||||
}
|
||||
async update(id, dto) {
|
||||
@@ -160,8 +168,18 @@ let ShipmentsService = class ShipmentsService {
|
||||
}
|
||||
return result;
|
||||
});
|
||||
this.notifyOrderStatus(shipment.orderId, SHIPMENT_TO_ORDER[nextStatus], {
|
||||
carrier: updated.carrier,
|
||||
trackingNumber: updated.trackingNumber,
|
||||
});
|
||||
return this.map(updated);
|
||||
}
|
||||
notifyOrderStatus(orderId, status, context) {
|
||||
const event = (0, notification_events_1.eventForStatus)(status);
|
||||
if (event) {
|
||||
this.notifications.dispatchOrderEvent(orderId, event, context);
|
||||
}
|
||||
}
|
||||
async ensure(id) {
|
||||
const shipment = await this.prisma.shipment.findUnique({ where: { id } });
|
||||
if (!shipment)
|
||||
@@ -188,6 +206,7 @@ let ShipmentsService = class ShipmentsService {
|
||||
exports.ShipmentsService = ShipmentsService;
|
||||
exports.ShipmentsService = ShipmentsService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService,
|
||||
notifications_service_1.NotificationsService])
|
||||
], ShipmentsService);
|
||||
//# sourceMappingURL=shipments.service.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user