浏览代码

本期未计量清单,原单价记录问题

MaiXinRong 2 年之前
父节点
当前提交
9a7985e10f
共有 4 个文件被更改,包括 17 次插入13 次删除
  1. 3 3
      app/lib/revise_price.js
  2. 8 4
      app/service/stage_bills_final.js
  3. 1 1
      app/service/stage_change.js
  4. 5 5
      sql/update.sql

+ 3 - 3
app/lib/revise_price.js

@@ -66,7 +66,7 @@ class revisePriceCalc {
             node.positive_qc_pc_tp = helper.mul(priceDiff, node.pre_positive_qc_qty, decimal.tp);
             node.negative_qc_pc_tp = helper.mul(priceDiff, node.pre_negative_qc_qty, decimal.tp);
             result.ibData.push({
-                tid: newStage.tid, sid: newStage.id, sorder: newStage.order, lid: node.id, org_price: node.pre_unit_price,
+                tid: newStage.tid, sid: newStage.id, sorder: newStage.order, lid: node.id, org_price: node.pre_unit_price, unit_price: node.unit_price,
                 contract_pc_tp: node.contract_pc_tp, qc_pc_tp: node.qc_pc_tp, pc_tp: node.pc_tp,
                 positive_qc_pc_tp: node.positive_qc_pc_tp, negative_qc_pc_tp: node.negative_qc_pc_tp,
             });
@@ -137,7 +137,7 @@ class revisePriceCalc {
                 node.positive_qc_pc_tp = helper.mul(priceDiff, node.pre_positive_qc_qty, decimal.tp);
                 node.negative_qc_pc_tp = helper.mul(priceDiff, node.pre_negative_qc_qty, decimal.tp);
                 result.bpcData.push({
-                    tid: stage.tid, sid: stage.id, sorder: stage.order, lid: node.id, org_price: node.pre_unit_price,
+                    tid: stage.tid, sid: stage.id, sorder: stage.order, lid: node.id, org_price: node.pre_unit_price, unit_price: node.unit_price,
                     contract_pc_tp: node.contract_pc_tp, qc_pc_tp: node.qc_pc_tp, pc_tp: node.pc_tp,
                     positive_qc_pc_tp: node.positive_qc_pc_tp, negative_qc_pc_tp: node.negative_qc_pc_tp,
                 });
@@ -254,7 +254,7 @@ class revisePriceCalc {
             }
             if (node.pre_id) {
                 result.bpcData.push({
-                    tid: stage.tid, sid: stage.id, sorder: stage.order, lid: node.id, org_price: node.pre_unit_price,
+                    tid: stage.tid, sid: stage.id, sorder: stage.order, lid: node.id, org_price: node.pre_unit_price, unit_price: node.unit_price,
                     contract_pc_tp: node.contract_pc_tp, qc_pc_tp: node.qc_pc_tp, pc_tp: node.pc_tp,
                     positive_qc_pc_tp: node.positive_qc_pc_tp, negative_qc_pc_tp: node.negative_qc_pc_tp,
                 });

+ 8 - 4
app/service/stage_bills_final.js

@@ -90,7 +90,7 @@ module.exports = app => {
                     return x.lid === c.lid;
                 });
                 if (p) {
-                    c.unit_price = p.org_price;
+                    c.unit_price = p.unit_price;
                     c.contract_qty = this.ctx.helper.add(c.contract_qty, p.contract_qty);
                     c.contract_tp = this.ctx.helper.add(c.contract_tp, p.contract_tp);
                     c.qc_qty = this.ctx.helper.add(c.qc_qty, p.qc_qty);
@@ -109,12 +109,12 @@ module.exports = app => {
                 }
                 const cp = curPc.find(x => { return x.lid === c.lid; });
                 if (cp) {
-                    c.unit_price = cp.org_price;
+                    c.unit_price = cp.unit_price;
                     c.contract_tp = this.ctx.helper.add(c.contract_tp, cp.contract_pc_tp);
                     c.qc_tp = this.ctx.helper.add(c.qc_tp, cp.qc_pc_tp);
                     curPc.splice(curPc.indexOf(cp), 1);
                 }
-                if (!c.org_price) {
+                if (!c.unit_price) {
                     const bills = await this.ctx.service.ledger.getDataById(c.lid);
                     c.unit_price = bills ? bills.unit_price || 0 : 0;
                 }
@@ -126,11 +126,15 @@ module.exports = app => {
                 p.sorder = stage.order;
                 const cp = curPc.find(x => { return x.lid === p.lid; });
                 if (cp) {
-                    p.unit_price = cp.org_price;
+                    p.unit_price = cp.unit_price;
                     p.contract_tp = this.ctx.helper.add(p.contract_tp, cp.contract_pc_tp);
                     p.qc_tp = this.ctx.helper.add(p.qc_tp, cp.qc_pc_tp);
                     curPc.splice(curPc.indexOf(cp), 1);
                 }
+                if (!p.unit_price) {
+                    const bills = await this.ctx.service.ledger.getDataById(c.lid);
+                    p.unit_price = bills ? bills.unit_price || 0 : 0;
+                }
             }
             await transaction.delete(this.tableName, { tid: tender.id, sid: stage.id });
             await transaction.insert(this.tableName, cur ? cur.concat(pre) : pre);

+ 1 - 1
app/service/stage_change.js

@@ -415,7 +415,7 @@ module.exports = app => {
                 const nc = this._.find(oldChanges, { cid: c.cid, cbid: c.cbid });
                 if (!nc) {
                     const change = getNewChange(c.cid, c.cbid, this.ctx.stage.curTimes, this.ctx.stage.curOrder, this.round(c.qty, precision.value), c.minus, noValue);
-                    change.unit_price;
+                    change.unit_price = ledgerBills.unit_price;
                     posQty = this.ctx.helper.add(posQty, change.qty);
                     if (change.minus) {
                         posNegativeQty = this.ctx.helper.add(posNegativeQty, change.qty);

+ 5 - 5
sql/update.sql

@@ -86,12 +86,16 @@ CREATE TABLE `zh_stage_bills_pc` (
   `tid` int(11) unsigned NOT NULL COMMENT '标段id',
   `sid` int(11) NOT NULL,
   `lid` varchar(36) COLLATE utf8_unicode_ci NOT NULL COMMENT '项目节id',
+  `org_price` decimal(24,8) NOT NULL DEFAULT 0 COMMENT '原单价',
+  `unit_price` decimal(24,8) NOT NULL DEFAULT 0 COMMENT '本期单价',
   `contract_pc_tp` decimal(24,8) NOT NULL DEFAULT 0 COMMENT '本期补差(合同)',
   `qc_pc_tp` decimal(24,8) NOT NULL DEFAULT 0 COMMENT '本期补差(变更)',
   `pc_tp` decimal(24,8) NOT NULL DEFAULT 0 COMMENT '本期补差',
+  `positive_qc_pc_tp` decimal(24,8) NOT NULL DEFAULT 0 COMMENT '本期补差(正变更)',
+  `negative_qc_pc_tp` decimal(24,8) NOT NULL DEFAULT 0 COMMENT '本期补差(负变更)',
   PRIMARY KEY (`id`),
   KEY `idx_sid` (`sid`) USING BTREE
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='期-项目节-补差数据';
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='期-补差数据';
 
 ALTER TABLE `zh_stage_bills_final_0`
 ADD COLUMN `unit_price`  decimal(24,8) UNSIGNED NOT NULL DEFAULT 0 COMMENT '本期单价' AFTER `contract_expr`,
@@ -474,10 +478,6 @@ ALTER TABLE `zh_stage_pos_final_19`
 ADD COLUMN `positive_qc_qty`  decimal(24,8) NOT NULL DEFAULT 0 AFTER `qc_minus_qty`,
 ADD COLUMN `negative_qc_qty`  decimal(24,8) NOT NULL DEFAULT 0 AFTER `positive_qc_qty`;
 
-ALTER TABLE `zh_stage_bills_pc`
-ADD COLUMN `positive_qc_pc_tp`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '本期补差(正变更)' AFTER `pc_tp`,
-ADD COLUMN `negative_qc_pc_tp`  decimal(24,8) NOT NULL DEFAULT 0 COMMENT '本期补差(负变更)' AFTER `positive_qc_pc_tp`;
-
 ALTER TABLE `zh_stage`
 ADD COLUMN `positive_qc_tp`  decimal(24,8) NULL DEFAULT 0 COMMENT '本期-正-变更金额' AFTER `his_id`,
 ADD COLUMN `pre_positive_qc_tp`  decimal(24,8) NULL DEFAULT 0 COMMENT '截止上期-正-变更金额' AFTER `positive_qc_tp`,