|
@@ -525,30 +525,50 @@ module.exports = app => {
|
|
|
const returnData = {};
|
|
|
returnData.m_tp = this.ctx.material.m_tp;
|
|
|
if (this.ctx.material.is_stage_self) {
|
|
|
+ if (!data.ms_id) throw '参数有误';
|
|
|
const mbInfo = await this.getDataById(data.id);
|
|
|
- let all_m_tp = 0;
|
|
|
- let all_tax_tp = 0;
|
|
|
- for (const sid of this.ctx.material.stage_id.split(',')) {
|
|
|
- const materialCalculator = new MaterialCalculator(this.ctx, sid, this.ctx.tender.info);
|
|
|
- const quantity = await materialCalculator.calculateExpr(data.expr);
|
|
|
- const msInfo = await this.ctx.service.materialStage.getDataByCondition({ mid: this.ctx.material.id, sid });
|
|
|
- const msbInfo = await this.ctx.service.materialStageBills.getDataByCondition({ mid: this.ctx.material.id, mb_id: data.id, ms_id: msInfo.id });
|
|
|
- const newQuantity = quantity !== 0 ? this.ctx.helper.round(quantity, this.ctx.material.decimal.qty) : null;
|
|
|
- const m_tp = newQuantity ? this.ctx.helper.round(this.ctx.helper.mul(newQuantity, msbInfo.m_spread), this.ctx.material.decimal.tp) : null;
|
|
|
- const updateData = {
|
|
|
- id: data.id,
|
|
|
- quantity: newQuantity,
|
|
|
- m_tp,
|
|
|
- m_tax_tp: this.ctx.helper.round(this.ctx.helper.mul(m_tp, (1 + this.ctx.helper.div(mbInfo.m_tax, 100))), this.ctx.material.decimal.tp),
|
|
|
- };
|
|
|
- const [one_bill_m_tp, one_bill_tax_tp] = await this.ctx.service.materialStageBills.update(transaction, updateData, msInfo.id);
|
|
|
- await this.ctx.service.materialStage.updateMtp(transaction, msInfo.id);
|
|
|
- all_m_tp = this.ctx.helper.round(one_bill_m_tp, this.ctx.material.decimal.tp);
|
|
|
- all_tax_tp = this.ctx.helper.round(one_bill_tax_tp, this.ctx.material.decimal.tp);
|
|
|
- }
|
|
|
- const updateBillsData = {
|
|
|
+ const msInfo = await this.ctx.service.materialStage.getDataById(data.ms_id);
|
|
|
+ const msbInfo = await this.ctx.service.materialStageBills.getDataByCondition({ mid: this.ctx.material.id, mb_id: data.id, ms_id: data.ms_id });
|
|
|
+ // let all_m_tp = 0;
|
|
|
+ // let all_tax_tp = 0;
|
|
|
+ const materialCalculator = new MaterialCalculator(this.ctx, msInfo.sid, this.ctx.tender.info);
|
|
|
+ const quantity = await materialCalculator.calculateExpr(data.expr);
|
|
|
+ const newQuantity = quantity !== 0 ? this.ctx.helper.round(quantity, this.ctx.material.decimal.qty) : null;
|
|
|
+ const m_tp = newQuantity ? this.ctx.helper.round(this.ctx.helper.mul(newQuantity, msbInfo.m_spread), this.ctx.material.decimal.tp) : null;
|
|
|
+ const updateData = {
|
|
|
id: data.id,
|
|
|
+ quantity: newQuantity,
|
|
|
expr: data.expr,
|
|
|
+ m_tp,
|
|
|
+ m_tax_tp: this.ctx.helper.round(this.ctx.helper.mul(m_tp, (1 + this.ctx.helper.div(mbInfo.m_tax, 100))), this.ctx.material.decimal.tp),
|
|
|
+ };
|
|
|
+ const [one_bill_m_tp, one_bill_tax_tp] = await this.ctx.service.materialStageBills.update(transaction, updateData, msInfo.id);
|
|
|
+ await this.ctx.service.materialStage.updateMtp(transaction, msInfo.id);
|
|
|
+ const all_m_tp = this.ctx.helper.round(one_bill_m_tp, this.ctx.material.decimal.tp);
|
|
|
+ const all_tax_tp = this.ctx.helper.round(one_bill_tax_tp, this.ctx.material.decimal.tp);
|
|
|
+
|
|
|
+ // for (const sid of this.ctx.material.stage_id.split(',')) {
|
|
|
+ // const materialCalculator = new MaterialCalculator(this.ctx, sid, this.ctx.tender.info);
|
|
|
+ // const quantity = await materialCalculator.calculateExpr(data.expr);
|
|
|
+ // const msInfo = await this.ctx.service.materialStage.getDataByCondition({ mid: this.ctx.material.id, sid });
|
|
|
+ // const msbInfo = await this.ctx.service.materialStageBills.getDataByCondition({ mid: this.ctx.material.id, mb_id: data.id, ms_id: msInfo.id });
|
|
|
+ // const newQuantity = quantity !== 0 ? this.ctx.helper.round(quantity, this.ctx.material.decimal.qty) : null;
|
|
|
+ // const m_tp = newQuantity ? this.ctx.helper.round(this.ctx.helper.mul(newQuantity, msbInfo.m_spread), this.ctx.material.decimal.tp) : null;
|
|
|
+ // const updateData = {
|
|
|
+ // id: data.id,
|
|
|
+ // quantity: newQuantity,
|
|
|
+ // m_tp,
|
|
|
+ // m_tax_tp: this.ctx.helper.round(this.ctx.helper.mul(m_tp, (1 + this.ctx.helper.div(mbInfo.m_tax, 100))), this.ctx.material.decimal.tp),
|
|
|
+ // };
|
|
|
+ // const [one_bill_m_tp, one_bill_tax_tp] = await this.ctx.service.materialStageBills.update(transaction, updateData, msInfo.id);
|
|
|
+ // await this.ctx.service.materialStage.updateMtp(transaction, msInfo.id);
|
|
|
+ // all_m_tp = this.ctx.helper.round(one_bill_m_tp, this.ctx.material.decimal.tp);
|
|
|
+ // all_tax_tp = this.ctx.helper.round(one_bill_tax_tp, this.ctx.material.decimal.tp);
|
|
|
+ // }
|
|
|
+
|
|
|
+ const updateBillsData = {
|
|
|
+ id: data.id,
|
|
|
+ // expr: data.expr,
|
|
|
m_tp: all_m_tp ? all_m_tp : null,
|
|
|
m_tax_tp: all_tax_tp ? all_tax_tp : null,
|
|
|
};
|