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:
+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
Reference in New Issue
Block a user