瀏覽代碼

fix:审核、修改时判断收款金额是否超过了已收款金额

ly 9 月之前
父節點
當前提交
8372a31e9e
共有 1 個文件被更改,包括 92 次插入3 次删除
  1. 92 3
      src/views/business/financial/collection/form.vue

+ 92 - 3
src/views/business/financial/collection/form.vue

@@ -419,7 +419,7 @@
     getCollection,
     getCollectionByContract,
     saveCollection,
-    verifyCollection, setCollectionZero,
+    verifyCollection, setCollectionZero, getCollectionDetail,
   } from "@/api/business/financial/collection";
   import { listSource } from "@/api/settings/source";
   import { listCompany } from "@/api/business/crm/company";
@@ -431,6 +431,7 @@
   import { ref } from "vue";
 
   import useUserStore from "@/store/modules/user";
+  import match from "@/utils/match";
   const { proxy } = getCurrentInstance();
   const baseUrl = import.meta.env.VITE_APP_BASE_API;
 
@@ -583,7 +584,51 @@
   }
 
   /** 提交按钮 */
-  function submitForm() {
+  async function submitForm() {
+    // 应收款金额  和明细比较 如果大于应收内容 提示 当前的合同提过的收款申请总金额超过当前合同金额,不可提交,如有需要请跟财务人员联系
+    const res = await getCollectionDetail(form.value.contractId);
+    if (res.data == null || res.data.length == 0) {
+      const amount = form.value.arriveAmount;
+      if (amount > form.value.contractAmount) {
+        proxy.$modal.msgError("当前的合同提过的收款申请总金额超过当前合同金额,不可提交,请联系财务人员。");
+        return false;
+      }
+      for (let i = 0; i < form.value.details.length; i++) {
+        let item = form.value.details[i];
+        if (item.arriveAmount != null && item.amount < item.arriveAmount) {
+          proxy.$modal.msgError("当前的" + item.taskTypeName + "收款申请总金额超过当前服务金额,不可提交,请联系财务人员。");
+          return false;
+        }
+      }
+    } else {
+      const countAmount = res.data.map((item) => item.arriveAmount).reduce((total, number) => {
+        return total + number;
+      });
+      const amount = countAmount + form.value.arriveAmount;
+      if (amount > form.value.contractAmount) {
+        proxy.$modal.msgError("当前的合同提过的收款申请总金额超过当前合同金额,不可提交,请联系财务人员。");
+        return false;
+      }
+      for (let i = 0; i < form.value.details.length; i++) {
+        let item = form.value.details[i];
+        let countAmount = 0;
+        for (let j = 0; j < res.data.length; j++) {
+          let match = res.data[j];
+          if (item.taskTypeId == match.taskTypeId) {
+            countAmount += match.arriveAmount;
+          }
+        }
+        if (item.amount < match.add(item.arriveAmount, countAmount)) {
+          proxy.$modal.msgError("当前的" + item.taskTypeName + "收款申请总金额超过当前服务金额,不可提交,请联系财务人员。");
+          return false;
+        }
+      }
+    }
+
+    if (form.value.arriveAmount > form.value.contractAmount) {
+      proxy.$modal.msgError("实际收款金额不能大于合同收款金额");
+      return;
+    }
     proxy.$refs["orderRef"].validate((valid) => {
       if (valid && detailValid()) {
         const formValue = form.value;
@@ -647,7 +692,7 @@
     }
   }
 
-  function verifyUpload() {
+  async function verifyUpload() {
     // const formValue = proxy.deepClone(form.value);
     // formValue.verifyStatus = status;
     // formValue.status = status;
@@ -675,6 +720,50 @@
     //   proxy.$modal.msgError("请上传凭证并至多上传5个");
     //   return;
     // }
+    // 应收款金额  和明细比较 如果大于应收内容 提示 当前的合同提过的收款申请总金额超过当前合同金额,不可提交,如有需要请跟财务人员联系
+    const res = await getCollectionDetail(form.value.contractId);
+    if (res.data == null || res.data.length == 0) {
+      const amount = form.value.arriveAmount;
+      if (amount > form.value.contractAmount) {
+        proxy.$modal.msgError("当前的合同提过的收款申请总金额超过当前合同金额,不可提交,请联系财务人员。");
+        return false;
+      }
+      for (let i = 0; i < form.value.details.length; i++) {
+        let item = form.value.details[i];
+        if (item.arriveAmount != null && item.amount < item.arriveAmount) {
+          proxy.$modal.msgError("当前的" + item.taskTypeName + "收款申请总金额超过当前服务金额,不可提交,请联系财务人员。");
+          return false;
+        }
+      }
+    } else {
+      const countAmount = res.data.map((item) => item.arriveAmount).reduce((total, number) => {
+        return total + number;
+      });
+      const amount = countAmount + form.value.arriveAmount;
+      if (amount > form.value.contractAmount) {
+        proxy.$modal.msgError("当前的合同提过的收款申请总金额超过当前合同金额,不可提交,请联系财务人员。");
+        return false;
+      }
+      for (let i = 0; i < form.value.details.length; i++) {
+        let item = form.value.details[i];
+        let countAmount = 0;
+        for (let j = 0; j < res.data.length; j++) {
+          let match = res.data[j];
+          if (item.taskTypeId == match.taskTypeId) {
+            countAmount += match.arriveAmount;
+          }
+        }
+        if (item.amount < match.add(item.arriveAmount, countAmount)) {
+          proxy.$modal.msgError("当前的" + item.taskTypeName + "收款申请总金额超过当前服务金额,不可提交,请联系财务人员。");
+          return false;
+        }
+      }
+    }
+
+    if (form.value.arriveAmount > form.value.contractAmount) {
+      proxy.$modal.msgError("实际收款金额不能大于合同收款金额");
+      return;
+    }
     form.value.status = form.value.verifyStatus;
     form.value.arriveStatus = form.value.status === 1 ? 1 : 0;
     verifyCollection(form.value).then((res) => {