|
@@ -263,6 +263,16 @@ class StageIm {
|
|
|
}
|
|
|
|
|
|
_getCalcMemo(im) {
|
|
|
+ if (im.gclBills && im.gclBills.length > 0) {
|
|
|
+ const self = this;
|
|
|
+ im.gclBills.sort(function (x, y) {
|
|
|
+ return self.ctx.helper.compareCode(x.b_code, y.b_code);
|
|
|
+ });
|
|
|
+ for (const b of im.gclBills) {
|
|
|
+ b.imid = im.id;
|
|
|
+ this.ImBillsData.push(b);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (im.calc_memo !== undefined && im.calc_memo !== null && im.calc_memo !== '') return;
|
|
|
|
|
|
if (im.leafXmjs && im.leafXmjs.length > 0) {
|
|
@@ -274,10 +284,6 @@ class StageIm {
|
|
|
}
|
|
|
im.calc_memo = memo.join('\n');
|
|
|
} else if (im.gclBills && im.gclBills.length > 0) {
|
|
|
- const self = this;
|
|
|
- im.gclBills.sort(function (x, y) {
|
|
|
- return self.ctx.helper.compareCode(x.b_code, y.b_code);
|
|
|
- });
|
|
|
const memo = [];
|
|
|
for (const [i, b] of im.gclBills.entries()) {
|
|
|
if (b.pos && b.pos.length > 0) {
|
|
@@ -336,7 +342,6 @@ class StageIm {
|
|
|
if (!b) {
|
|
|
b = { imid: im.id, bid: p.id, b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price };
|
|
|
im.gclBills.push(b);
|
|
|
- this.ImBillsData.push(b);
|
|
|
}
|
|
|
b.quantity = this.ctx.helper.add(b.quantity, p.quantity);
|
|
|
b.total_price = this.ctx.helper.add(b.total_price, p.total_price);
|
|
@@ -440,10 +445,9 @@ class StageIm {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- _addBwBillsGclBills(im, bills) {
|
|
|
+ _addBwBillsGclBills(im, bills, pos) {
|
|
|
const helper = this.ctx.helper;
|
|
|
- if (!im.imBills) im.imBills = [];
|
|
|
- im.imBills.push(bills);
|
|
|
+ const tp_decimal = this.ctx.tender.info.decimal.tp;
|
|
|
|
|
|
if (!im.gclBills) im.gclBills = [];
|
|
|
let gcl = im.gclBills.find(function (x) {
|
|
@@ -455,10 +459,63 @@ class StageIm {
|
|
|
if (!gcl) {
|
|
|
gcl = {b_code: bills.b_code, name: bills.name, unit: bills.unit, unit_price: bills.unit_price};
|
|
|
im.gclBills.push(gcl);
|
|
|
+ this.ImBillsData.push(gcl);
|
|
|
+ }
|
|
|
+ if (pos) {
|
|
|
+ gcl.quantity = helper.add(gcl.quantity, pos.quantity);
|
|
|
+ gcl.total_price = helper.mul(gcl.unit_price, gcl.quantity, tp_decimal);
|
|
|
+
|
|
|
+ gcl.jl = helper.add(gcl.jl, pos.gather_qty);
|
|
|
+ gcl.contract_jl = helper.add(gcl.contract_jl, pos.contract_qty);
|
|
|
+ gcl.qc_jl = helper.add(gcl.qc_jl, pos.qc_qty);
|
|
|
+
|
|
|
+ gcl.tp = helper.mul(gcl.unit_price, gcl.jl, tp_decimal);
|
|
|
+ gcl.contract_tp = helper.mul(gcl.unit_price, gcl.contract_jl, tp_decimal);
|
|
|
+ gcl.qc_tp = helper.mul(gcl.unit_price, gcl.qc_jl, tp_decimal);
|
|
|
+
|
|
|
+ gcl.pre_jl = helper.add(gcl.pre_jl, pos.pre_gather_qty);
|
|
|
+ gcl.pre_contract_jl = helper.add(gcl.pre_contract_jl, pos.pre_contract_qty);
|
|
|
+ gcl.pre_qc_jl = helper.add(gcl.pre_qc_jl, pos.pre_qc_qty);
|
|
|
+
|
|
|
+ gcl.pre_tp = helper.mul(gcl.unit_price, gcl.pre_jl, tp_decimal);
|
|
|
+ gcl.pre_contract_tp = helper.mul(gcl.unit_price, gcl.pre_contract_jl, tp_decimal);
|
|
|
+ gcl.pre_qc_tp = helper.mul(gcl.unit_price, gcl.pre_qc_jl, tp_decimal);
|
|
|
+
|
|
|
+ gcl.end_jl = helper.add(gcl.end_jl, pos.end_gather_qty);
|
|
|
+ gcl.end_contract_jl = helper.add(gcl.end_contract_jl, pos.end_contract_qty);
|
|
|
+ gcl.end_qc_jl = helper.add(gcl.end_qc_jl, pos.end_qc_qty);
|
|
|
+
|
|
|
+ gcl.end_tp = helper.mul(gcl.unit_price, gcl.end_jl, tp_decimal);
|
|
|
+ gcl.end_contract_tp = helper.mul(gcl.unit_price, gcl.end_contract_jl, tp_decimal);
|
|
|
+ gcl.end_qc_tp = helper.mul(gcl.unit_price, gcl.end_qc_jl, tp_decimal);
|
|
|
+ } else {
|
|
|
+ gcl.quantity = helper.add(gcl.quantity, bills.quantity);
|
|
|
+ gcl.total_price = helper.add(gcl.total_price, bills.total_price);
|
|
|
+
|
|
|
+ gcl.jl = helper.add(gcl.jl, bills.gather_qty);
|
|
|
+ gcl.contract_jl = helper.add(gcl.contract_jl, bills.contract_qty);
|
|
|
+ gcl.qc_jl = helper.add(gcl.qc_jl, bills.qc_qty);
|
|
|
+
|
|
|
+ gcl.tp = helper.add(gcl.tp, bills.gather_tp);
|
|
|
+ gcl.contract_tp = helper.add(gcl.contract_tp, bills.contract_tp);
|
|
|
+ gcl.qc_tp = helper.add(gcl.qc_tp, bills.qc_tp);
|
|
|
+
|
|
|
+ gcl.pre_jl = helper.add(gcl.pre_jl, bills.pre_gather_qty);
|
|
|
+ gcl.pre_contract_jl = helper.add(gcl.pre_contract_jl, bills.pre_contract_qty);
|
|
|
+ gcl.pre_qc_jl = helper.add(gcl.pre_qc_jl, bills.pre_qc_qty);
|
|
|
+
|
|
|
+ gcl.pre_tp = helper.add(gcl.pre_tp, bills.pre_gather_tp);
|
|
|
+ gcl.pre_contract_tp = helper.add(gcl.pre_contract_tp, bills.pre_contract_tp);
|
|
|
+ gcl.pre_qc_tp = helper.add(gcl.pre_qc_tp, bills.pre_qc_tp);
|
|
|
+
|
|
|
+ gcl.end_jl = helper.add(gcl.end_jl, bills.end_gather_qty);
|
|
|
+ gcl.end_contract_jl = helper.add(gcl.end_contract_jl, bills.end_contract_qty);
|
|
|
+ gcl.end_qc_jl = helper.add(gcl.end_qc_jl, bills.end_qc_qty);
|
|
|
+
|
|
|
+ gcl.end_tp = helper.add(gcl.end_tp, bills.end_gather_tp);
|
|
|
+ gcl.end_contract_tp = helper.add(gcl.end_contract_tp, bills.end_contract_tp);
|
|
|
+ gcl.end_qc_tp = helper.add(gcl.end_qc_tp, bills.end_qc_tp);
|
|
|
}
|
|
|
- gcl.contract_jl = helper.add(gcl.contract_jl, bills.contract_jl);
|
|
|
- gcl.qc_jl = helper.add(gcl.qc_jl, bills.qc_jl);
|
|
|
- gcl.jl = helper.add(gcl.jl, bills.jl);
|
|
|
}
|
|
|
_calculateBwBillsIm(im) {
|
|
|
const tp_decimal = this.ctx.tender.info.decimal.tp;
|
|
@@ -522,10 +579,7 @@ class StageIm {
|
|
|
|
|
|
const im = this._getBwBillsPosIm(nodeImData, node, peg, nodeIndex, bw, pp.name);
|
|
|
|
|
|
- this._addBwBillsGclBills(im, {
|
|
|
- b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
|
|
|
- jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty
|
|
|
- });
|
|
|
+ this._addBwBillsGclBills(im, p, pp);
|
|
|
|
|
|
for (const c of this.changes) {
|
|
|
if (c.lid === p.id && c.pid == pp.id && c.qty && c.qty !== 0) {
|
|
@@ -546,21 +600,13 @@ class StageIm {
|
|
|
imDefault.contract_jl = this.ctx.helper.add(imDefault.contract_jl, p.contract_qty);
|
|
|
imDefault.qc_jl = this.ctx.helper.add(imDefault.qc_jl, p.qc_qty);
|
|
|
|
|
|
- this._addBwBillsGclBills(imDefault, {
|
|
|
- b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
|
|
|
- jl: p.gather_qty, contract_jl: p.contract_qty, qc_jl: p.qc_jl,
|
|
|
- });
|
|
|
+ this._addBwBillsGclBills(imDefault, p);
|
|
|
}
|
|
|
}
|
|
|
if (imDefault.contract_jl || imDefault.qc_jl) {
|
|
|
imDefault.jl = this.ctx.helper.add(imDefault.contract_jl, imDefault.qc_jl);
|
|
|
imDefault.id = this.ImData.length + 1;
|
|
|
this.ImData.push(imDefault);
|
|
|
- for (const b of imDefault.imBills) {
|
|
|
- b.imid = imDefault.id;
|
|
|
- this.ImBillsData.push(b);
|
|
|
- }
|
|
|
- delete imDefault.imBills;
|
|
|
}
|
|
|
for (const im of nodeImData) {
|
|
|
this._calculateBwBillsIm(im);
|
|
@@ -568,11 +614,6 @@ class StageIm {
|
|
|
im.position = this.ctx.helper._.uniq(im.position).join(mergeChar);
|
|
|
im.id = this.ImData.length + 1;
|
|
|
this.ImData.push(im);
|
|
|
- for (const b of im.imBills) {
|
|
|
- b.imid = im.id;
|
|
|
- this.ImBillsData.push(b);
|
|
|
- }
|
|
|
- delete im.imBills;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -745,7 +786,7 @@ class StageIm {
|
|
|
end_jl: pp.end_gather_qty, end_contract_jl: pp.end_contract_qty, end_qc_jl: pp.end_qc_qty,
|
|
|
bw,
|
|
|
peg: this._checkPeg(pp.name) ? this._getPegStr(pp.name) : (peg ? this._getPegStr(peg.name) : ''),
|
|
|
- xm: pp.name,
|
|
|
+ xm: pp.name, jldy: pp.name,
|
|
|
drawing_code: pp.drawing_code,
|
|
|
changes: [],
|
|
|
position: pp.position,
|
|
@@ -787,7 +828,7 @@ class StageIm {
|
|
|
end_tp: p.end_gather_tp, end_contract_tp: p.end_contract_tp, end_qc_tp: p.end_qc_tp,
|
|
|
bw,
|
|
|
peg: peg ? this._getPegStr(peg.name) : '',
|
|
|
- xm: node.name,
|
|
|
+ xm: node.name, jldy: node.name,
|
|
|
drawing_code: this._getDrawingCode(p),
|
|
|
changes: [],
|
|
|
position: '',
|