fix: 修改结算单其他费用的计算逻辑 (#1146)

Reviewed-on: daoyoucloud/tachybase#1146
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: wjh <wwwjh0710@163.com>
Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
wjh 2024-06-11 11:20:09 +08:00 committed by sealday
parent 98e4f7327c
commit 61b685c522

View File

@ -535,21 +535,20 @@ export class SettlementService {
rule.conversion_logic_id !== ConversionLogics.ProductWeight rule.conversion_logic_id !== ConversionLogics.ProductWeight
) { ) {
settlementAbout.records?.forEach((item) => { settlementAbout.records?.forEach((item) => {
if ( if (dayjs(item.date).isBetween(settlementAbout.start_date, settlementAbout.end_date, 'day', '[]')) {
dayjs(item.date).isBetween(ruleItem.start_date, ruleItem.end_date, 'day', '[]') &&
dayjs(item.date).isSameOrAfter(settlementAbout.start_date)
) {
const feeItem = item?.record_items.filter( const feeItem = item?.record_items.filter(
(value) => value && value.product_id === rule.fee_product_id, (value) => value && value.product_id === rule.fee_product_id,
); );
if (feeItem.length) { if (feeItem.length) {
feeItem.forEach((value) => { feeItem.forEach((value) => {
if (category === '其他') { if (category === '其他') {
data.movement = item.movement; const otherData = { ...data };
data.count = value.count * Number(item.movement === '-1' ? '1' : '-1'); otherData.movement = item.movement;
data.date = item.date; otherData.count = value.count * Number(item.movement === '-1' ? '1' : '-1');
data.amount = data.count * data.unit_price; otherData.date = dayjs(item.date).endOf('day');
createFeesDatas.push(data); otherData.amount = otherData.count * otherData.unit_price;
otherData.item_count = value.count;
createFeesDatas.push(otherData);
} else { } else {
data.count = data.count + value.count; data.count = data.count + value.count;
conversion = true; conversion = true;