|
@@ -8,6 +8,7 @@
|
|
|
'use strict';
|
|
|
|
|
|
const excel = require('node-xlsx');
|
|
|
+const _ = require('lodash');
|
|
|
|
|
|
/*const testNodeData = [
|
|
|
{ ledger_id: 1, ledger_pid: -1, order: 1, level: 1, full_path: '1', code: '1', is_leaf: false },
|
|
@@ -61,7 +62,8 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
it('clear history test data', function* () {
|
|
|
const ctx = app.mockContext();
|
|
|
const result = yield ctx.service.ledger.db.delete(ctx.service.ledger.tableName, { tender_id: testTenderId });
|
|
|
- assert(result.affectedRows >= 0);
|
|
|
+ const posResult = yield ctx.service.pos.db.delete(ctx.service.ledger.tableName, { tender_id: testTenderId });
|
|
|
+ assert(result.affectedRows >= 0 && posResult.affectedRows >= 0);
|
|
|
});
|
|
|
it('add test data(test add)', function* () {
|
|
|
const ctx = app.mockContext();
|
|
@@ -378,8 +380,8 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
const ctx = app.mockContext();
|
|
|
// 选中1-3 降级
|
|
|
const resultData = yield ctx.service.ledger.downLevelNode(testTenderId, 4);
|
|
|
- // 1-3/1-3-1/1-4修改
|
|
|
- assert(resultData.update.length === 3);
|
|
|
+ // 1-2/1-3/1-3-1/1-4修改
|
|
|
+ assert(resultData.update.length === 4);
|
|
|
|
|
|
let node = findById(resultData.update, 4);
|
|
|
assert(node.full_path === '1.3.4');
|
|
@@ -536,10 +538,14 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
*/
|
|
|
it('test updateCalc - update 1', function* () {
|
|
|
const ctx = app.mockContext();
|
|
|
+ // 计算需使用清单精度、小数位数
|
|
|
+ ctx.tender = {id: testTenderId};
|
|
|
+ ctx.tender.data = yield ctx.service.tender.getTender(testTenderId);
|
|
|
+ ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(testTenderId);
|
|
|
// 修改202-2-e(1-1-1下)(id=12)的quantity为2.00000001, unit_price位3.0000005
|
|
|
- const qty = 2.00000001;
|
|
|
- const up = 3.0000005;
|
|
|
- const tp = 6.00000103;
|
|
|
+ const qty = 2.00000001, fQty = ctx.helper.round(qty, ctx.tender.info.precision.other.value);
|
|
|
+ const up = 3.0000005, fUp = ctx.helper.round(up, ctx.tender.info.decimal.up);
|
|
|
+ const tp = 6.00000103, fTp = ctx.helper.times(fQty, fUp);
|
|
|
const node1 = yield ctx.service.ledger.getDataByNodeId(testTenderId, 12);
|
|
|
assert(node1);
|
|
|
const resultData = yield ctx.service.ledger.updateCalc(testTenderId, {
|
|
@@ -551,7 +557,9 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
});
|
|
|
assert(resultData.update.length === 1);
|
|
|
let node = findById(resultData.update, 12);
|
|
|
- assert(node.total_price.toFixed(8) == tp);
|
|
|
+ assert(node.quantity === fQty);
|
|
|
+ assert(node.unit_price === fUp);
|
|
|
+ assert(node.total_price == fTp);
|
|
|
});
|
|
|
/* 期望运行结果:
|
|
|
1
|
|
@@ -559,7 +567,7 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
│ ├── 1-1-1
|
|
|
│ │ └── 202-2
|
|
|
│ │ ├── 202-2-c
|
|
|
- │ │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ │ └── 202-2-e 2 3 6
|
|
|
│ └── 1-1-4
|
|
|
├── 1-1-2
|
|
|
│ └── 1-1-3
|
|
@@ -576,13 +584,28 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
*/
|
|
|
it('test updateCalc - update N', function* () {
|
|
|
const ctx = app.mockContext();
|
|
|
+ // 计算需使用清单精度、小数位数
|
|
|
+ ctx.tender = {id: testTenderId};
|
|
|
+ ctx.tender.data = yield ctx.service.tender.getTender(testTenderId);
|
|
|
+ ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(testTenderId);
|
|
|
// 修改202-2-c(1-1-1下)(id=11)的quantity为4.00000025, unit_price为6.0000083
|
|
|
// 202-2-c(1-2-2下)(id=20)的quantity为2.0000001, unit_price为5.000065
|
|
|
// 202-2-e(1-2-2下)(id=21)的quantity为8.0000579, unit_price为4.0000086
|
|
|
const qty = [4.00000025, 2.0000001, 8.0000579];
|
|
|
const up = [6.0000083, 5.000065, 4.0000086];
|
|
|
const tp = [24.0000347, 10.0001305, 32.0003004];
|
|
|
- const sum = [30.00003573, 42.0004309, 72.00046663]
|
|
|
+ // 实际结果
|
|
|
+ const fQty = [], fUp = [], fTp = [];
|
|
|
+ for (const q of qty) {
|
|
|
+ fQty.push(ctx.helper.round(q, ctx.tender.info.precision.other.value));
|
|
|
+ }
|
|
|
+ for (const p of up) {
|
|
|
+ fUp.push(ctx.helper.round(p, ctx.tender.info.decimal.up));
|
|
|
+ }
|
|
|
+ for (const i in qty) {
|
|
|
+ fTp.push(ctx.helper.times(fQty[i], fUp[i]));
|
|
|
+ }
|
|
|
+
|
|
|
const node1 = yield ctx.service.ledger.getDataByNodeId(testTenderId, 11);
|
|
|
assert(node1);
|
|
|
const node2 = yield ctx.service.ledger.getDataByNodeId(testTenderId, 20);
|
|
@@ -613,19 +636,25 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
assert(resultData.update.length === 3);
|
|
|
|
|
|
let node = findById(resultData.update, 11);
|
|
|
- assert(node.total_price.toFixed(8) == tp[0]);
|
|
|
+ assert(node.quantity == fQty[0]);
|
|
|
+ assert(node.unit_price == fUp[0]);
|
|
|
+ assert(node.total_price === fTp[0]);
|
|
|
node = findById(resultData.update, 20);
|
|
|
- assert(node.total_price.toFixed(8) == tp[1]);
|
|
|
+ assert(node.quantity == fQty[1]);
|
|
|
+ assert(node.unit_price == fUp[1]);
|
|
|
+ assert(node.total_price === fTp[1]);
|
|
|
node = findById(resultData.update, 21);
|
|
|
- assert(node.total_price.toFixed(8) == tp[2]);
|
|
|
+ assert(node.quantity == fQty[2]);
|
|
|
+ assert(node.unit_price == fUp[2]);
|
|
|
+ assert(node.total_price == fTp[2]);
|
|
|
});
|
|
|
/* 期望运行结果:
|
|
|
1
|
|
|
├── 1-1
|
|
|
│ ├── 1-1-1
|
|
|
│ │ └── 202-2
|
|
|
- │ │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ │ ├── 202-2-c 4 6 24
|
|
|
+ │ │ └── 202-2-e 2 3 6
|
|
|
│ └── 1-1-4
|
|
|
├── 1-1-2
|
|
|
│ └── 1-1-3
|
|
@@ -633,8 +662,8 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
│ ├── 1-2-1
|
|
|
│ ├── 1-2-2
|
|
|
│ │ └── 202-2
|
|
|
- │ │ ├── 202-2-c 2.0000001 5.000065 10.0001305
|
|
|
- │ │ └── 202-2-e 8.0000579 4.0000086 32.0003004
|
|
|
+ │ │ ├── 202-2-c 2 5 10
|
|
|
+ │ │ └── 202-2-e 8 4 32
|
|
|
│ ├── 1-2-3
|
|
|
│ └── 1-3
|
|
|
│ └── 1-3-1
|
|
@@ -654,20 +683,20 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
├── 1-1
|
|
|
│ ├── 1-1-1
|
|
|
│ │ └── 202-2
|
|
|
- │ │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ │ ├── 202-2-c 4 6 24
|
|
|
+ │ │ └── 202-2-e 2 3 6
|
|
|
│ ├── 1-1-4
|
|
|
│ └── 202-2
|
|
|
- │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ ├── 202-2-c 4 6 24
|
|
|
+ │ └── 202-2-e 2 3 6
|
|
|
├── 1-1-2
|
|
|
│ └── 1-1-3
|
|
|
├── 1-2
|
|
|
│ ├── 1-2-1
|
|
|
│ ├── 1-2-2
|
|
|
│ │ └── 202-2
|
|
|
- │ │ ├── 202-2-c 2.0000001 5.000065 10.0001305
|
|
|
- │ │ └── 202-2-e 8.0000579 4.0000086 32.0003004
|
|
|
+ │ │ ├── 202-2-c 2 5 10
|
|
|
+ │ │ └── 202-2-e 8 4 32
|
|
|
│ ├── 1-2-3
|
|
|
│ └── 1-3
|
|
|
│ └── 1-3-1
|
|
@@ -685,20 +714,20 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
├── 1-1
|
|
|
│ ├── 1-1-1
|
|
|
│ │ └── 202-2
|
|
|
- │ │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ │ ├── 202-2-c 4 6 24
|
|
|
+ │ │ └── 202-2-e 2 3 6
|
|
|
│ └── 1-1-4
|
|
|
│ └── 202-2
|
|
|
- │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ ├── 202-2-c 4 6 24
|
|
|
+ │ └── 202-2-e 2 3 6
|
|
|
├── 1-1-2
|
|
|
│ └── 1-1-3
|
|
|
├── 1-2
|
|
|
│ ├── 1-2-1
|
|
|
│ ├── 1-2-2
|
|
|
│ │ └── 202-2
|
|
|
- │ │ ├── 202-2-c 2.0000001 5.000065 10.0001305
|
|
|
- │ │ └── 202-2-e 8.0000579 4.0000086 32.0003004
|
|
|
+ │ │ ├── 202-2-c 2 5 10
|
|
|
+ │ │ └── 202-2-e 8 4 32
|
|
|
│ ├── 1-2-3
|
|
|
│ └── 1-3
|
|
|
│ └── 1-3-1
|
|
@@ -712,23 +741,23 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
├── 1-1
|
|
|
│ ├── 1-1-1
|
|
|
│ │ └── 202-2
|
|
|
- │ │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ │ ├── 202-2-c 4 6 24
|
|
|
+ │ │ └── 202-2-e 2 3 6
|
|
|
│ └── 1-1-4
|
|
|
│ ├── 202-2
|
|
|
- │ │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ │ ├── 202-2-c 4 6 24
|
|
|
+ │ │ └── 202-2-e 2 3 6
|
|
|
│ └── 202-2
|
|
|
- │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ ├── 202-2-c 4 6 24
|
|
|
+ │ └── 202-2-e 2 3 6
|
|
|
├── 1-1-2
|
|
|
│ └── 1-1-3
|
|
|
├── 1-2
|
|
|
│ ├── 1-2-1
|
|
|
│ ├── 1-2-2
|
|
|
│ │ └── 202-2
|
|
|
- │ │ ├── 202-2-c 2.0000001 5.000065 10.0001305
|
|
|
- │ │ └── 202-2-e 8.0000579 4.0000086 32.0003004
|
|
|
+ │ │ ├── 202-2-c 2 5 10
|
|
|
+ │ │ └── 202-2-e 8 4 32
|
|
|
│ ├── 1-2-3
|
|
|
│ └── 1-3
|
|
|
│ └── 1-3-1
|
|
@@ -743,23 +772,23 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
├── 1-1
|
|
|
│ ├── 1-1-1
|
|
|
│ │ └── 202-2
|
|
|
- │ │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ │ ├── 202-2-c 4 6 24
|
|
|
+ │ │ └── 202-2-e 2 3 6
|
|
|
│ ├── 1-1-4
|
|
|
│ └── 202-2
|
|
|
- │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ ├── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ ├── 202-2-c 4 6 24
|
|
|
+ │ ├── 202-2-e 2 3 6
|
|
|
│ └── 202-2
|
|
|
- │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ ├── 202-2-c 4 6 24
|
|
|
+ │ └── 202-2-e 2 3 6
|
|
|
├── 1-1-2
|
|
|
│ └── 1-1-3
|
|
|
├── 1-2
|
|
|
│ ├── 1-2-1
|
|
|
│ ├── 1-2-2
|
|
|
│ │ └── 202-2
|
|
|
- │ │ ├── 202-2-c 2.0000001 5.000065 10.0001305
|
|
|
- │ │ └── 202-2-e 8.0000579 4.0000086 32.0003004
|
|
|
+ │ │ ├── 202-2-c 2 5 10
|
|
|
+ │ │ └── 202-2-e 8 4 32
|
|
|
│ ├── 1-2-3
|
|
|
│ └── 1-3
|
|
|
│ └── 1-3-1
|
|
@@ -778,22 +807,22 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
├── 1-1
|
|
|
│ ├── 1-1-1
|
|
|
│ │ └── 202-2
|
|
|
- │ │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ │ ├── 202-2-c 4 6 24
|
|
|
+ │ │ └── 202-2-e 2 3 6
|
|
|
│ ├── 1-1-4
|
|
|
│ └── 202-2
|
|
|
- │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ ├── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ ├── 202-2-c 4 6 24
|
|
|
+ │ ├── 202-2-e 2 3 6
|
|
|
│ └── 202-2
|
|
|
- │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ ├── 202-2-c 4 6 24
|
|
|
+ │ └── 202-2-e 2 3 6
|
|
|
├── 1-1-2
|
|
|
│ └── 1-1-3
|
|
|
├── 1-2
|
|
|
│ ├── 1-2-1
|
|
|
│ ├── 1-2-2
|
|
|
│ │ └── 202-2
|
|
|
- │ │ └── 202-2-e 8.0000579 4.0000086 32.0003004
|
|
|
+ │ │ └── 202-2-e 8 4 32
|
|
|
│ ├── 1-2-3
|
|
|
│ └── 1-3
|
|
|
│ └── 1-3-1
|
|
@@ -821,27 +850,27 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
// 从标准库中添加101-1
|
|
|
});
|
|
|
/* 期望运行结果:
|
|
|
- 1 122.00040759
|
|
|
- ├── 1-1 90.00009719
|
|
|
- │ ├── 1-1-1 30.00003573
|
|
|
- │ │ └── 202-2 30.00003573
|
|
|
- │ │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ 1
|
|
|
+ ├── 1-1
|
|
|
+ │ ├── 1-1-1
|
|
|
+ │ │ └── 202-2
|
|
|
+ │ │ ├── 202-2-c 4 6 24
|
|
|
+ │ │ └── 202-2-e 2 3 6
|
|
|
│ ├── 1-1-4
|
|
|
│ ├── 1-1-5
|
|
|
- │ └── 202-2 60.00007146
|
|
|
- │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ ├── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
- │ └── 202-2 30.00003573
|
|
|
- │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
- │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
+ │ └── 202-2
|
|
|
+ │ ├── 202-2-c 4 6 24
|
|
|
+ │ ├── 202-2-e 2 3 6
|
|
|
+ │ └── 202-2
|
|
|
+ │ ├── 202-2-c 4 6 24
|
|
|
+ │ └── 202-2-e 2 3 6
|
|
|
├── 1-1-2
|
|
|
│ └── 1-1-3
|
|
|
- ├── 1-2 32.0003004
|
|
|
+ ├── 1-2
|
|
|
│ ├── 1-2-1
|
|
|
- │ ├── 1-2-2 32.0003004
|
|
|
- │ │ └── 202-2 32.0003004
|
|
|
- │ │ └── 202-2-e 8.0000579 4.0000086 32.0003004
|
|
|
+ │ ├── 1-2-2
|
|
|
+ │ │ └── 202-2
|
|
|
+ │ │ └── 202-2-e 8 4 32
|
|
|
│ ├── 1-2-3
|
|
|
│ └── 1-3
|
|
|
│ └── 1-3-1
|
|
@@ -875,7 +904,6 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
assert(result2.update.length === 1);
|
|
|
assert(result2.update[0].code = '1-4-2-1');
|
|
|
assert(!result2.update[0].is_leaf);
|
|
|
- assert(result2.expand.length === 4);
|
|
|
// 从标准库添加1-4-2-1-1
|
|
|
const condition3 = { list_id: 1, code: '1-4-2-1-1'};
|
|
|
const libData3 = yield ctx.service.stdChapter.getDataByCondition(condition3);
|
|
@@ -890,29 +918,28 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
assert(result3.update.length === 1);
|
|
|
assert(result3.update[0].code === '1-4-2-1-2');
|
|
|
assert(result3.update[0].order === 2);
|
|
|
- assert(result3.expand.length === 5);
|
|
|
});
|
|
|
/* 期望运行结果:
|
|
|
- 1 122.00040759
|
|
|
- ├── 1-1 90.00009719
|
|
|
- │ ├── 1-1-1 30.00003573
|
|
|
- │ │ └── 202-2 30.00003573
|
|
|
+ 1
|
|
|
+ ├── 1-1
|
|
|
+ │ ├── 1-1-1
|
|
|
+ │ │ └── 202-2
|
|
|
│ │ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
│ │ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
│ ├── 1-1-4
|
|
|
│ ├── 1-1-5
|
|
|
- │ └── 202-2 60.00007146
|
|
|
+ │ └── 202-2
|
|
|
│ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
│ ├── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
- │ └── 202-2 30.00003573
|
|
|
+ │ └── 202-2
|
|
|
│ ├── 202-2-c 4.00000025 6.0000083 24.0000347
|
|
|
│ └── 202-2-e 2.00000001 3.0000005 6.00000103
|
|
|
├── 1-1-2
|
|
|
│ └── 1-1-3
|
|
|
- ├── 1-2 32.0003004
|
|
|
+ ├── 1-2
|
|
|
│ ├── 1-2-1
|
|
|
- │ ├── 1-2-2 32.0003004
|
|
|
- │ │ └── 202-2 32.0003004
|
|
|
+ │ ├── 1-2-2
|
|
|
+ │ │ └── 202-2
|
|
|
│ │ └── 202-2-e 8.0000579 4.0000086 32.0003004
|
|
|
│ ├── 1-2-3
|
|
|
│ └── 1-3
|
|
@@ -926,6 +953,10 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
// 批量插入
|
|
|
it('test batchInsertChild', function* () {
|
|
|
const ctx = app.mockContext();
|
|
|
+ // 计算需使用清单精度、小数位数
|
|
|
+ ctx.tender = {id: testTenderId};
|
|
|
+ ctx.tender.data = yield ctx.service.tender.getTender(testTenderId);
|
|
|
+ ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(testTenderId);
|
|
|
// pos需要记录createUserId
|
|
|
ctx.session = {
|
|
|
sessionUser: {
|
|
@@ -946,12 +977,12 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
// 选中1-1-3(id=14)
|
|
|
const result = yield ctx.service.ledger.batchInsertChild(testTenderId, 14, batchData);
|
|
|
assert(result.ledger.create.length === 2);
|
|
|
- let node = findById(result.ledger.create, 36);
|
|
|
- assert(node.quantity.toFixed(8) == 3);
|
|
|
- assert(node.total_price.toFixed(8) == 6);
|
|
|
- node = findById(result.ledger.create, 37);
|
|
|
- assert(node.quantity.toFixed(8) == 7);
|
|
|
- assert(node.total_price.toFixed(8) == 21);
|
|
|
+ let node = _.find(result.ledger.create, {name: 'A1'});
|
|
|
+ assert(node.quantity === 3);
|
|
|
+ assert(node.total_price === 6);
|
|
|
+ node = _.find(result.ledger.create, {name: 'A2'});
|
|
|
+ assert(node.quantity === 7);
|
|
|
+ assert(node.total_price === 21);
|
|
|
|
|
|
assert(result.pos.length === 4);
|
|
|
});
|
|
@@ -995,6 +1026,10 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
// 批量插入
|
|
|
it('test batchInsertNext', function* () {
|
|
|
const ctx = app.mockContext();
|
|
|
+ // 计算需使用清单精度、小数位数
|
|
|
+ ctx.tender = {id: testTenderId};
|
|
|
+ ctx.tender.data = yield ctx.service.tender.getTender(testTenderId);
|
|
|
+ ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(testTenderId);
|
|
|
// pos需要记录createUserId
|
|
|
ctx.session = {
|
|
|
sessionUser: {
|
|
@@ -1004,11 +1039,11 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
|
|
|
const batchData = [
|
|
|
{
|
|
|
- b_code: 403-1, name: 'A1', unit: 'B1', price: 2,
|
|
|
+ b_code: 403-1, name: 'A3', unit: 'B1', price: 2,
|
|
|
pos: [{name: 'Y1', quantity: 5}, {name: 'Y2', quantity: 6}],
|
|
|
},
|
|
|
{
|
|
|
- b_code: 404-1, name: 'A2', unit: 'B2', price: 3,
|
|
|
+ b_code: 404-1, name: 'A4', unit: 'B2', price: 3,
|
|
|
pos: [{name: 'Y1', quantity: 7}, {name: 'Y2', quantity: 8}],
|
|
|
},
|
|
|
];
|
|
@@ -1016,12 +1051,12 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
const result = yield ctx.service.ledger.batchInsertNext(testTenderId, 14, batchData);
|
|
|
|
|
|
assert(result.ledger.create.length === 2);
|
|
|
- let node = findById(result.ledger.create, 39);
|
|
|
- assert(node.quantity.toFixed(8) == 11);
|
|
|
- assert(node.total_price.toFixed(8) == 22);
|
|
|
- node = findById(result.ledger.create, 40);
|
|
|
- assert(node.quantity.toFixed(8) == 15);
|
|
|
- assert(node.total_price.toFixed(8) == 45);
|
|
|
+ let node = _.find(result.ledger.create, {name: 'A3'});
|
|
|
+ assert(node.quantity === 11);
|
|
|
+ assert(node.total_price === 22);
|
|
|
+ node = _.find(result.ledger.create, {name: 'A4'});
|
|
|
+ assert(node.quantity === 15);
|
|
|
+ assert(node.total_price === 45);
|
|
|
|
|
|
assert(result.pos.length === 4);
|
|
|
});
|
|
@@ -1075,7 +1110,7 @@ describe('test/app/service/ledger.test.js', () => {
|
|
|
|
|
|
// 统计202-2(id=23)前两个子节点的金额
|
|
|
const result1 = yield ctx.service.ledger.addUpChildren(testTenderId, 23, 2, '<=');
|
|
|
- assert(result1 && result1.toFixed(8) == 30.00003573);
|
|
|
+ assert(result1 && result1 === 30);
|
|
|
// 数据库不再存储父项金额,以下两个查询不能获得实际金额
|
|
|
// 统计202-2(id=23)后两个子节点的金额
|
|
|
//const result2 = yield ctx.service.ledger.addUpChildren(testTenderId, 23, 2, '>=');
|