|
@@ -975,41 +975,73 @@ class checkData {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- _checkPosOverRange(p) {
|
|
|
+ _checkPosOverRangeTz(p, coe) {
|
|
|
const end_contract_qty = this.ctx.helper.add(p.pre_contract_qty, p.contract_qty);
|
|
|
- if (!p.quantity) return !!end_contract_qty;
|
|
|
- return p.quantity > 0
|
|
|
- ? end_contract_qty > p.final_1_qty
|
|
|
- : (p.final_1_qty > 0 ? true : end_contract_qty < p.final_1_qty || end_contract_qty > 0);
|
|
|
+ const base_qty = p.quantity;
|
|
|
+ const compare_qty = this.ctx.helper.mul(p.final_1_qty, coe);
|
|
|
+ if (!base_qty) return !!end_contract_qty;
|
|
|
+ return base_qty > 0
|
|
|
+ ? end_contract_qty > compare_qty
|
|
|
+ : (compare_qty > 0 ? true : end_contract_qty < compare_qty || end_contract_qty > 0);
|
|
|
}
|
|
|
- _checkBillsOverRange(bills, posRange, isTz) {
|
|
|
- if (isTz && posRange.length > 0) {
|
|
|
- for (const p of posRange) {
|
|
|
- if (this._checkPosOverRange(p)) return true;
|
|
|
- }
|
|
|
+ _checkPosOverRange(p, checkInfo) {
|
|
|
+ const checkTz = checkInfo.checkTz ? this._checkPosOverRangeTz(p, checkInfo.coe) : false;
|
|
|
+ const checkDeal = false;
|
|
|
+ return checkTz || checkDeal;
|
|
|
+ }
|
|
|
+ _checkBillsOverRangeTz(bills, coe) {
|
|
|
+ const end_contract_qty = this.ctx.helper.add(bills.contract_qty, bills.pre_contract_qty);
|
|
|
+ const end_contract_tp = this.ctx.helper.add(bills.contract_tp, bills.pre_contract_tp);
|
|
|
+ if (bills.is_tp) {
|
|
|
+ const base_tp = bills.total_price;
|
|
|
+ const compare_tp = this.ctx.helper.mul(base_tp, coe);
|
|
|
+ if (!base_tp) return !!end_contract_tp;
|
|
|
+ return base_tp >= 0 ? end_contract_tp > compare_tp : end_contract_tp < compare_tp || end_contract_tp > 0;
|
|
|
+ } else {
|
|
|
+ const base_qty = bills.quantity;
|
|
|
+ const compare_qty = this.ctx.helper.mul(bills.final_1_qty, coe);
|
|
|
+ if (!base_qty) return !!end_contract_qty;
|
|
|
+ return base_qty > 0
|
|
|
+ ? end_contract_qty > compare_qty
|
|
|
+ : (compare_qty > 0 ? true : end_contract_qty < compare_qty || end_contract_qty > 0);
|
|
|
}
|
|
|
+ }
|
|
|
+ _checkBillsOverRangeDeal(bills, coe) {
|
|
|
const end_contract_qty = this.ctx.helper.add(bills.contract_qty, bills.pre_contract_qty);
|
|
|
const end_contract_tp = this.ctx.helper.add(bills.contract_tp, bills.pre_contract_tp);
|
|
|
if (bills.is_tp) {
|
|
|
- const compare_tp = isTz ? bills.total_price : bills.deal_tp;
|
|
|
- if (!compare_tp) return !!end_contract_tp;
|
|
|
- return compare_tp >= 0 ? end_contract_tp > compare_tp : end_contract_tp < compare_tp || end_contract_tp > 0;
|
|
|
+ const base_tp = bills.deal_tp;
|
|
|
+ const compare_tp = this.ctx.helper.mul(base_tp, coe);
|
|
|
+ if (!base_tp) return !!end_contract_tp;
|
|
|
+ return base_tp >= 0 ? end_contract_tp > compare_tp : end_contract_tp < compare_tp || end_contract_tp > 0;
|
|
|
} else {
|
|
|
- const compare_qty1 = isTz ? bills.quantity : bills.deal_qty;
|
|
|
- const compare_qty2 = isTz ? bills.final_1_qty : bills.deal_final_1_qty;
|
|
|
- if (!compare_qty1) return !!end_contract_qty;
|
|
|
- return compare_qty1 > 0
|
|
|
- ? end_contract_qty > compare_qty2
|
|
|
- : (compare_qty2 > 0 ? true : end_contract_qty < compare_qty2 || end_contract_qty > 0);
|
|
|
+ const base_qty = bills.deal_qty;
|
|
|
+ const compare_qty = this.ctx.helper.mul(bills.deal_final_1_qty, coe);
|
|
|
+ if (!base_qty) return !!end_contract_qty;
|
|
|
+ return base_qty > 0
|
|
|
+ ? end_contract_qty > compare_qty
|
|
|
+ : (compare_qty > 0 ? true : end_contract_qty < compare_qty || end_contract_qty > 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _checkBillsOverRange(bills, posRange, checkInfo) {
|
|
|
+ if (checkInfo.hasPosCheckPos && posRange.length > 0) {
|
|
|
+ for (const p of posRange) {
|
|
|
+ if (this._checkPosOverRange(p, checkInfo)) return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (checkInfo.hasPosCheckBills || posRange.length === 0) {
|
|
|
+ const checkTz = checkInfo.checkTz ? this._checkBillsOverRangeTz(bills, checkInfo.coe) : false;
|
|
|
+ const checkDeal = checkInfo.checkDeal ? this._checkBillsOverRangeDeal(bills, checkInfo.coe) : false;
|
|
|
+ return checkTz || checkDeal;
|
|
|
}
|
|
|
+ return false;
|
|
|
}
|
|
|
- checkOverRange() {
|
|
|
- const isTz = this.ctx.tender.data.measure_type === this.measureType.tz.value;
|
|
|
+ checkOverRange(checkInfo) {
|
|
|
for (const b of this.checkBills.nodes) {
|
|
|
if (b.children && b.children.length > 0) continue;
|
|
|
const pr = this.checkPos.getLedgerPos(b.id) || [];
|
|
|
|
|
|
- if (this._checkBillsOverRange(b, pr, isTz)) {
|
|
|
+ if (this._checkBillsOverRange(b, pr, checkInfo)) {
|
|
|
this.checkResult.error.push({
|
|
|
ledger_id: b.ledger_id,
|
|
|
b_code: b.b_code,
|