Parcourir la source

超计判断调整

MaiXinRong il y a 4 ans
Parent
commit
7ca8250ecd
4 fichiers modifiés avec 67 ajouts et 71 suppressions
  1. 53 20
      app/extend/helper.js
  2. 12 8
      app/public/js/global.js
  3. 1 24
      app/public/js/ledger_check.js
  4. 1 19
      app/public/js/stage.js

+ 53 - 20
app/extend/helper.js

@@ -1191,31 +1191,64 @@ module.exports = {
     },
 
     checkBillsOverRange(bills, posRange, isTz) {
-        if (isTz && posRange.length > 0) {
-            for (const p of posRange) {
-                const end_contract_qty = this.add(p.pre_contract_qty, p.contract_qty);
-                if (end_contract_qty > p.quantity) return true;
+        // if (isTz && posRange.length > 0) {
+        //     for (const p of posRange) {
+        //         const end_contract_qty = this.add(p.pre_contract_qty, p.contract_qty);
+        //         if (end_contract_qty > p.quantity) return true;
+        //     }
+        //     return false;
+        // } else {
+        //     const end_qc_qty = this.add(bills.qc_qty, bills.pre_qc_qty);
+        //     const end_qc_tp = this.add(bills.qc_tp, bills.pre_qc_tp);
+        //     const end_gather_qty = this.sum([bills.contract_qty, bills.pre_contract_qty, end_qc_qty]);
+        //     const end_gather_tp = this.sum([bills.contract_tp, bills.pre_contract_tp, end_qc_tp]);
+        //     if (isTz) {
+        //         if (end_gather_qty) {
+        //             return !bills.quantity || Math.abs(end_gather_qty) > Math.abs(this.add(bills.quantity, end_qc_qty));
+        //         } else if (end_gather_tp) {
+        //             return !bills.total_price || Math.abs(end_gather_tp) > Math.abs(this.add(bills.total_price, end_qc_tp));
+        //         }
+        //     } else {
+        //         if (end_gather_qty) {
+        //             return !bills.deal_qty || Math.abs(end_gather_qty) > Math.abs(this.add(bills.deal_qty, end_qc_qty));
+        //         } else if (end_gather_tp) {
+        //             return !bills.deal_tp || Math.abs(end_gather_tp) > Math.abs(this.add(bills.deal_tp, end_qc_tp));
+        //         }
+        //     }
+        // }
+        if (!bills) return false;
+        if (isTz) {
+            if (posRange.length > 0) {
+                for (const p of posRange) {
+                    if (checkUtils.posOver(p)) return true;
+                }
+                return false;
+            }
+            if (bills.is_tp) {
+                if (!bills.total_price) return !!bills.end_contract_tp;
+                return bills.total_price >= 0
+                    ? bills.end_contract_tp > bills.total_price
+                    : bills.end_contract_tp < bills.total_price || bills.end_contract_tp > 0;
+            } else {
+                if (!bills.quantity) return !!bills.end_contract_qty;
+                return bills.quantity >= 0
+                    ? bills.end_contract_qty > bills.quantity
+                    : bills.end_contract_qty < bills.quantity || bills.end_contract_qty > 0;
             }
-            return false;
         } else {
-            const end_qc_qty = this.add(bills.qc_qty, bills.pre_qc_qty);
-            const end_qc_tp = this.add(bills.qc_tp, bills.pre_qc_tp);
-            const end_gather_qty = this.sum([bills.contract_qty, bills.pre_contract_qty, end_qc_qty]);
-            const end_gather_tp = this.sum([bills.contract_tp, bills.pre_contract_tp, end_qc_tp]);
-            if (isTz) {
-                if (end_gather_qty) {
-                    return !bills.quantity || Math.abs(end_gather_qty) > Math.abs(this.add(bills.quantity, end_qc_qty));
-                } else if (end_gather_tp) {
-                    return !bills.total_price || Math.abs(end_gather_tp) > Math.abs(this.add(bills.total_price, end_qc_tp));
-                }
+            if (bills.is_tp) {
+                if (!bills.deal_tp) return !!bills.end_contract_tp;
+                return bills.deal_tp >= 0
+                    ? bills.end_contract_tp > bills.deal_tp
+                    : bills.end_contract_tp < bills.deal_tp || bills.end_contract_tp > 0;
             } else {
-                if (end_gather_qty) {
-                    return !bills.deal_qty || Math.abs(end_gather_qty) > Math.abs(this.add(bills.deal_qty, end_qc_qty));
-                } else if (end_gather_tp) {
-                    return !bills.deal_tp || Math.abs(end_gather_tp) > Math.abs(this.add(bills.deal_tp, end_qc_tp));
-                }
+                if (!bills.deal_qty) return !!bills.end_contract_qty;
+                return bills.deal_qty >= 0
+                    ? bills.end_contract_qty > bills.deal_qty
+                    : bills.end_contract_qty < bills.deal_qty || bills.end_contract_qty > 0;
             }
         }
+
     },
 
     checkBillsWithPos2(bills, pos, fields, checkOver, isTz) {

+ 12 - 8
app/public/js/global.js

@@ -878,22 +878,26 @@ const checkUtils = {
             }
             if (data.is_tp) {
                 if (!data.total_price) return !!data.end_contract_tp;
-                return data.total_price >= 0
-                    ? data.end_contract_tp > data.total_price : data.end_contract_tp < data.total_price;
+                return data.total_price > 0
+                    ? data.end_contract_tp > data.total_price
+                    : data.end_contract_tp < data.total_price || data.end_contract_tp > 0;
             } else {
                 if (!data.quantity) return !!data.end_contract_qty;
-                return data.quantity >= 0
-                    ? data.end_contract_qty > data.quantity : data.end_contract_qty < data.quantity;
+                return data.quantity > 0
+                    ? data.end_contract_qty > data.quantity
+                    : data.end_contract_qty < data.quantity || data.end_contract_qty > 0;
             }
         } else {
             if (data.is_tp) {
                 if (!data.deal_tp) return !!data.end_contract_tp;
-                return data.deal_tp >= 0
-                    ? data.end_contract_tp > data.deal_tp : data.end_contract_tp < data.deal_tp;
+                return data.deal_tp > 0
+                    ? data.end_contract_tp > data.deal_tp
+                    : data.end_contract_tp < data.deal_tp || data.end_contract_tp > 0;
             } else {
                 if (!data.deal_qty) return !!data.end_contract_qty;
-                return data.deal_qty >= 0
-                    ? data.end_contract_qty > data.deal_qty : data.end_contract_qty < data.deal_qty;
+                return data.deal_qty > 0
+                    ? data.end_contract_qty > data.deal_qty
+                    : data.end_contract_qty < data.deal_qty || data.end_contract_tp > 0;
             }
         }
     }

+ 1 - 24
app/public/js/ledger_check.js

@@ -102,30 +102,7 @@ const ledgerCheckUtil = {
         for (const node of ledgerTree.nodes) {
             if (node.children && node.children.length > 0) continue;
 
-            if (option.isTz) {
-                const posRange = ledgerPos.getLedgerPos(node.id) || [];
-                if (posRange.length > 0) {
-                    for (const p of posRange) {
-                        if (p.end_contract_qty > p.quantity) {
-                            error.push(node);
-                            continue;
-                        }
-                    }
-                }
-            }
-            if (node.is_tp) {
-                if (option.isTz) {
-                    if (node.end_contract_tp > node.total_price) error.push(node);
-                } else {
-                    if (node.end_contract_tp > node.deal_tp) error.push(node);
-                }
-            } else {
-                if (option.isTz) {
-                    if (node.end_contract_qty > node.quantity) error.push(node);
-                } else {
-                    if (node.end_contract_qty > node.deal_qty) error.push(node);
-                }
-            }
+            if (checkUtils.billsOver(node, option.isTz, ledgerPos)) error.push(node);
         }
         return error;
     },

+ 1 - 19
app/public/js/stage.js

@@ -3541,25 +3541,7 @@ $(document).ready(() => {
                         }, {
                             key: 'over', title: '超计', valid: true,
                             check: function (node) {
-                                if (checkTzMeasureType()) {
-                                    const posRange = stagePos.ledgerPos[itemsPre + node.id] || [];
-                                    if (posRange.length > 0) {
-                                        for (const p of posRange) {
-                                            if (p.end_contract_qty > p.quantity) return true;
-                                        }
-                                        return false;
-                                    } else if (node.end_gather_qty) {
-                                        return !node.quantity || Math.abs(node.end_gather_qty) > Math.abs(ZhCalc.add(node.quantity, node.end_qc_qty));
-                                    } else if (node.end_gather_tp) {
-                                        return !node.total_price || Math.abs(node.end_gather_tp) > Math.abs(ZhCalc.add(node.total_price, node.end_qc_tp));
-                                    }
-                                } else {
-                                    if (node.end_gather_qty) {
-                                        return !node.deal_qty || Math.abs(node.end_gather_qty) > Math.abs(ZhCalc.add(node.deal_qty, node.end_qc_qty));
-                                    } else if (node.end_gather_tp) {
-                                        return !node.deal_tp || Math.abs(node.end_gather_tp) > Math.abs(ZhCalc.add(node.deal_tp, node.end_qc_tp));
-                                    }
-                                }
+                                return checkUtils.billsOver(node, checkTzMeasureType(), stagePos);
                             }
                         }, {
                             key: 'empty', title: '漏计', valid: false,