Rebuild order flow: settle after pricing, notifications, and invoice expiry.
Hide prices until admin sends the invoice, enforce status transitions, add customer/admin SMS+in-app notifications, schedule cash invoice reminders, and ship updated dist/prisma-client/deploy-bundle for git-pull deploys. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Vendored
+21
-2
@@ -14,6 +14,8 @@ const common_1 = require("@nestjs/common");
|
||||
const client_1 = require("@prisma/client");
|
||||
const prisma_service_1 = require("../prisma/prisma.service");
|
||||
const name_1 = require("../common/utils/name");
|
||||
const notifications_service_1 = require("../notifications/notifications.service");
|
||||
const notification_events_1 = require("../notifications/notification-events");
|
||||
const STATUS_FLOW = [
|
||||
client_1.ShipmentStatus.preparing,
|
||||
client_1.ShipmentStatus.ready,
|
||||
@@ -28,8 +30,10 @@ const SHIPMENT_TO_ORDER = {
|
||||
};
|
||||
let ShipmentsService = class ShipmentsService {
|
||||
prisma;
|
||||
constructor(prisma) {
|
||||
notifications;
|
||||
constructor(prisma, notifications) {
|
||||
this.prisma = prisma;
|
||||
this.notifications = notifications;
|
||||
}
|
||||
async findAll(status) {
|
||||
const shipments = await this.prisma.shipment.findMany({
|
||||
@@ -92,6 +96,10 @@ let ShipmentsService = class ShipmentsService {
|
||||
}
|
||||
return created;
|
||||
});
|
||||
this.notifyOrderStatus(order.id, SHIPMENT_TO_ORDER[status], {
|
||||
carrier: shipment.carrier,
|
||||
trackingNumber: shipment.trackingNumber,
|
||||
});
|
||||
return this.map(shipment);
|
||||
}
|
||||
async update(id, dto) {
|
||||
@@ -160,8 +168,18 @@ let ShipmentsService = class ShipmentsService {
|
||||
}
|
||||
return result;
|
||||
});
|
||||
this.notifyOrderStatus(shipment.orderId, SHIPMENT_TO_ORDER[nextStatus], {
|
||||
carrier: updated.carrier,
|
||||
trackingNumber: updated.trackingNumber,
|
||||
});
|
||||
return this.map(updated);
|
||||
}
|
||||
notifyOrderStatus(orderId, status, context) {
|
||||
const event = (0, notification_events_1.eventForStatus)(status);
|
||||
if (event) {
|
||||
this.notifications.dispatchOrderEvent(orderId, event, context);
|
||||
}
|
||||
}
|
||||
async ensure(id) {
|
||||
const shipment = await this.prisma.shipment.findUnique({ where: { id } });
|
||||
if (!shipment)
|
||||
@@ -188,6 +206,7 @@ let ShipmentsService = class ShipmentsService {
|
||||
exports.ShipmentsService = ShipmentsService;
|
||||
exports.ShipmentsService = ShipmentsService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService,
|
||||
notifications_service_1.NotificationsService])
|
||||
], ShipmentsService);
|
||||
//# sourceMappingURL=shipments.service.js.map
|
||||
Reference in New Issue
Block a user