|
|
@@ -216,9 +216,9 @@ module.exports = app => {
|
|
|
orgDetail = await this.ctx.service.costStageDetail.getAllDataByCondition({ where: { stage_id: this.ctx.costStage.relaStage.id }});
|
|
|
for (const cd of detailCalcData) {
|
|
|
const nd = { id: cd.id, ledger_id: cd.ledger_id, detail_id: cd.detail_id };
|
|
|
- const cl = orgLedger.find(x => { return x.id === cd.ledger_id });
|
|
|
+ const cl = orgDetail.find(x => { return x.id === cd.ledger_id });
|
|
|
nd.in_tp = this.ctx.helper.round(cd.in_tp, decimal.tp);
|
|
|
- const divNum = cl.tax ? this.ctx.helper.add(1, this.ctx.helper.div(cl.tax, 100)) : 1;
|
|
|
+ const divNum = cl && cl.tax ? this.ctx.helper.add(1, this.ctx.helper.div(cl.tax, 100)) : 1;
|
|
|
nd.in_excl_tax_tp = this.ctx.helper.div(nd.in_tp !== undefined ? nd.in_tp : nd.in_tp, divNum, decimal.excl_tax_tp);
|
|
|
detailUpdateData.push(nd);
|
|
|
}
|
|
|
@@ -262,7 +262,7 @@ module.exports = app => {
|
|
|
detailUpdateData.forEach(u => {
|
|
|
u.book_id = u.id;
|
|
|
delete u.id;
|
|
|
- const cl = orgDetail.find(x => { return x.id === od.detail_id; });
|
|
|
+ const cl = orgDetail.find(x => { return x.id === u.detail_id; });
|
|
|
i.id = cl.id;
|
|
|
});
|
|
|
return { calc: calcTp, bills: updateData, detail: detailUpdateData };
|
|
|
@@ -270,4 +270,4 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
return CostStageBook;
|
|
|
-};
|
|
|
+};
|