소스 검색

fix(contractReview): 移除提交审核后的return语句以触发后续操作,新增发票判读开票金额是否一致

liujt 4 달 전
부모
커밋
3f5f85acaa

+ 0 - 1
src/views/contractManage/contractReview/components/addDialog.vue

@@ -729,7 +729,6 @@ this.postOptions.push(...response.data);
             businessType: this.form.categoryName 
           }
         });
-        return
         this.$message('提交审核成功');
         this.$emit('reload');
         this.cancel();

+ 47 - 49
src/views/financialManage/invoiceManage/components/tableInfoNew.vue

@@ -495,65 +495,49 @@
        */
       allocateInvoiceAmount(data) {
         if (Array.isArray(data)) {
-          // 处理数组
           data.forEach(item => {
             if (item && typeof item === 'object') {
-              let remainingTotal = Number(item.amountTotalPrice) || 0;
-              const details = item.details || [];
-              
-              // 按顺序分配金额
-              details.forEach((detail) => {
-                if (remainingTotal <= 0) {
-                  // 剩余金额为0,分配0
-                  detail.invoiceAmount = 0;
-                } else {
-                  // 获取当前明细的unInvoiceAmount
-                  const unInvoiceAmount = Number(detail.unInvoiceAmount) || 0;
-                  
-                  if (remainingTotal > unInvoiceAmount) {
-                    // 剩余金额大于unInvoiceAmount,分配unInvoiceAmount
-                    detail.invoiceAmount = unInvoiceAmount;
-                    remainingTotal -= unInvoiceAmount;
-                  } else {
-                    // 剩余金额小于等于unInvoiceAmount,分配剩余金额
-                    detail.invoiceAmount = remainingTotal;
-                    remainingTotal = 0;
-                  }
-                }
-              });
+              this.allocateSingleInvoiceAmount(item);
             }
           });
           return data;
         } else if (data && typeof data === 'object') {
-          // 处理单个对象
-          let remainingTotal = Number(data.amountTotalPrice) || 0;
-          const details = data.details || [];
-          
-          // 按顺序分配金额
-          details.forEach((detail) => {
-            if (remainingTotal <= 0) {
-              // 剩余金额为0,分配0
-              detail.invoiceAmount = 0;
-            } else {
-              // 获取当前明细的unInvoiceAmount
-              const unInvoiceAmount = Number(detail.unInvoiceAmount) || 0;
-              
-              if (remainingTotal > unInvoiceAmount) {
-                // 剩余金额大于unInvoiceAmount,分配unInvoiceAmount
-                detail.invoiceAmount = unInvoiceAmount;
-                remainingTotal -= unInvoiceAmount;
-              } else {
-                // 剩余金额小于等于unInvoiceAmount,分配剩余金额
-                detail.invoiceAmount = remainingTotal;
-                remainingTotal = 0;
-              }
-            }
-          });
-          
+          this.allocateSingleInvoiceAmount(data);
           return data;
         }
         return data;
       },
+      allocateSingleInvoiceAmount(item) {
+        let remainingTotal = this.toPrecision(item.amountTotalPrice);
+        const details = item.details || [];
+        
+        details.forEach((detail) => {
+          if (remainingTotal <= 0) {
+            detail.invoiceAmount = 0;
+          } else {
+            const unInvoiceAmount = this.toPrecision(detail.unInvoiceAmount);
+            
+            if (remainingTotal > unInvoiceAmount) {
+              detail.invoiceAmount = this.fromPrecision(unInvoiceAmount);
+              remainingTotal = this.subPrecision(remainingTotal, unInvoiceAmount);
+            } else {
+              detail.invoiceAmount = this.fromPrecision(remainingTotal);
+              remainingTotal = 0;
+            }
+          }
+        });
+      },
+      toPrecision(value) {
+        const num = parseFloat(value) || 0;
+        return Math.round(num * 100);
+      },
+      fromPrecision(value) {
+        const num = parseFloat(value) || 0;
+        return (num / 100).toFixed(2);
+      },
+      subPrecision(a, b) {
+        return a - b;
+      },
 
       setSinglePrice(row, data) {
         let index = this.tableForm.detailList.findIndex(item => item.key == row.relatedOrderNo);
@@ -644,6 +628,20 @@
           // 3. 处理验证结果
           try {
             await Promise.all(validationPromises);
+            
+            // 4. 校验 amountTotalPrice 和 defaultAmountTotalPrice 是否相等
+            for (let i = 0; i < this.tableForm.detailList.length; i++) {
+              const item = this.tableForm.detailList[i];
+              const amountTotalPrice = parseFloat(item.amountTotalPrice) || 0;
+              const defaultAmountTotalPrice = parseFloat(item.defaultAmountTotalPrice) || 0;
+              
+              if (amountTotalPrice !== defaultAmountTotalPrice) {
+                this.$message.warning(`第${i + 1}条本次开票合计(${amountTotalPrice})必须等于本次开票金额合计(${defaultAmountTotalPrice})`);
+                reject(false);
+                return;
+              }
+            }
+            
             resolve(this.tableForm);
             console.log('this.tableForm~~~',this.tableForm);
           } catch (error) {