Deploy via committed dist: local Nest build, server runs with .env
Build on the developer machine without Docker, commit dist/, and run on the server with Dockerfile.dist plus compose env_file. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Vendored
+62
@@ -0,0 +1,62 @@
|
||||
import { CheckRegistrationMode, OrderStatus, SettlementType } from '@prisma/client';
|
||||
export declare class SubmitOrderItemDto {
|
||||
productId: string;
|
||||
meterage: number;
|
||||
notes?: string;
|
||||
}
|
||||
export declare class SubmitOrderCheckDto {
|
||||
amount: number;
|
||||
dueDate: string;
|
||||
sayadId?: string;
|
||||
checkNumber?: string;
|
||||
ownerNationalId?: string;
|
||||
ownerFirstName?: string;
|
||||
ownerLastName?: string;
|
||||
bankName?: string;
|
||||
branchName?: string;
|
||||
frontImage?: string;
|
||||
backImage?: string;
|
||||
notes?: string;
|
||||
mode?: CheckRegistrationMode;
|
||||
}
|
||||
export declare class SubmitOrderDto {
|
||||
companyId: string;
|
||||
settlementType: SettlementType;
|
||||
checkMode?: CheckRegistrationMode;
|
||||
notes?: string;
|
||||
items: SubmitOrderItemDto[];
|
||||
checks?: SubmitOrderCheckDto[];
|
||||
}
|
||||
export declare class AdminCreateOrderDto {
|
||||
userId?: string;
|
||||
customerPhone?: string;
|
||||
customerName?: string;
|
||||
companyId: string;
|
||||
settlementType?: SettlementType;
|
||||
settlementMethod?: SettlementType;
|
||||
meterage?: number;
|
||||
notes?: string;
|
||||
items?: SubmitOrderItemDto[];
|
||||
}
|
||||
export declare class OrderItemPricingDto {
|
||||
id: string;
|
||||
confirmedMeterage?: number;
|
||||
unitPrice?: number;
|
||||
supplyPrice?: number;
|
||||
unitDiscount?: number;
|
||||
}
|
||||
export declare class UpdateOrderPricingDto {
|
||||
items: OrderItemPricingDto[];
|
||||
shippingCost?: number;
|
||||
totalDiscount?: number;
|
||||
note?: string;
|
||||
}
|
||||
export declare class UpdateOrderStatusDto {
|
||||
status: OrderStatus;
|
||||
note?: string;
|
||||
reason?: string;
|
||||
}
|
||||
export declare class UpdateOrderChecksDto {
|
||||
checks: SubmitOrderCheckDto[];
|
||||
checkMode?: CheckRegistrationMode;
|
||||
}
|
||||
Vendored
+327
@@ -0,0 +1,327 @@
|
||||
"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);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UpdateOrderChecksDto = exports.UpdateOrderStatusDto = exports.UpdateOrderPricingDto = exports.OrderItemPricingDto = exports.AdminCreateOrderDto = 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");
|
||||
class SubmitOrderItemDto {
|
||||
productId;
|
||||
meterage;
|
||||
notes;
|
||||
}
|
||||
exports.SubmitOrderItemDto = SubmitOrderItemDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderItemDto.prototype, "productId", void 0);
|
||||
__decorate([
|
||||
(0, class_transformer_1.Type)(() => Number),
|
||||
(0, class_validator_1.IsNumber)(),
|
||||
(0, class_validator_1.Min)(0.001),
|
||||
__metadata("design:type", Number)
|
||||
], SubmitOrderItemDto.prototype, "meterage", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderItemDto.prototype, "notes", void 0);
|
||||
class SubmitOrderCheckDto {
|
||||
amount;
|
||||
dueDate;
|
||||
sayadId;
|
||||
checkNumber;
|
||||
ownerNationalId;
|
||||
ownerFirstName;
|
||||
ownerLastName;
|
||||
bankName;
|
||||
branchName;
|
||||
frontImage;
|
||||
backImage;
|
||||
notes;
|
||||
mode;
|
||||
}
|
||||
exports.SubmitOrderCheckDto = SubmitOrderCheckDto;
|
||||
__decorate([
|
||||
(0, class_transformer_1.Type)(() => Number),
|
||||
(0, class_validator_1.IsNumber)(),
|
||||
(0, class_validator_1.Min)(1),
|
||||
__metadata("design:type", Number)
|
||||
], SubmitOrderCheckDto.prototype, "amount", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsDateString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "dueDate", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "sayadId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "checkNumber", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "ownerNationalId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "ownerFirstName", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "ownerLastName", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "bankName", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "branchName", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "frontImage", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "backImage", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "notes", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsEnum)(client_1.CheckRegistrationMode),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderCheckDto.prototype, "mode", void 0);
|
||||
class SubmitOrderDto {
|
||||
companyId;
|
||||
settlementType;
|
||||
checkMode;
|
||||
notes;
|
||||
items;
|
||||
checks;
|
||||
}
|
||||
exports.SubmitOrderDto = SubmitOrderDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderDto.prototype, "companyId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsEnum)(client_1.SettlementType),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderDto.prototype, "settlementType", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsEnum)(client_1.CheckRegistrationMode),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderDto.prototype, "checkMode", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], SubmitOrderDto.prototype, "notes", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsArray)(),
|
||||
(0, class_validator_1.ArrayMinSize)(1),
|
||||
(0, class_validator_1.ValidateNested)({ each: true }),
|
||||
(0, class_transformer_1.Type)(() => SubmitOrderItemDto),
|
||||
__metadata("design:type", Array)
|
||||
], SubmitOrderDto.prototype, "items", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsArray)(),
|
||||
(0, class_validator_1.ValidateNested)({ each: true }),
|
||||
(0, class_transformer_1.Type)(() => SubmitOrderCheckDto),
|
||||
__metadata("design:type", Array)
|
||||
], SubmitOrderDto.prototype, "checks", void 0);
|
||||
class AdminCreateOrderDto {
|
||||
userId;
|
||||
customerPhone;
|
||||
customerName;
|
||||
companyId;
|
||||
settlementType;
|
||||
settlementMethod;
|
||||
meterage;
|
||||
notes;
|
||||
items;
|
||||
}
|
||||
exports.AdminCreateOrderDto = AdminCreateOrderDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], AdminCreateOrderDto.prototype, "userId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], AdminCreateOrderDto.prototype, "customerPhone", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], AdminCreateOrderDto.prototype, "customerName", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], AdminCreateOrderDto.prototype, "companyId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsEnum)(client_1.SettlementType),
|
||||
__metadata("design:type", String)
|
||||
], AdminCreateOrderDto.prototype, "settlementType", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsEnum)(client_1.SettlementType),
|
||||
__metadata("design:type", String)
|
||||
], AdminCreateOrderDto.prototype, "settlementMethod", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_transformer_1.Type)(() => Number),
|
||||
(0, class_validator_1.IsNumber)(),
|
||||
(0, class_validator_1.Min)(0),
|
||||
__metadata("design:type", Number)
|
||||
], AdminCreateOrderDto.prototype, "meterage", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], AdminCreateOrderDto.prototype, "notes", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsArray)(),
|
||||
(0, class_validator_1.ValidateNested)({ each: true }),
|
||||
(0, class_transformer_1.Type)(() => SubmitOrderItemDto),
|
||||
__metadata("design:type", Array)
|
||||
], AdminCreateOrderDto.prototype, "items", void 0);
|
||||
class OrderItemPricingDto {
|
||||
id;
|
||||
confirmedMeterage;
|
||||
unitPrice;
|
||||
supplyPrice;
|
||||
unitDiscount;
|
||||
}
|
||||
exports.OrderItemPricingDto = OrderItemPricingDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], OrderItemPricingDto.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_transformer_1.Type)(() => Number),
|
||||
(0, class_validator_1.IsNumber)(),
|
||||
(0, class_validator_1.Min)(0),
|
||||
__metadata("design:type", Number)
|
||||
], OrderItemPricingDto.prototype, "confirmedMeterage", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_transformer_1.Type)(() => Number),
|
||||
(0, class_validator_1.IsNumber)(),
|
||||
(0, class_validator_1.Min)(0),
|
||||
__metadata("design:type", Number)
|
||||
], OrderItemPricingDto.prototype, "unitPrice", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_transformer_1.Type)(() => Number),
|
||||
(0, class_validator_1.IsNumber)(),
|
||||
(0, class_validator_1.Min)(0),
|
||||
__metadata("design:type", Number)
|
||||
], OrderItemPricingDto.prototype, "supplyPrice", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_transformer_1.Type)(() => Number),
|
||||
(0, class_validator_1.IsNumber)(),
|
||||
(0, class_validator_1.Min)(0),
|
||||
__metadata("design:type", Number)
|
||||
], OrderItemPricingDto.prototype, "unitDiscount", void 0);
|
||||
class UpdateOrderPricingDto {
|
||||
items;
|
||||
shippingCost;
|
||||
totalDiscount;
|
||||
note;
|
||||
}
|
||||
exports.UpdateOrderPricingDto = UpdateOrderPricingDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsArray)(),
|
||||
(0, class_validator_1.ValidateNested)({ each: true }),
|
||||
(0, class_transformer_1.Type)(() => OrderItemPricingDto),
|
||||
__metadata("design:type", Array)
|
||||
], UpdateOrderPricingDto.prototype, "items", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_transformer_1.Type)(() => Number),
|
||||
(0, class_validator_1.IsNumber)(),
|
||||
(0, class_validator_1.Min)(0),
|
||||
__metadata("design:type", Number)
|
||||
], UpdateOrderPricingDto.prototype, "shippingCost", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_transformer_1.Type)(() => Number),
|
||||
(0, class_validator_1.IsNumber)(),
|
||||
(0, class_validator_1.Min)(0),
|
||||
__metadata("design:type", Number)
|
||||
], UpdateOrderPricingDto.prototype, "totalDiscount", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], UpdateOrderPricingDto.prototype, "note", void 0);
|
||||
class UpdateOrderStatusDto {
|
||||
status;
|
||||
note;
|
||||
reason;
|
||||
}
|
||||
exports.UpdateOrderStatusDto = UpdateOrderStatusDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsEnum)(client_1.OrderStatus),
|
||||
__metadata("design:type", String)
|
||||
], UpdateOrderStatusDto.prototype, "status", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], UpdateOrderStatusDto.prototype, "note", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], UpdateOrderStatusDto.prototype, "reason", void 0);
|
||||
class UpdateOrderChecksDto {
|
||||
checks;
|
||||
checkMode;
|
||||
}
|
||||
exports.UpdateOrderChecksDto = UpdateOrderChecksDto;
|
||||
__decorate([
|
||||
(0, class_validator_1.IsArray)(),
|
||||
(0, class_validator_1.ValidateNested)({ each: true }),
|
||||
(0, class_transformer_1.Type)(() => SubmitOrderCheckDto),
|
||||
__metadata("design:type", Array)
|
||||
], UpdateOrderChecksDto.prototype, "checks", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsEnum)(client_1.CheckRegistrationMode),
|
||||
__metadata("design:type", String)
|
||||
], UpdateOrderChecksDto.prototype, "checkMode", void 0);
|
||||
//# sourceMappingURL=order.dto.js.map
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"order.dto.js","sourceRoot":"","sources":["../../../src/orders/dto/order.dto.ts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AIrB,IAAI,CAAU;IAId,MAAM,CAAU;CACjB;AAXD,oDAWC;AATC;IADC,IAAA,wBAAM,EAAC,oBAAW,CAAC;;oDACC;AAIrB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;kDACG;AAId;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;oDACK;AAGlB,MAAa,oBAAoB;IAI/B,MAAM,CAAyB;IAI/B,SAAS,CAAyB;CACnC;AATD,oDASC;AALC;IAHC,IAAA,yBAAO,GAAE;IACT,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC;;oDACD;AAI/B;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,8BAAqB,CAAC;;uDACI"}
|
||||
Vendored
+920
@@ -0,0 +1,920 @@
|
||||
import { OrdersService } from './orders.service';
|
||||
import type { AuthPrincipal } from '../common/decorators/current-user.decorator';
|
||||
import { AdminCreateOrderDto, SubmitOrderDto, UpdateOrderChecksDto, UpdateOrderPricingDto, UpdateOrderStatusDto } from './dto/order.dto';
|
||||
export declare class CustomerOrdersController {
|
||||
private readonly ordersService;
|
||||
constructor(ordersService: OrdersService);
|
||||
findMine(user: AuthPrincipal): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
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;
|
||||
discount: number;
|
||||
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;
|
||||
}[];
|
||||
}[]>;
|
||||
findOne(user: AuthPrincipal, id: string): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
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;
|
||||
discount: number;
|
||||
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;
|
||||
}[];
|
||||
}>;
|
||||
submit(user: AuthPrincipal, dto: SubmitOrderDto): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
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;
|
||||
discount: number;
|
||||
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;
|
||||
}[];
|
||||
}>;
|
||||
updateChecks(user: AuthPrincipal, id: string, dto: UpdateOrderChecksDto): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
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;
|
||||
discount: number;
|
||||
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;
|
||||
}[];
|
||||
}>;
|
||||
}
|
||||
export declare class AdminOrdersController {
|
||||
private readonly ordersService;
|
||||
constructor(ordersService: OrdersService);
|
||||
findAll(status?: string, q?: string): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
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;
|
||||
discount: number;
|
||||
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;
|
||||
}[];
|
||||
}[]>;
|
||||
findOne(id: string): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
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;
|
||||
discount: number;
|
||||
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;
|
||||
}[];
|
||||
}>;
|
||||
create(user: AuthPrincipal, dto: AdminCreateOrderDto): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
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;
|
||||
discount: number;
|
||||
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;
|
||||
}[];
|
||||
}>;
|
||||
updatePricing(user: AuthPrincipal, id: string, dto: UpdateOrderPricingDto): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
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;
|
||||
discount: number;
|
||||
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;
|
||||
}[];
|
||||
}>;
|
||||
updateStatus(user: AuthPrincipal, id: string, dto: UpdateOrderStatusDto): Promise<{
|
||||
id: string;
|
||||
orderNumber: string;
|
||||
userId: string;
|
||||
companyId: string;
|
||||
companyName: string;
|
||||
settlementType: import("@prisma/client").$Enums.SettlementType;
|
||||
settlementMethod: import("@prisma/client").$Enums.SettlementType;
|
||||
checkMode: import("@prisma/client").$Enums.CheckRegistrationMode | undefined;
|
||||
status: import("@prisma/client").$Enums.OrderStatus;
|
||||
adminStatus: string;
|
||||
totalMeterage: number;
|
||||
meterage: number;
|
||||
totalAmount: number | null;
|
||||
shippingCost: number | null;
|
||||
totalDiscount: number | null;
|
||||
finalAmount: number | null;
|
||||
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;
|
||||
discount: number;
|
||||
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;
|
||||
}[];
|
||||
}>;
|
||||
}
|
||||
Vendored
+148
@@ -0,0 +1,148 @@
|
||||
"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.AdminOrdersController = exports.CustomerOrdersController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const orders_service_1 = require("./orders.service");
|
||||
const auth_decorators_1 = require("../common/decorators/auth.decorators");
|
||||
const current_user_decorator_1 = require("../common/decorators/current-user.decorator");
|
||||
const order_dto_1 = require("./dto/order.dto");
|
||||
let CustomerOrdersController = class CustomerOrdersController {
|
||||
ordersService;
|
||||
constructor(ordersService) {
|
||||
this.ordersService = ordersService;
|
||||
}
|
||||
findMine(user) {
|
||||
return this.ordersService.findMyOrders(user.id);
|
||||
}
|
||||
findOne(user, id) {
|
||||
return this.ordersService.findMyOrder(user.id, id);
|
||||
}
|
||||
submit(user, dto) {
|
||||
return this.ordersService.submitOrder(user.id, dto);
|
||||
}
|
||||
updateChecks(user, id, dto) {
|
||||
return this.ordersService.updateChecks(user.id, id, dto);
|
||||
}
|
||||
};
|
||||
exports.CustomerOrdersController = CustomerOrdersController;
|
||||
__decorate([
|
||||
(0, auth_decorators_1.AuthType)('customer'),
|
||||
(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)
|
||||
], CustomerOrdersController.prototype, "findMine", null);
|
||||
__decorate([
|
||||
(0, auth_decorators_1.AuthType)('customer'),
|
||||
(0, common_1.Get)(':id'),
|
||||
__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)
|
||||
], CustomerOrdersController.prototype, "findOne", null);
|
||||
__decorate([
|
||||
(0, auth_decorators_1.AuthType)('customer'),
|
||||
(0, common_1.Post)(),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__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.Patch)(':id/checks'),
|
||||
__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.UpdateOrderChecksDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], CustomerOrdersController.prototype, "updateChecks", null);
|
||||
exports.CustomerOrdersController = CustomerOrdersController = __decorate([
|
||||
(0, common_1.Controller)('orders'),
|
||||
__metadata("design:paramtypes", [orders_service_1.OrdersService])
|
||||
], CustomerOrdersController);
|
||||
let AdminOrdersController = class AdminOrdersController {
|
||||
ordersService;
|
||||
constructor(ordersService) {
|
||||
this.ordersService = ordersService;
|
||||
}
|
||||
findAll(status, q) {
|
||||
return this.ordersService.findAdminOrders({ status, q });
|
||||
}
|
||||
findOne(id) {
|
||||
return this.ordersService.findAdminOrder(id);
|
||||
}
|
||||
create(user, dto) {
|
||||
return this.ordersService.adminCreate(user.id, dto);
|
||||
}
|
||||
updatePricing(user, id, dto) {
|
||||
return this.ordersService.updatePricing(id, user.id, dto);
|
||||
}
|
||||
updateStatus(user, id, dto) {
|
||||
return this.ordersService.updateStatus(id, user.id, dto);
|
||||
}
|
||||
};
|
||||
exports.AdminOrdersController = AdminOrdersController;
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__param(0, (0, common_1.Query)('status')),
|
||||
__param(1, (0, common_1.Query)('q')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminOrdersController.prototype, "findAll", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(':id'),
|
||||
__param(0, (0, common_1.Param)('id')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminOrdersController.prototype, "findOne", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)(),
|
||||
__param(0, (0, current_user_decorator_1.CurrentUser)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, order_dto_1.AdminCreateOrderDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminOrdersController.prototype, "create", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)(':id/pricing'),
|
||||
__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.UpdateOrderPricingDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminOrdersController.prototype, "updatePricing", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)(':id/status'),
|
||||
__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.UpdateOrderStatusDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AdminOrdersController.prototype, "updateStatus", null);
|
||||
exports.AdminOrdersController = AdminOrdersController = __decorate([
|
||||
(0, common_1.Controller)('admin/orders'),
|
||||
(0, auth_decorators_1.AuthType)('admin'),
|
||||
__metadata("design:paramtypes", [orders_service_1.OrdersService])
|
||||
], AdminOrdersController);
|
||||
//# sourceMappingURL=orders.controller.js.map
|
||||
Vendored
+1
@@ -0,0 +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;QACz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,WAAA,IAAA,oCAAW,GAAE,CAAA;IACb,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAM,+BAAmB;;mDAGjC;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;gCArCU,qBAAqB;IAFjC,IAAA,mBAAU,EAAC,cAAc,CAAC;IAC1B,IAAA,0BAAQ,EAAC,OAAO,CAAC;qCAE4B,8BAAa;GAD9C,qBAAqB,CAsCjC"}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export declare class OrdersModule {
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
"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.OrdersModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const orders_controller_1 = require("./orders.controller");
|
||||
const orders_service_1 = require("./orders.service");
|
||||
let OrdersModule = class OrdersModule {
|
||||
};
|
||||
exports.OrdersModule = OrdersModule;
|
||||
exports.OrdersModule = OrdersModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
controllers: [orders_controller_1.CustomerOrdersController, orders_controller_1.AdminOrdersController],
|
||||
providers: [orders_service_1.OrdersService],
|
||||
exports: [orders_service_1.OrdersService],
|
||||
})
|
||||
], OrdersModule);
|
||||
//# sourceMappingURL=orders.module.js.map
|
||||
Vendored
+1
@@ -0,0 +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"}
|
||||
Vendored
+1044
File diff suppressed because it is too large
Load Diff
Vendored
+549
@@ -0,0 +1,549 @@
|
||||
"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);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.OrdersService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_service_1 = require("../prisma/prisma.service");
|
||||
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 name_1 = require("../common/utils/name");
|
||||
const phone_1 = require("../common/utils/phone");
|
||||
const orderInclude = {
|
||||
items: true,
|
||||
checks: { orderBy: { row: 'asc' } },
|
||||
cashReceipt: true,
|
||||
statusHistory: { orderBy: { changedAt: 'asc' } },
|
||||
shipment: true,
|
||||
user: true,
|
||||
company: true,
|
||||
};
|
||||
let OrdersService = class OrdersService {
|
||||
prisma;
|
||||
constructor(prisma) {
|
||||
this.prisma = prisma;
|
||||
}
|
||||
async findMyOrders(userId) {
|
||||
const orders = await this.prisma.order.findMany({
|
||||
where: { userId },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: orderInclude,
|
||||
});
|
||||
return orders.map((o) => this.mapOrder(o));
|
||||
}
|
||||
async findMyOrder(userId, id) {
|
||||
const order = await this.getOrder(id);
|
||||
if (order.userId !== userId) {
|
||||
throw new common_1.ForbiddenException('دسترسی به این سفارش مجاز نیست');
|
||||
}
|
||||
return this.mapOrder(order);
|
||||
}
|
||||
async findAdminOrders(filters) {
|
||||
const statuses = (0, order_status_1.resolveAdminStatusFilter)(filters.status);
|
||||
const q = filters.q?.trim();
|
||||
const orders = await this.prisma.order.findMany({
|
||||
where: {
|
||||
...(statuses ? { status: { in: statuses } } : {}),
|
||||
...(q
|
||||
? {
|
||||
OR: [
|
||||
{ orderNumber: { contains: q, mode: 'insensitive' } },
|
||||
{ companyName: { contains: q, mode: 'insensitive' } },
|
||||
{
|
||||
user: {
|
||||
OR: [
|
||||
{ firstName: { contains: q, mode: 'insensitive' } },
|
||||
{ lastName: { contains: q, mode: 'insensitive' } },
|
||||
{ phone: { contains: (0, phone_1.toEnglishDigits)(q) } },
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
orderBy: { createdAt: 'desc' },
|
||||
include: orderInclude,
|
||||
});
|
||||
return orders.map((o) => this.mapOrder(o, true));
|
||||
}
|
||||
async findAdminOrder(id) {
|
||||
const order = await this.getOrder(id);
|
||||
return this.mapOrder(order, true);
|
||||
}
|
||||
async submitOrder(userId, dto) {
|
||||
const company = await this.prisma.company.findUnique({
|
||||
where: { id: dto.companyId },
|
||||
});
|
||||
if (!company || !company.isActive) {
|
||||
throw new common_1.NotFoundException('شرکت یافت نشد یا غیرفعال است');
|
||||
}
|
||||
const productIds = dto.items.map((i) => i.productId);
|
||||
const products = await this.prisma.product.findMany({
|
||||
where: { id: { in: productIds }, companyId: company.id, isActive: true },
|
||||
include: { catalog: true },
|
||||
});
|
||||
if (products.length !== productIds.length) {
|
||||
throw new common_1.BadRequestException('یک یا چند محصول نامعتبر است');
|
||||
}
|
||||
const productMap = new Map(products.map((p) => [p.id, p]));
|
||||
let totalMeterage = 0;
|
||||
const itemsData = dto.items.map((item) => {
|
||||
const product = productMap.get(item.productId);
|
||||
if (item.meterage < product.minMeterage) {
|
||||
throw new common_1.BadRequestException(`حداقل متراژ برای ${product.name} برابر ${product.minMeterage} است`);
|
||||
}
|
||||
const rem = Math.round((item.meterage / product.orderMultiplier) * 1000) / 1000;
|
||||
if (Math.abs(rem - Math.round(rem)) > 1e-6) {
|
||||
throw new common_1.BadRequestException(`متراژ ${product.name} باید مضرب ${product.orderMultiplier} باشد`);
|
||||
}
|
||||
totalMeterage += item.meterage;
|
||||
return {
|
||||
productId: product.id,
|
||||
catalogCode: product.catalog.code,
|
||||
productName: product.name,
|
||||
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} متر است`);
|
||||
}
|
||||
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 orderNumber = await this.nextOrderNumber();
|
||||
const order = await this.prisma.$transaction(async (tx) => {
|
||||
const created = await tx.order.create({
|
||||
data: {
|
||||
orderNumber,
|
||||
userId,
|
||||
companyId: company.id,
|
||||
companyName: company.name,
|
||||
settlementType,
|
||||
checkMode,
|
||||
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: 'ارسال برای بررسی مدیریت',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
include: orderInclude,
|
||||
});
|
||||
const cart = await tx.cart.findFirst({ where: { userId } });
|
||||
if (cart) {
|
||||
await tx.cartItem.deleteMany({
|
||||
where: { cartId: cart.id, companyId: company.id },
|
||||
});
|
||||
}
|
||||
return created;
|
||||
});
|
||||
return this.mapOrder(order);
|
||||
}
|
||||
async adminCreate(adminId, dto) {
|
||||
const settlementType = dto.settlementType ?? dto.settlementMethod;
|
||||
if (!settlementType) {
|
||||
throw new common_1.BadRequestException('نوع تسویه الزامی است');
|
||||
}
|
||||
const company = await this.prisma.company.findUnique({
|
||||
where: { id: dto.companyId },
|
||||
});
|
||||
if (!company)
|
||||
throw new common_1.NotFoundException('شرکت یافت نشد');
|
||||
let userId = dto.userId;
|
||||
if (!userId && dto.customerPhone) {
|
||||
const phone = (0, phone_1.normalizePhone)((0, phone_1.toEnglishDigits)(dto.customerPhone));
|
||||
if (!(0, phone_1.isValidPhone)(phone)) {
|
||||
throw new common_1.BadRequestException('شماره موبایل نامعتبر است');
|
||||
}
|
||||
let customer = await this.prisma.customer.findUnique({ where: { phone } });
|
||||
if (!customer) {
|
||||
const names = (0, name_1.splitFullName)(dto.customerName || 'مشتری جدید');
|
||||
customer = await this.prisma.customer.create({
|
||||
data: {
|
||||
phone,
|
||||
firstName: names.firstName,
|
||||
lastName: names.lastName || 'جدید',
|
||||
},
|
||||
});
|
||||
}
|
||||
userId = customer.id;
|
||||
}
|
||||
if (!userId) {
|
||||
throw new common_1.BadRequestException('شناسه یا شماره مشتری الزامی است');
|
||||
}
|
||||
const orderNumber = await this.nextOrderNumber();
|
||||
const totalMeterage = dto.meterage ?? 0;
|
||||
const order = await this.prisma.order.create({
|
||||
data: {
|
||||
orderNumber,
|
||||
userId,
|
||||
companyId: company.id,
|
||||
companyName: company.name,
|
||||
settlementType,
|
||||
status: client_1.OrderStatus.awaiting_review,
|
||||
totalMeterage,
|
||||
notes: dto.notes?.trim() || null,
|
||||
statusHistory: {
|
||||
create: {
|
||||
fromStatus: null,
|
||||
toStatus: client_1.OrderStatus.awaiting_review,
|
||||
changedBy: `admin:${adminId}`,
|
||||
note: 'سفارش توسط ادمین ثبت شد',
|
||||
},
|
||||
},
|
||||
},
|
||||
include: orderInclude,
|
||||
});
|
||||
return this.mapOrder(order, true);
|
||||
}
|
||||
async updatePricing(id, adminId, dto) {
|
||||
const order = await this.getOrder(id);
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
let totalAmount = 0;
|
||||
let totalMeterage = 0;
|
||||
for (const item of dto.items) {
|
||||
const existing = order.items.find((i) => i.id === item.id);
|
||||
if (!existing) {
|
||||
throw new common_1.BadRequestException(`آیتم ${item.id} یافت نشد`);
|
||||
}
|
||||
const unitPrice = item.unitPrice !== undefined
|
||||
? item.unitPrice
|
||||
: item.supplyPrice !== undefined
|
||||
? item.supplyPrice
|
||||
: (existing.unitPrice ?? 0);
|
||||
const unitDiscount = item.unitDiscount ?? existing.unitDiscount ?? 0;
|
||||
const confirmed = item.confirmedMeterage ??
|
||||
existing.confirmedMeterage ??
|
||||
existing.requestedMeterage;
|
||||
const lineTotal = Math.max(0, (unitPrice - unitDiscount) * confirmed);
|
||||
totalAmount += lineTotal;
|
||||
totalMeterage += confirmed;
|
||||
await tx.orderItem.update({
|
||||
where: { id: item.id },
|
||||
data: {
|
||||
confirmedMeterage: confirmed,
|
||||
unitPrice,
|
||||
unitDiscount,
|
||||
lineTotal,
|
||||
},
|
||||
});
|
||||
}
|
||||
const shippingCost = dto.shippingCost ?? order.shippingCost ?? 0;
|
||||
const totalDiscount = dto.totalDiscount ?? order.totalDiscount ?? 0;
|
||||
const finalAmount = Math.max(0, totalAmount + shippingCost - totalDiscount);
|
||||
const nextStatus = order.status === client_1.OrderStatus.awaiting_review ||
|
||||
order.status === client_1.OrderStatus.pricing
|
||||
? client_1.OrderStatus.pricing
|
||||
: order.status;
|
||||
await tx.order.update({
|
||||
where: { id },
|
||||
data: {
|
||||
totalAmount,
|
||||
totalMeterage,
|
||||
shippingCost,
|
||||
totalDiscount,
|
||||
finalAmount,
|
||||
status: nextStatus,
|
||||
},
|
||||
});
|
||||
if (nextStatus !== order.status) {
|
||||
await tx.orderStatusHistory.create({
|
||||
data: {
|
||||
orderId: id,
|
||||
fromStatus: order.status,
|
||||
toStatus: nextStatus,
|
||||
changedBy: `admin:${adminId}`,
|
||||
note: dto.note || 'قیمتگذاری انجام شد',
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
return this.findAdminOrder(id);
|
||||
}
|
||||
async updateStatus(id, adminId, dto) {
|
||||
const order = await this.getOrder(id);
|
||||
if (order.status === dto.status) {
|
||||
return this.mapOrder(order, true);
|
||||
}
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
await tx.order.update({
|
||||
where: { id },
|
||||
data: { status: dto.status },
|
||||
});
|
||||
await tx.orderStatusHistory.create({
|
||||
data: {
|
||||
orderId: id,
|
||||
fromStatus: order.status,
|
||||
toStatus: dto.status,
|
||||
changedBy: `admin:${adminId}`,
|
||||
note: dto.note || null,
|
||||
reason: dto.reason || null,
|
||||
},
|
||||
});
|
||||
if (dto.status === client_1.OrderStatus.cash_invoice_issued ||
|
||||
dto.status === client_1.OrderStatus.awaiting_cash_payment) {
|
||||
if (!order.cashInvoiceExpiresAt) {
|
||||
await tx.order.update({
|
||||
where: { id },
|
||||
data: {
|
||||
cashInvoiceExpiresAt: (0, cash_expiry_1.computeCashInvoiceExpiry)(order.company),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return this.findAdminOrder(id);
|
||||
}
|
||||
async updateChecks(userId, id, dto) {
|
||||
const order = await this.getOrder(id);
|
||||
if (order.userId !== userId) {
|
||||
throw new common_1.ForbiddenException('دسترسی به این سفارش مجاز نیست');
|
||||
}
|
||||
if (order.settlementType !== client_1.SettlementType.check) {
|
||||
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);
|
||||
await this.prisma.$transaction(async (tx) => {
|
||||
await tx.check.deleteMany({ where: { orderId: id } });
|
||||
await tx.check.createMany({
|
||||
data: dto.checks.map((c, index) => ({
|
||||
orderId: id,
|
||||
...this.mapCheckCreate(c, index + 1, checkMode),
|
||||
})),
|
||||
});
|
||||
await tx.order.update({
|
||||
where: { id },
|
||||
data: {
|
||||
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,
|
||||
},
|
||||
});
|
||||
if (order.status === client_1.OrderStatus.check_needs_fix) {
|
||||
await tx.orderStatusHistory.create({
|
||||
data: {
|
||||
orderId: id,
|
||||
fromStatus: order.status,
|
||||
toStatus: client_1.OrderStatus.awaiting_check_review,
|
||||
changedBy: 'customer',
|
||||
note: 'چکها اصلاح و مجدداً ارسال شد',
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
return this.findMyOrder(userId, id);
|
||||
}
|
||||
mapCheckCreate(c, row, defaultMode) {
|
||||
return {
|
||||
row,
|
||||
amount: c.amount,
|
||||
dueDate: new Date(c.dueDate),
|
||||
sayadId: c.sayadId?.trim() || null,
|
||||
checkNumber: c.checkNumber?.trim() || null,
|
||||
ownerNationalId: c.ownerNationalId?.trim() || null,
|
||||
ownerFirstName: c.ownerFirstName?.trim() || null,
|
||||
ownerLastName: c.ownerLastName?.trim() || null,
|
||||
bankName: c.bankName?.trim() || null,
|
||||
branchName: c.branchName?.trim() || null,
|
||||
frontImage: c.frontImage || null,
|
||||
backImage: c.backImage || null,
|
||||
notes: c.notes?.trim() || null,
|
||||
mode: c.mode ?? defaultMode,
|
||||
};
|
||||
}
|
||||
async nextOrderNumber() {
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const orderNumber = (0, order_number_1.generateOrderNumber)();
|
||||
const exists = await this.prisma.order.findUnique({
|
||||
where: { orderNumber },
|
||||
});
|
||||
if (!exists)
|
||||
return orderNumber;
|
||||
}
|
||||
return `${(0, order_number_1.generateOrderNumber)()}-${Date.now().toString().slice(-3)}`;
|
||||
}
|
||||
async getOrder(id) {
|
||||
const order = await this.prisma.order.findUnique({
|
||||
where: { id },
|
||||
include: orderInclude,
|
||||
});
|
||||
if (!order)
|
||||
throw new common_1.NotFoundException('سفارش یافت نشد');
|
||||
return order;
|
||||
}
|
||||
mapOrder(order, adminView = false) {
|
||||
const customerName = (0, name_1.joinFullName)(order.user.firstName, order.user.lastName);
|
||||
const base = {
|
||||
id: order.id,
|
||||
orderNumber: order.orderNumber,
|
||||
userId: order.userId,
|
||||
companyId: order.companyId,
|
||||
companyName: order.companyName,
|
||||
settlementType: order.settlementType,
|
||||
settlementMethod: order.settlementType,
|
||||
checkMode: order.checkMode ?? undefined,
|
||||
status: order.status,
|
||||
adminStatus: (0, order_status_1.toAdminStatus)(order.status),
|
||||
totalMeterage: order.totalMeterage,
|
||||
meterage: order.totalMeterage,
|
||||
totalAmount: order.totalAmount,
|
||||
shippingCost: order.shippingCost,
|
||||
totalDiscount: order.totalDiscount,
|
||||
finalAmount: order.finalAmount,
|
||||
notes: order.notes ?? undefined,
|
||||
checkRassDays: order.checkRassDays ?? undefined,
|
||||
checkRassDate: order.checkRassDate?.toISOString(),
|
||||
cashInvoiceExpiresAt: order.cashInvoiceExpiresAt?.toISOString(),
|
||||
createdAt: order.createdAt.toISOString(),
|
||||
updatedAt: order.updatedAt.toISOString(),
|
||||
customerName,
|
||||
customerPhone: order.user.phone,
|
||||
customerNationalId: order.user.nationalId ?? undefined,
|
||||
customerType: order.user.customerType,
|
||||
items: order.items.map((item) => ({
|
||||
id: item.id,
|
||||
productId: item.productId ?? undefined,
|
||||
catalogCode: item.catalogCode,
|
||||
productName: item.productName,
|
||||
productCode: item.productCode ?? undefined,
|
||||
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,
|
||||
notes: item.notes ?? undefined,
|
||||
})),
|
||||
checks: order.checks.map((c) => ({
|
||||
id: c.id,
|
||||
orderId: c.orderId,
|
||||
row: c.row,
|
||||
amount: c.amount,
|
||||
dueDate: c.dueDate.toISOString(),
|
||||
sayadId: c.sayadId ?? undefined,
|
||||
checkNumber: c.checkNumber ?? undefined,
|
||||
ownerNationalId: c.ownerNationalId ?? undefined,
|
||||
ownerFirstName: c.ownerFirstName ?? undefined,
|
||||
ownerLastName: c.ownerLastName ?? undefined,
|
||||
bankName: c.bankName ?? '',
|
||||
branchName: c.branchName ?? undefined,
|
||||
frontImage: c.frontImage ?? undefined,
|
||||
backImage: c.backImage ?? undefined,
|
||||
notes: c.notes ?? undefined,
|
||||
mode: c.mode,
|
||||
status: c.status,
|
||||
createdAt: c.createdAt.toISOString(),
|
||||
updatedAt: c.updatedAt.toISOString(),
|
||||
})),
|
||||
cashReceipt: order.cashReceipt
|
||||
? {
|
||||
id: order.cashReceipt.id,
|
||||
amount: order.cashReceipt.amount,
|
||||
paidAmount: order.cashReceipt.paidAmount,
|
||||
transferDate: order.cashReceipt.transferDate?.toISOString() ?? null,
|
||||
transferTime: order.cashReceipt.transferTime ?? undefined,
|
||||
trackingNumber: order.cashReceipt.trackingNumber ?? undefined,
|
||||
trackingCode: order.cashReceipt.trackingNumber ?? undefined,
|
||||
destinationAccountId: order.cashReceipt.destinationAccountId ?? undefined,
|
||||
receiptImage: order.cashReceipt.receiptImage ?? undefined,
|
||||
notes: order.cashReceipt.notes ?? undefined,
|
||||
expiresAt: order.cashReceipt.expiresAt?.toISOString() ??
|
||||
order.cashInvoiceExpiresAt?.toISOString(),
|
||||
status: order.cashReceipt.status,
|
||||
submittedAt: order.cashReceipt.submittedAt?.toISOString(),
|
||||
createdAt: order.cashReceipt.createdAt.toISOString(),
|
||||
}
|
||||
: undefined,
|
||||
shipment: order.shipment
|
||||
? {
|
||||
id: order.shipment.id,
|
||||
orderId: order.shipment.orderId,
|
||||
carrier: order.shipment.carrier,
|
||||
trackingNumber: order.shipment.trackingNumber ?? '',
|
||||
meterage: order.shipment.meterage,
|
||||
status: order.shipment.status,
|
||||
shippedAt: order.shipment.shippedAt?.toISOString() ?? null,
|
||||
deliveredAt: order.shipment.deliveredAt?.toISOString() ?? null,
|
||||
}
|
||||
: undefined,
|
||||
statusHistory: order.statusHistory.map((h) => ({
|
||||
id: h.id,
|
||||
fromStatus: h.fromStatus,
|
||||
toStatus: h.toStatus,
|
||||
changedBy: h.changedBy,
|
||||
note: h.note ?? undefined,
|
||||
reason: h.reason ?? undefined,
|
||||
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])
|
||||
], OrdersService);
|
||||
//# sourceMappingURL=orders.service.js.map
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user