'use strict'; const assert = require('node:assert/strict'); const ReceivingService = require('../../../../app/service/systems/storage/receiving'); describe('test/app/service/systems/storage.receiving.complete.notice.test.js', () => { it('should include box_remainder and box_weight in completeReceiving notice payload', async () => { const noticeCalls = []; const transaction = { LOCK: { UPDATE: 'UPDATE', }, finished: false, async commit() { this.finished = 'commit'; }, async rollback() { this.finished = 'rollback'; }, }; const ctx = { app: { Sequelize: { Op: { in: 'in', }, }, }, user: { store_id: 100000, employees_id: 2001, employees_name: '测试员A', }, logger: { info() {}, warn() {}, error() {}, }, service: { systems: { operationLog: { async createOperationLog() { return null; }, }, }, }, model: { async transaction() { return transaction; }, ReceivingDetail: {}, StockWarehouse: {}, Receiving: { async findOne() { return { id: 123, warehouse_id: 100000, store_id: 1000000, store_name: '测试货主', receiving_number: 'RCV202605060001', status: 'receiving', remark: '', details: [ { id: 501, system_product_id: 10001, product_name: '测试商品A', barcode: 'SKU-001', actual_quantity: 8, weight: 12, box_quantity: 2, pallet_quantity: 1, box_remainder: 1, box_weight: 24.5, system_product: { id: 10001, is_batch_mgmt: 'N', is_shelf_life_mgmt: 'N', }, }, ], }; }, async update() { return [ 1 ]; }, }, FileReference: { async findAll() { return []; }, }, }, }; const service = new ReceivingService(ctx); service.sendCompletionNotice = async payload => { noticeCalls.push(payload); return { success: true }; }; service._syncProductDataFromReceiving = async () => {}; const result = await service.completeReceiving({ id: 123 }); assert.equal(result.success, true); assert.equal(noticeCalls.length, 1); assert.equal(Number(noticeCalls[0].receiving.details[0].box_remainder), 1); assert.equal(Number(noticeCalls[0].receiving.details[0].box_weight), 24.5); }); });