|
@@ -343,7 +343,7 @@ const stageIm = (function () {
|
|
|
const posRange = gsPos.getLedgerPos(node.id);
|
|
|
if (!posRange) { return }
|
|
|
for (const p of posRange) {
|
|
|
- if (!p.gather_qty || checkZero(p.gather_qty)) { continue; }
|
|
|
+ if (checkZero(p.contract_qty) && checkZero(p.qc_qty)) { continue; }
|
|
|
let lp = _.find(gclBills.pos, {name: p.name});
|
|
|
if (!lp) {
|
|
|
lp = {name: p.name};
|
|
@@ -362,7 +362,8 @@ const stageIm = (function () {
|
|
|
if ((!p.b_code || p.b_code === '') || (p.children && p.children.length > 0)) {
|
|
|
continue;
|
|
|
}
|
|
|
- if ((!p.contract_tp || p.contract_tp === 0) && (!p.qc_tp || p.qc_tp === 0)) {
|
|
|
+ if (checkZero(p.contract_qty) && checkZero(p.contract_tp) &&
|
|
|
+ checkZero(p.qc_qty) && checkZero(p.qc_tp)) {
|
|
|
continue;
|
|
|
}
|
|
|
let b = _.find(im.gclBills, {bid: p.id});
|
|
@@ -416,12 +417,40 @@ const stageIm = (function () {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ function checkUsed(node) {
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ const posterity = gsTree.getPosterity(node);
|
|
|
+ for (const p of posterity) {
|
|
|
+ if (p.children && p.children.length > 0) continue;
|
|
|
+ if (!checkZero(p.contract_qty) || !checkZero(p.contract_tp) ||
|
|
|
+ !checkZero(p.qc_qty) || !checkZero(p.qc_tp))
|
|
|
+ return true;
|
|
|
+ const pPos = gsPos.getLedgerPos(p.id);
|
|
|
+ if (!pPos || pPos.length === 0) continue;
|
|
|
+ for (const pp of pPos) {
|
|
|
+ if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty)) return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ if (!checkZero(node.contract_qty) || !checkZero(node.contract_tp) ||
|
|
|
+ !checkZero(node.qc_qty) || !checkZero(node.qc_tp))
|
|
|
+ return true;
|
|
|
+ const pPos = gsPos.getLedgerPos(node.id);
|
|
|
+ if (!pPos || pPos.length === 0) return false;
|
|
|
+ for (const pp of pPos) {
|
|
|
+ if (!checkZero(pp.contract_qty) || !checkZero(pp.qc_qty)) return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 生成 0号台账 中间计量数据
|
|
|
* @param {Object} node - 生成中间计量表的节点
|
|
|
*/
|
|
|
function generateTzImData (node) {
|
|
|
- if (node.gather_tp) {
|
|
|
+ if (checkUsed(node)) {
|
|
|
const nodeIndex = gsTree.getNodeIndex(node);
|
|
|
const peg = getPegNode(node);
|
|
|
const im = {
|
|
@@ -476,7 +505,7 @@ const stageIm = (function () {
|
|
|
im.jl = ZhCalc.add(im.contract_jl, im.qc_jl);
|
|
|
}
|
|
|
function generateBwBillsImData (node) {
|
|
|
- if (node.gather_tp) {
|
|
|
+ if (checkUsed(node)) {
|
|
|
const nodeIndex = gsTree.getNodeIndex(node);
|
|
|
const peg = getPegNode(node);
|
|
|
const nodeImData = [], posterity = gsTree.getPosterity(node);
|
|
@@ -496,11 +525,11 @@ const stageIm = (function () {
|
|
|
for (const p of posterity) {
|
|
|
if (p.children && p.children.length > 0) continue;
|
|
|
if (!p.b_code || p.b_code === '') continue;
|
|
|
- if (!p.gather_tp || p.gather_tp === 0) continue;
|
|
|
+ if (!checkUsed(p)) continue;
|
|
|
const pPos = gsPos.getLedgerPos(p.id);
|
|
|
if (pPos && pPos.length > 0) {
|
|
|
for (const pp of pPos) {
|
|
|
- if (!pp.gather_qty && !pp.contract_qty && !pp.qc_qty) continue;
|
|
|
+ if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty)) continue;
|
|
|
let im = nodeImData.find(function (d) {
|
|
|
return d.lid === node.id && d.pos_name === pp.name;
|
|
|
});
|
|
@@ -545,6 +574,7 @@ const stageIm = (function () {
|
|
|
|
|
|
imDefault.contract_jl = ZhCalc.add(imDefault.contract_jl, p.contract_tp);
|
|
|
imDefault.qc_jl = ZhCalc.add(imDefault.qc_jl, p.qc_tp);
|
|
|
+ imDefault.used = true;
|
|
|
|
|
|
addBwBillsGclBills(imDefault, {
|
|
|
b_code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price,
|
|
@@ -552,7 +582,7 @@ const stageIm = (function () {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- if (imDefault.contract_jl || imDefault.qc_jl) {
|
|
|
+ if (imDefault.used) {
|
|
|
imDefault.jl = ZhCalc.add(imDefault.contract_jl, imDefault.qc_jl);
|
|
|
ImData.push(imDefault);
|
|
|
}
|
|
@@ -642,7 +672,7 @@ const stageIm = (function () {
|
|
|
for (const p of posterity) {
|
|
|
if (p.children && p.children.length > 0 ) { continue; }
|
|
|
if (!p.b_code || p.b_code === '') { continue }
|
|
|
- if (!p.gather_tp || p.gather_tp === 0) { continue; }
|
|
|
+ if (!checkUsed(p)) { continue; }
|
|
|
let im = nodeImData.find(function (d) {
|
|
|
return d.lid === node.id &&
|
|
|
d.code === p.b_code && p.name === d.name && p.unit === d.unit && checkZero(ZhCalc.sub(p.unit_price, d.unit_price));
|
|
@@ -693,7 +723,7 @@ const stageIm = (function () {
|
|
|
if (pPos && pPos.length > 0) {
|
|
|
const nodeIndex = gsTree.getNodeIndex(node);
|
|
|
for (const pp of pPos) {
|
|
|
- if ((!pp.contract_qty || pp.contract_qty === 0) && (!pp.qc_qty || pp.qc_qty === 0)) { continue }
|
|
|
+ if (checkZero(pp.contract_qty) && checkZero(pp.qc_qty)) { continue }
|
|
|
const im = {
|
|
|
lid: node.id, code: p.b_code, name: p.name, unit: p.unit, unit_price: p.unit_price, pid: pp.id,
|
|
|
jl: pp.gather_qty, contract_jl: pp.contract_qty, qc_jl: pp.qc_qty,
|