fix: 合同小结计算理论重量,订单保存避免合同数据不全引发报错
This commit is contained in:
parent
ccabd6a849
commit
ecd4d560b2
@ -97,13 +97,13 @@ export const RecordSummary = observer((props): any => {
|
|||||||
if (form.values.category === RecordCategory.lease && !leaseItems) return;
|
if (form.values.category === RecordCategory.lease && !leaseItems) return;
|
||||||
if (form.values.category === RecordCategory.lease2lease && !inLeaseItems) return;
|
if (form.values.category === RecordCategory.lease2lease && !inLeaseItems) return;
|
||||||
const in_contract = form.values.category === RecordCategory.lease ? leaseItems.data : inLeaseItems.data;
|
const in_contract = form.values.category === RecordCategory.lease ? leaseItems.data : inLeaseItems.data;
|
||||||
const { ruleCalc } = summary(element, in_contract, reqWeightRules);
|
const { ruleCalc } = summary(element, in_contract, reqWeightRules, recordData);
|
||||||
contractWeight.total += ruleCalc.weight / 1000;
|
contractWeight.total += ruleCalc.weight / 1000;
|
||||||
calcProductCount(contractSummary, ruleCalc, productCategory);
|
calcProductCount(contractSummary, ruleCalc, productCategory);
|
||||||
if (form.values.category === RecordCategory.lease2lease && outLeaseItems) {
|
if (form.values.category === RecordCategory.lease2lease && outLeaseItems) {
|
||||||
// 还需要生成出库合同小结
|
// 还需要生成出库合同小结
|
||||||
const out_contract = outLeaseItems.data;
|
const out_contract = outLeaseItems.data;
|
||||||
const { ruleCalc } = summary(element, out_contract, reqWeightRules);
|
const { ruleCalc } = summary(element, out_contract, reqWeightRules, recordData);
|
||||||
outContractWeight.total += ruleCalc.weight / 1000;
|
outContractWeight.total += ruleCalc.weight / 1000;
|
||||||
calcProductCount(outContractSummary, ruleCalc, productCategory);
|
calcProductCount(outContractSummary, ruleCalc, productCategory);
|
||||||
}
|
}
|
||||||
@ -231,9 +231,9 @@ const summary = (event: RecordItems, rules: any[], ruleWeight: any, recordData =
|
|||||||
);
|
);
|
||||||
if (!cacheData) {
|
if (!cacheData) {
|
||||||
const weight =
|
const weight =
|
||||||
recordData.group_weight_items?.find((g) =>
|
recordData?.group_weight_items?.find((g) =>
|
||||||
g.product_categories?.find((pc) => pc.id === event.product?.category_id),
|
g.product_categories?.find((pc) => pc.id === event.product?.category_id),
|
||||||
)?.weight || recordData.weight;
|
)?.weight || recordData?.weight;
|
||||||
cache.push({
|
cache.push({
|
||||||
id: plain.conversion_logic_id,
|
id: plain.conversion_logic_id,
|
||||||
category_id: event.product?.category_id,
|
category_id: event.product?.category_id,
|
||||||
@ -258,10 +258,12 @@ const summary = (event: RecordItems, rules: any[], ruleWeight: any, recordData =
|
|||||||
: (event.count * weightRule.weight) / 1000;
|
: (event.count * weightRule.weight) / 1000;
|
||||||
ruleCalc.unit = '吨';
|
ruleCalc.unit = '吨';
|
||||||
}
|
}
|
||||||
|
// 合同理论重量,换算逻辑是重量表取重量表换算后的值(重量)
|
||||||
ruleCalc.weight = ruleCalc.count * 1000;
|
ruleCalc.weight = ruleCalc.count * 1000;
|
||||||
ruleCalc.price = ruleCalc.count * plain.unit_price;
|
ruleCalc.price = ruleCalc.count * plain.unit_price;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 合同理论重量,非重量表规则都是取产品重量
|
||||||
if (plain.conversion_logic_id <= 4) {
|
if (plain.conversion_logic_id <= 4) {
|
||||||
ruleCalc.price = ruleCalc.count * plain.unit_price;
|
ruleCalc.price = ruleCalc.count * plain.unit_price;
|
||||||
ruleCalc.weight = event.product.weight * event.count;
|
ruleCalc.weight = event.product.weight * event.count;
|
||||||
|
@ -527,9 +527,9 @@ export class RecordService {
|
|||||||
|
|
||||||
if (values.record_category === RecordTypes.rentInStock) {
|
if (values.record_category === RecordTypes.rentInStock) {
|
||||||
out_stock = contractProject.dataValues;
|
out_stock = contractProject.dataValues;
|
||||||
in_stock = associatedCompanyProject.dataValues;
|
in_stock = associatedCompanyProject?.dataValues;
|
||||||
} else {
|
} else {
|
||||||
out_stock = associatedCompanyProject.dataValues;
|
out_stock = associatedCompanyProject?.dataValues;
|
||||||
in_stock = contractProject.dataValues;
|
in_stock = contractProject.dataValues;
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
@ -545,13 +545,19 @@ export class RecordService {
|
|||||||
in_stock = values.in_stock;
|
in_stock = values.in_stock;
|
||||||
out_stock = values.out_stock;
|
out_stock = values.out_stock;
|
||||||
}
|
}
|
||||||
|
if (in_stock) {
|
||||||
where['in_stock_id'] = in_stock.id;
|
where['in_stock_id'] = in_stock.id;
|
||||||
|
}
|
||||||
|
if (out_stock) {
|
||||||
where['out_stock_id'] = out_stock.id;
|
where['out_stock_id'] = out_stock.id;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
await record.update(where, { transaction });
|
await record.update(where, { transaction });
|
||||||
|
if (where['in_stock_id'] && where['out_stock_id']) {
|
||||||
// 设置完出库入,设置项目
|
// 设置完出库入,设置项目
|
||||||
await this.updateRecordProjects(record, values, transaction, where);
|
await this.updateRecordProjects(record, values, transaction, where);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据产品数据计算金额
|
* 根据产品数据计算金额
|
||||||
|
Loading…
Reference in New Issue
Block a user