浏览代码

合同支付,允许删除质量保证金、扣回开工预付款

MaiXinRong 6 年之前
父节点
当前提交
c1dd48ec9a
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      app/service/pay.js

+ 5 - 2
app/service/pay.js

@@ -29,7 +29,10 @@ module.exports = app => {
          * @returns {Promise<boolean>}
          */
         async addDefaultPayData(tid, transaction) {
+            const existPays = this.getAllDataByCondition({tid: tid});
             const pays = JSON.parse(JSON.stringify(payConst.payTemplate));
+            if (existPays.length >= pays.length) { return false; }
+
             for (const p of pays) {
                 p.tid = tid;
                 p.csid = 0;
@@ -104,8 +107,8 @@ module.exports = app => {
             const pay = await this.getDataByCondition({id: id});
             if (!pay) {
                 throw '合同支付项不存在';
-            } else if (pay.uid === -1) {
-                throw '默认合同支付项不可删除';
+            } else if (pay.ptype !== payConst.payType.normal) {
+                throw '合同支付项不可删除';
             }
             // 删除合同支付
             const transaction = await this.db.beginTransaction();