|
@@ -19,7 +19,7 @@ class BillsPosConvert {
|
|
|
this.ctx = ctx;
|
|
|
this._ = this.ctx.helper._;
|
|
|
|
|
|
- this.tpFields = ['total_price', 'contract_tp', 'qc_tp', 'gather_tp',
|
|
|
+ this.tpFields = ['total_price', 'contract_tp', 'qc_tp', 'gather_tp', 'contract_pc_tp', 'qc_pc_tp', 'pc_tp',
|
|
|
'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp'];
|
|
|
this.baseCalcFields = ['quantity', 'contract_qty', 'qc_qty', 'gather_qty',
|
|
|
'pre_contract_qty', 'pre_qc_qty', 'pre_gather_qty', 'end_contract_qty', 'end_qc_qty', 'end_gather_qty'];
|
|
@@ -85,6 +85,8 @@ class BillsPosConvert {
|
|
|
node.quantity = this.ctx.helper.add(node.quantity, data.quantity);
|
|
|
node.total_price = this.ctx.helper.add(node.total_price, this.ctx.helper.mul(node.unit_price, data.quantity, tpDecimal));
|
|
|
|
|
|
+ const org_price = node.org_price || node.unit_price;
|
|
|
+
|
|
|
node.contract_qty = this.ctx.helper.add(node.contract_qty, data.contract_qty);
|
|
|
node.contract_tp = this.ctx.helper.add(node.contract_tp, this.ctx.helper.mul(node.unit_price, data.contract_qty, tpDecimal));
|
|
|
node.qc_qty = this.ctx.helper.add(node.qc_qty, data.qc_qty);
|
|
@@ -92,9 +94,9 @@ class BillsPosConvert {
|
|
|
node.gather_qty = this.ctx.helper.add(node.gather_qty, data.gather_qty);
|
|
|
|
|
|
node.pre_contract_qty = this.ctx.helper.add(node.pre_contract_qty, data.pre_contract_qty);
|
|
|
- node.pre_contract_tp = this.ctx.helper.add(node.pre_contract_tp, this.ctx.helper.mul(node.unit_price, data.pre_contract_qty, tpDecimal));
|
|
|
+ node.pre_contract_tp = this.ctx.helper.add(node.pre_contract_tp, this.ctx.helper.mul(org_price, data.pre_contract_qty, tpDecimal));
|
|
|
node.pre_qc_qty = this.ctx.helper.add(node.pre_qc_qty, data.pre_qc_qty);
|
|
|
- node.pre_qc_tp = this.ctx.helper.add(node.pre_qc_tp, this.ctx.helper.mul(node.unit_price, data.pre_qc_qty, tpDecimal));
|
|
|
+ node.pre_qc_tp = this.ctx.helper.add(node.pre_qc_tp, this.ctx.helper.mul(org_price, data.pre_qc_qty, tpDecimal));
|
|
|
node.pre_gather_qty = this.ctx.helper.add(node.pre_gather_qty, data.pre_gather_qty);
|
|
|
|
|
|
node.real_qty = this.ctx.helper.add(node.real_qty, data.real_qty);
|
|
@@ -111,6 +113,7 @@ class BillsPosConvert {
|
|
|
node.qc_qty = this.ctx.helper.add(node.qc_qty, data.qc_qty);
|
|
|
node.qc_tp = this.ctx.helper.add(node.qc_tp, data.qc_tp);
|
|
|
node.gather_qty = this.ctx.helper.add(node.gather_qty, data.gather_qty);
|
|
|
+ node.gather_tp = this.ctx.helper.add(node.gather_tp, data.gather_tp);
|
|
|
|
|
|
node.pre_contract_qty = this.ctx.helper.add(node.pre_contract_qty, data.pre_contract_qty);
|
|
|
node.pre_contract_tp = this.ctx.helper.add(node.pre_contract_tp, data.pre_contract_tp);
|
|
@@ -142,7 +145,7 @@ class BillsPosConvert {
|
|
|
if (p.ex_memo3) posUnit.ex_memo3.push(p.ex_memo3);
|
|
|
|
|
|
const gclUnit = xmj.unitTree.addNode({pos_name: '',
|
|
|
- b_code: node.b_code, name: node.name, unit: node.unit, unit_price: node.unit_price
|
|
|
+ b_code: node.b_code, name: node.name, unit: node.unit, unit_price: node.unit_price, org_price: node.org_price,
|
|
|
}, posUnit);
|
|
|
if (node.drawing_code && gclUnit.drawing_code.indexOf(node.drawing_code) < 0)
|
|
|
gclUnit.drawing_code.push(node.drawing_code);
|
|
@@ -164,7 +167,7 @@ class BillsPosConvert {
|
|
|
} else {
|
|
|
const unit = xmj.unitTree.addNode({
|
|
|
pos_name: '',
|
|
|
- b_code: node.b_code, name: node.name, unit: node.unit, unit_price: node.unit_price,
|
|
|
+ b_code: node.b_code, name: node.name, unit: node.unit, unit_price: node.unit_price, org_price: node.org_price,
|
|
|
});
|
|
|
if (node.drawing_code && unit.drawing_code.indexOf(node.drawing_code) < 0)
|
|
|
unit.drawing_code.push(node.drawing_code);
|
|
@@ -248,12 +251,24 @@ class BillsPosConvert {
|
|
|
child.final_1_tp = this.ctx.helper.mul(child.unit_price, child.final_1_qty, tpDecimal);
|
|
|
child.end_final_1_tp = this.ctx.helper.add(child.final_1_tp, child.end_qc_tp);
|
|
|
child.end_final_1_percent = this.ctx.helper.mul(this.ctx.helper.div(child.end_gather_tp, child.end_final_1_tp, 4), 100);
|
|
|
+
|
|
|
+ const priceDiff = child.org_price ? this.ctx.helper.sub(child.unit_price, child.org_price) : 0;
|
|
|
+ if (priceDiff && (child.pre_contract_qty || child.pre_qc_qty)) {
|
|
|
+ child.contract_pc_tp = this.ctx.helper.sub(this.ctx.helper.mul(child.unit_price, child.pre_contract_qty, this.ctx.tender.info.decimal.tp), child.pre_contract_tp);
|
|
|
+ child.qc_pc_tp = this.ctx.helper.sub(this.ctx.helper.mul(child.unit_price, child.pre_qc_qty, this.ctx.tender.info.decimal.tp), child.pre_qc_tp);
|
|
|
+ child.pc_tp = this.ctx.helper.add(child.contract_pc_tp, child.qc_pc_tp);
|
|
|
+ child.gather_tp = this.ctx.helper.add(child.gather_tp, child.pc_tp);
|
|
|
+ child.end_contract_tp = this.ctx.helper.add(child.end_contract_tp, child.contract_pc_tp);
|
|
|
+ child.end_qc_tp = this.ctx.helper.add(child.end_qc_tp, child.qc_pc_tp);
|
|
|
+ child.end_gather_tp = this.ctx.helper.add(child.end_contract_tp, child.end_qc_tp);
|
|
|
+ }
|
|
|
}
|
|
|
_calculateNode(node, children) {
|
|
|
for (const child of children) {
|
|
|
node.total_price = this.ctx.helper.add(node.total_price, child.total_price);
|
|
|
node.contract_tp = this.ctx.helper.add(node.contract_tp, child.contract_tp);
|
|
|
node.qc_tp = this.ctx.helper.add(node.qc_tp, child.qc_tp);
|
|
|
+ node.pc_tp = this.ctx.helper.add(node.pc_tp, child.pc_tp);
|
|
|
node.gather_tp = this.ctx.helper.add(node.gather_tp, child.gather_tp);
|
|
|
node.pre_contract_tp = this.ctx.helper.add(node.pre_contract_tp, child.pre_contract_tp);
|
|
|
node.pre_qc_tp = this.ctx.helper.add(node.pre_qc_tp, child.pre_qc_tp);
|
|
@@ -372,7 +387,7 @@ class BillsPosConvert {
|
|
|
switch (filter) {
|
|
|
case 'cur':
|
|
|
return this._getResultData(function (node) {
|
|
|
- for (const field of ['contract_tp', 'qc_tp', 'gather_tp']) {
|
|
|
+ for (const field of ['contract_tp', 'qc_tp', 'gather_tp', 'contract_pc_tp', 'qc_pc_tp', 'pc_tp']) {
|
|
|
if (node[field]) {
|
|
|
return false;
|
|
|
}
|