Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | import { Injectable } from '@nestjs/common'; import { ConfigurationService } from '../configuration/services/configuration.service'; import { VendorService } from '../vendors/services/vendor.service'; import { RequisitionService } from '../requisitions/services/requisition.service'; import { SourcingService } from '../sourcing/services/sourcing.service'; import { PurchaseOrderService } from '../purchase-orders/services/purchase-order.service'; import { ReceiptService } from '../receipts/services/receipt.service'; import { InspectionService } from '../inspections/services/inspection.service'; import { ReturnService } from '../returns/services/return.service'; import { VendorBillService } from '../vendor-bills/services/vendor-bill.service'; import { Vendor } from '../vendors/schemas/vendor.schema'; import { PurchaseRequisition } from '../requisitions/schemas/requisition.schema'; import { PurchaseOrder } from '../purchase-orders/schemas/purchase-order.schema'; @Injectable() export class ProcurementService { constructor( public readonly configService: ConfigurationService, public readonly vendorService: VendorService, public readonly requisitionService: RequisitionService, public readonly sourcingService: SourcingService, public readonly poService: PurchaseOrderService, public readonly receiptService: ReceiptService, public readonly inspectionService: InspectionService, public readonly returnService: ReturnService, public readonly billService: VendorBillService, ) {} // ========================================================================= // VENDOR DELEGATIONS (backward-compatibility fallback routes) // ========================================================================= async createVendor(tenantId: string, data: any, userId: string): Promise<Vendor> { return this.vendorService.createVendor(tenantId, data, userId); } async getVendors(tenantId: string): Promise<Vendor[]> { return this.vendorService.getVendors(tenantId); } async getVendorById(tenantId: string, id: string, userId: string = 'system'): Promise<Vendor> { return this.vendorService.getVendorById(tenantId, id, userId); } async updateVendor(tenantId: string, id: string, data: any, userId: string): Promise<Vendor> { return this.vendorService.updateVendor(tenantId, id, data, userId); } // ========================================================================= // REQUISITION DELEGATIONS // ========================================================================= async createRequisition(tenantId: string, requesterId: string, data: any, userId: string): Promise<PurchaseRequisition> { return this.requisitionService.createRequisition(tenantId, requesterId, data, userId); } async getRequisitions(tenantId: string, requesterId?: string): Promise<PurchaseRequisition[]> { return this.requisitionService.getRequisitions(tenantId, requesterId); } async getRequisitionById(tenantId: string, id: string): Promise<PurchaseRequisition> { return this.requisitionService.getRequisitionById(tenantId, id); } async approveRequisition(tenantId: string, id: string, userId: string): Promise<PurchaseRequisition> { return this.requisitionService.approveRequisition(tenantId, id, userId); } async rejectRequisition(tenantId: string, id: string, userId: string): Promise<PurchaseRequisition> { return this.requisitionService.rejectRequisition(tenantId, id, userId); } // ========================================================================= // PURCHASE ORDER DELEGATIONS // ========================================================================= async createPurchaseOrder(tenantId: string, data: any, userId: string): Promise<PurchaseOrder> { return this.poService.createPurchaseOrder(tenantId, data, userId); } async getPurchaseOrders(tenantId: string): Promise<PurchaseOrder[]> { return this.poService.getPurchaseOrders(tenantId); } async getPurchaseOrderById(tenantId: string, id: string): Promise<PurchaseOrder> { return this.poService.getPurchaseOrderById(tenantId, id); } async approvePurchaseOrder(tenantId: string, id: string, userId: string): Promise<PurchaseOrder> { return this.poService.approvePurchaseOrder(tenantId, id, userId); } // ========================================================================= // SEEDER HELPER // ========================================================================= async seed(tenantId: string, userId: string): Promise<any> { // Seed initial configuration await this.configService.getConfiguration(tenantId); // Seed default vendors const count = await this.vendorService.getVendors(tenantId); if (count.length === 0) { await this.vendorService.createVendor(tenantId, { name: 'Dell Technologies', code: 'VND-DELL', email: 'sales@dell.com', phone: '1-800-456-3355', address: 'One Dell Way, Round Rock, TX', category: 'IT Hardware', }, userId); await this.vendorService.createVendor(tenantId, { name: 'Staples Business Depot', code: 'VND-STAPLES', email: 'support@staples.com', phone: '1-877-877-2673', address: '500 Staples Dr, Framingham, MA', category: 'Office Supplies', }, userId); } return { seeded: true }; } } |