|
@@ -59,7 +59,7 @@ module.exports = app => {
|
|
|
insertArray.push(one_month);
|
|
|
if (monthList.length !== 0) {
|
|
|
const mb_msg_tp_sum = this._.sumBy(this._.filter(monthList, { mb_id: mb.id }), 'msg_tp');
|
|
|
- const month_num = material_month.length - this.ctx.helper.arrayCount(this._.concat(this._.map(this._.filter(monthList, { mb_id: mb.id }), 'msg_tp'), one_month.msg_tp), null);
|
|
|
+ const month_num = material_month.length - this.ctx.helper.arrayCount(this._.concat(this._.map(this._.filter(monthList, { mb_id: mb.id }), 'msg_tp'), one_month.msg_tp), [null, '', 0]);
|
|
|
const new_msg_tp = this.ctx.helper.round(this.ctx.helper.div(this.ctx.helper.add(mb_msg_tp_sum, one_month.msg_tp), month_num), 3);
|
|
|
const [newmsg_spread, newm_spread] = await this.ctx.service.materialBills.getSpread(mb, new_msg_tp);
|
|
|
updateArray.push({
|
|
@@ -107,7 +107,7 @@ module.exports = app => {
|
|
|
return data.indexOf(m.yearmonth) !== -1;
|
|
|
});
|
|
|
const mb_msg_tp_sum = this._.sumBy(this._.filter(monthList, { mb_id: mb.id }), 'msg_tp');
|
|
|
- const month_num = material_month.length - this.ctx.helper.arrayCount(this._.map(this._.filter(monthList, { mb_id: mb.id }), 'msg_tp'), null);
|
|
|
+ const month_num = material_month.length - this.ctx.helper.arrayCount(this._.map(this._.filter(monthList, { mb_id: mb.id }), 'msg_tp'), [null, '', 0]);
|
|
|
const new_msg_tp = month_num !== 0 ? this.ctx.helper.round(this.ctx.helper.div(mb_msg_tp_sum, month_num), 3) : null;
|
|
|
const [newmsg_spread, newm_spread] = await this.ctx.service.materialBills.getSpread(mb, new_msg_tp);
|
|
|
updateArray.push({
|
|
@@ -146,9 +146,8 @@ module.exports = app => {
|
|
|
const monthList = await transaction.select(this.tableName, { where: { mb_id: data.mb_id, mid: this.ctx.material.id } });
|
|
|
const mbInfo = await transaction.get(this.ctx.service.materialBills.tableName, { id: data.mb_id });
|
|
|
if (monthList.length !== 0) {
|
|
|
- console.log(monthList);
|
|
|
const mb_msg_tp_sum = this._.sumBy(monthList, 'msg_tp');
|
|
|
- const month_num = material_month.length - this.ctx.helper.arrayCount(this._.map(monthList, 'msg_tp'), null);
|
|
|
+ const month_num = material_month.length - this.ctx.helper.arrayCount(this._.map(monthList, 'msg_tp'), [null, '', 0]);
|
|
|
const new_msg_tp = month_num !== 0 ? this.ctx.helper.round(this.ctx.helper.div(mb_msg_tp_sum, month_num), 3) : null;
|
|
|
const [newmsg_spread, newm_spread] = await this.ctx.service.materialBills.getSpread(mbInfo, new_msg_tp);
|
|
|
await transaction.update(this.ctx.service.materialBills.tableName, {
|
|
@@ -200,7 +199,7 @@ module.exports = app => {
|
|
|
const mbUpdateArray = [];
|
|
|
for (const mb of mbList) {
|
|
|
const mb_msg_tp_sum = this._.sumBy(this._.filter(monthList, { mb_id: mb.id }), 'msg_tp');
|
|
|
- const month_num = material_month.length - this.ctx.helper.arrayCount(this._.map(this._.filter(monthList, { mb_id: mb.id }), 'msg_tp'), null);
|
|
|
+ const month_num = material_month.length - this.ctx.helper.arrayCount(this._.map(this._.filter(monthList, { mb_id: mb.id }), 'msg_tp'), [null, '', 0]);
|
|
|
const new_msg_tp = month_num !== 0 ? this.ctx.helper.round(this.ctx.helper.div(mb_msg_tp_sum, month_num), 3) : null;
|
|
|
const [newmsg_spread, newm_spread] = await this.ctx.service.materialBills.getSpread(mb, new_msg_tp);
|
|
|
mbUpdateArray.push({
|