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:
+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;AA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;
|
||||
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.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,qDAAiD;AACjD,0EAAgE;AAChE,wFAA0E;AAE1E,+CAMyB;AAGlB,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACN;IAA7B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAI7D,QAAQ,CAAgB,IAAmB;QACzC,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC;IAID,OAAO,CAAgB,IAAmB,EAAe,EAAU;QACjE,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAID,MAAM,CAAgB,IAAmB,EAAU,GAAmB;QACpE,OAAO,IAAI,C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,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
Reference in New Issue
Block a user