소스 검색

变更申请,变更方案金额计算

MaiXinRong 3 년 전
부모
커밋
d16eed3151
3개의 변경된 파일54개의 추가작업 그리고 5개의 파일을 삭제
  1. 0 1
      app/controller/tender_controller.js
  2. 30 4
      app/service/report_memory.js
  3. 24 0
      builder_report_index_define.js

+ 0 - 1
app/controller/tender_controller.js

@@ -1418,7 +1418,6 @@ module.exports = app => {
         async saveRelaData(ctx) {
             try {
                 const data = JSON.parse(ctx.request.body.data);
-                console.log(data);
                 const responseData = { err: 0, msg: '', data: {} };
                 if (data.change) await this.ctx.service.change.updateChangeSelect(data.change);
                 if (data.change_apply) await this.ctx.service.changeApply.defaultUpdateRows(data.change_apply);

+ 30 - 4
app/service/report_memory.js

@@ -843,16 +843,23 @@ module.exports = app => {
         async _generateChangeApply(tid) {
             if (!!this.changeApplyData) return;
             const helper = this.ctx.helper;
+            const decimal = this.ctx.tender.info.decimal;
             const where = { tid };
             if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
             const apply = await this.ctx.service.changeApply.getAllDataByCondition({ where });
             const bills = await this.ctx.service.changeApplyList.getChangeBills(tid, this.ctx.session.sessionProject.page_show.isOnlyChecked);
+            bills.forEach(x => {
+                const a = apply.find(y => { return y.id === x.caid });
+                const a_decimal = a.decimal ? JSON.stringify(a.decimal) : { tp: decimal.tp, up: decimal.up };
+                x.o_tp = helper.mul(x.oamount, x.unit_price, a_decimal.tp);
+                x.c_tp = helper.mul(x.camount, x.unit_price, a_decimal.tp);
+            });
             bills.sort(function(a, b ) {
                 const aCIndex = apply.findIndex(function (c) {
-                    return c.cid === a.cid;
+                    return c.id === a.caid;
                 });
                 const bCIndex = apply.findIndex(function (c) {
-                    return c.cid === b.cid;
+                    return c.id === b.caid;
                 });
                 return aCIndex === bCIndex
                     ? helper.compareCode(a.code, b.code)
@@ -904,17 +911,36 @@ module.exports = app => {
         async _generateChangePlan(tid) {
             if (!!this.changePlanData) return;
             const helper = this.ctx.helper;
+            const decimal = this.ctx.tender.info.decimal;
             this.changePlanData = {};
             const where = { tid };
             if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
             const data = await this.ctx.service.changePlan.getAllDataByCondition({ where });
             const bills = await this.ctx.service.changePlanList.getChangeBills(tid, this.ctx.session.sessionProject.page_show.isOnlyChecked);
+            bills.forEach(x => {
+                const plan = data.find(y => { return y.id === x.cpid });
+                const p_decimal = plan.decimal ? JSON.stringify(plan.decimal) : { tp: decimal.tp, up: decimal.up };
+                x.o_tp = helper.mul(x.oamount, x.unit_price, p_decimal.tp);
+                x.c_tp = helper.mul(x.camount, x.unit_price, p_decimal.tp);
+                x.s_tp = helper.mul(x.samount, x.unit_price, p_decimal.tp);
+                x.sp_tp = helper.mul(x.spamount, x.unit_price, p_decimal.tp);
+
+                const auditAmount = x.audit_amount ? x.audit_amount.split(',') : [];
+                for (const [i, aa] of auditAmount.entries()) {
+                    const amountField = 'qty_' + (i+1), tpField = 'tp_' + (i+1);
+                    x[amountField] = aa ? parseFloat(aa) : 0;
+                    x[tpField] = helper.mul(x[amountField], x.unit_price, p_decimal.tp);
+                    if (plan) {
+                        plan[tpField] = helper.add(plan[tpField], x[tpField]);
+                    }
+                }
+            });
             bills.sort(function(a, b ) {
                 const aCIndex = data.findIndex(function (c) {
-                    return c.cid === a.cid;
+                    return c.id === a.cpid;
                 });
                 const bCIndex = data.findIndex(function (c) {
-                    return c.cid === b.cid;
+                    return c.id === b.cpid;
                 });
                 return aCIndex === bCIndex
                     ? helper.compareCode(a.code, b.code)

+ 24 - 0
builder_report_index_define.js

@@ -449,6 +449,8 @@ const change_apply_bills = {
         { name: '单价', field: 'unit_price', type: dataType.currency },
         { name: '原数量', field: 'oamount', type: dataType.currency },
         { name: '变更数量', field: 'camount', type: dataType.currency },
+        { name: '原金额', field: 'o_tp', type: dataType.currency },
+        { name: '变更金额', field: 'c_tp', type: dataType.currency },
     ]
 };
 
@@ -521,6 +523,28 @@ const change_plan_bills = {
         { name: '审批完成后变更数量', field: 'samount', type: dataType.currency },
         { name: '用户填的数目, json', field: 'audit_amount', type: dataType.str },
         { name: '审批流程中读取数量', field: 'spamount', type: dataType.currency },
+        { name: '原金额', field: 'o_tp', type: dataType.currency },
+        { name: '变更金额', field: 'c_tp', type: dataType.currency },
+        { name: '审批完成后变更金额', field: 's_tp', type: dataType.currency },
+        { name: '审批流程中读取金额', field: 'sp_tp', type: dataType.currency },
+        { name: '数量_1', field: 'qty_1', type: dataType.currency },
+        { name: '金额_1', field: 'tp_1', type: dataType.currency },
+        { name: '数量_2', field: 'qty_2', type: dataType.currency },
+        { name: '金额_2', field: 'tp_2', type: dataType.currency },
+        { name: '数量_3', field: 'qty_3', type: dataType.currency },
+        { name: '金额_3', field: 'tp_3', type: dataType.currency },
+        { name: '数量_4', field: 'qty_4', type: dataType.currency },
+        { name: '金额_4', field: 'tp_4', type: dataType.currency },
+        { name: '数量_5', field: 'qty_5', type: dataType.currency },
+        { name: '金额_5', field: 'tp_5', type: dataType.currency },
+        { name: '数量_6', field: 'qty_6', type: dataType.currency },
+        { name: '金额_6', field: 'tp_6', type: dataType.currency },
+        { name: '数量_7', field: 'qty_7', type: dataType.currency },
+        { name: '金额_7', field: 'tp_7', type: dataType.currency },
+        { name: '数量_8', field: 'qty_8', type: dataType.currency },
+        { name: '金额_8', field: 'tp_8', type: dataType.currency },
+        { name: '数量_9', field: 'qty_9', type: dataType.currency },
+        { name: '金额_9', field: 'tp_9', type: dataType.currency },
     ]
 };