浏览代码

安全生产费,用户输入金额时,反算单价

MaiXinRong 2 周之前
父节点
当前提交
6a14da6160
共有 2 个文件被更改,包括 5 次插入2 次删除
  1. 1 1
      app/public/js/payment_safe.js
  2. 4 1
      app/service/payment_safe_bills.js

+ 1 - 1
app/public/js/payment_safe.js

@@ -32,7 +32,7 @@ $(document).ready(function() {
                     {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', cellType: 'unit'},
                     {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 80, type: 'Number'},
                     {title: '本期|数量', colSpan: '2|1', rowSpan: '1|1', field: 'cur_qty', hAlign: 2, width: 80, type: 'Number'},
-                    {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'cur_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
+                    {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'cur_tp', hAlign: 2, width: 80, type: 'Number'},
                     {title: '截止本期|数量', colSpan: '2|1', rowSpan: '1|1', field: 'end_qty', hAlign: 2, width: 80, type: 'Number'},
                     {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'end_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true},
                     {title: '发票号', colSpan: '1', rowSpan: '2', field: 'invoice_code', hAlign: 0, width: 100, formatter: '@'},

+ 4 - 1
app/service/payment_safe_bills.js

@@ -483,7 +483,10 @@ module.exports = app => {
                 if (row.cur_qty !== undefined || row.unit_price !== undefined || row.cur_tp !== undefined) {
                     nData.unit_price = row.unit_price !== undefined ? helper.round(row.unit_price, decimal.up) : oData.unit_price;
                     nData.cur_qty = row.cur_qty !== undefined ? helper.round(row.cur_qty, decimal.qty) : oData.cur_qty;
-                    nData.cur_tp = row.cur_tp !== undefined ? helper.round(row.cur_tp, decimal.tp) : helper.mul(nData.unit_price, nData.cur_qty, decimal.tp);
+                    if (row.cur_tp !== undefined && row.unit_price === undefined) {
+                        nData.unit_price = nData.cur_qty ? helper.div(row.cur_tp, nData.cur_qty, decimal.up) : 0;
+                    }
+                    nData.cur_tp = helper.mul(nData.unit_price, nData.cur_qty, decimal.tp);
                     nData.end_qty = helper.add(nData.cur_qty, oData.pre_qty);
                     nData.end_tp = helper.add(nData.cur_tp, oData.pre_tp);
                 }