|
@@ -204,14 +204,14 @@ module.exports = app => {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- async getTpData(transaction, materialId) {
|
|
|
+ async getTpData(transaction, materialId, decimal = (this.ctx.material.decimal ? this.ctx.material.decimal : materialConst.decimal)) {
|
|
|
const materialInfo = await transaction.get(this.ctx.service.material.tableName, { id: materialId });
|
|
|
const tp_data = {
|
|
|
- m_tp: materialInfo.m_tp !== null ? this.ctx.helper.round(materialInfo.m_tp, this.ctx.material.decimal.tp) : null,
|
|
|
+ m_tp: materialInfo.m_tp !== null ? this.ctx.helper.round(materialInfo.m_tp, decimal.tp) : null,
|
|
|
tax_tp: materialInfo.material_tax ? (materialInfo.m_tax_tp ? materialInfo.m_tax_tp : materialInfo.m_tp) :
|
|
|
- (materialInfo.m_tp !== null ? this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), this.ctx.material.decimal.tp) : null),
|
|
|
- ex_tp: materialInfo.ex_tp !== null ? this.ctx.helper.round(materialInfo.ex_tp, this.ctx.material.decimal.tp) : null,
|
|
|
- ex_tax_tp: materialInfo.ex_tp !== null ? this.ctx.helper.round(this.ctx.helper.mul(materialInfo.ex_tp, 1+materialInfo.exponent_rate/100), this.ctx.material.decimal.tp) : null,
|
|
|
+ (materialInfo.m_tp !== null ? this.ctx.helper.round(this.ctx.helper.mul(materialInfo.m_tp, 1+materialInfo.rate/100), decimal.tp) : null),
|
|
|
+ ex_tp: materialInfo.ex_tp !== null ? this.ctx.helper.round(materialInfo.ex_tp, decimal.tp) : null,
|
|
|
+ ex_tax_tp: materialInfo.ex_tp !== null ? this.ctx.helper.round(this.ctx.helper.mul(materialInfo.ex_tp, 1+materialInfo.exponent_rate/100), decimal.tp) : null,
|
|
|
}
|
|
|
tp_data.total_tp = this.ctx.helper.add(tp_data.m_tp, tp_data.ex_tp);
|
|
|
tp_data.total_tax_tp = !materialInfo.material_tax ? this.ctx.helper.add(tp_data.tax_tp, tp_data.ex_tax_tp) : tp_data.ex_tax_tp;
|
|
@@ -223,8 +223,8 @@ module.exports = app => {
|
|
|
id: ms.id,
|
|
|
sid: ms.sid,
|
|
|
order: ms.order,
|
|
|
- m_tp: this.ctx.helper.round(ms.m_tp, this.ctx.material.decimal.tp),
|
|
|
- m_tax_tp: this.ctx.helper.round(ms.m_tax_tp, this.ctx.material.decimal.tp),
|
|
|
+ m_tp: this.ctx.helper.round(ms.m_tp, decimal.tp),
|
|
|
+ m_tax_tp: this.ctx.helper.round(ms.m_tax_tp, decimal.tp),
|
|
|
});
|
|
|
}
|
|
|
tp_data.stage_tp = stage_tp;
|