From 5089a78f829513d6e6c7c038648b1157b406f069 Mon Sep 17 00:00:00 2001 From: wjh Date: Thu, 10 Oct 2024 13:37:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=AF=B9=E8=B4=A6?= =?UTF-8?q?=E5=8D=95=E6=97=A0=E6=B3=95=E9=87=8D=E6=96=B0=E7=BB=93=E7=AE=97?= =?UTF-8?q?=20(#1586)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1586 Co-authored-by: wjh Co-committed-by: wjh --- .../src/server/services/settlement-service.ts | 54 ++++++++++++------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/packages/plugins/@hera/plugin-rental/src/server/services/settlement-service.ts b/packages/plugins/@hera/plugin-rental/src/server/services/settlement-service.ts index b80fc66f8..7fcbae763 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/services/settlement-service.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/services/settlement-service.ts @@ -130,7 +130,9 @@ export class SettlementService { name: productLength > 1 ? rule.comment ?? '' : productName.name, //名称 label: productLength > 1 - ? `${rule.comment}-${productName.label}$$ ` ?? '' + `-${productName.label}$$ ` + ? rule.comment + ? `${rule.comment}-${productName.label}$$ ` + : ' ' + `-${productName.label}$$ ` : productName.label, //规格 category: item.category, //费用类别 //租赁天数 历史订单就存开始日期到结束日期 当前订单存储订单日期到结束日期 @@ -206,8 +208,9 @@ export class SettlementService { if (productLength > 1 && item) { const itemData = { ...data }; itemData['item_count'] = curr.count * Number(movement); - itemData['label'] = - `${rule.comment}-${curr.product.label}$$` ?? '' + `-${curr.product.label}$$`; + itemData['label'] = rule.comment + ? `${rule.comment}-${curr.product.label}$$` + : ' ' + `-${curr.product.label}$$`; itemData['count'] = 0; itemData['amount'] = 0; createLeasDatas.push(itemData); @@ -472,10 +475,13 @@ export class SettlementService { ) { const isRuleRecord = item.record_items ?.map((productItem) => { - return ruleProduct.includes(productItem.product_id) || + return ( + productItem && + (ruleProduct.includes(productItem.product_id) || ruleProduct.includes(productItem.product.category_id + RulesNumber) - ? productItem - : null; + ? productItem + : null) + ); }) .filter(Boolean); if (!isRuleRecord.length) return; @@ -567,10 +573,13 @@ export class SettlementService { if (dayjs(item.date).isBetween(settlementAbout.start_date, settlementAbout.end_date, 'day', '[]')) { const isRuleRecord = item.record_items ?.map((productItem) => { - return ruleProduct.includes(productItem.product_id) || + return ( + productItem && + (ruleProduct.includes(productItem.product_id) || ruleProduct.includes(productItem.product.category_id + RulesNumber) - ? productItem - : null; + ? productItem + : null) + ); }) .filter(Boolean); if (!isRuleRecord.length) return; @@ -618,10 +627,13 @@ export class SettlementService { ) { const isRuleRecord = item.record_items ?.map((productItem) => { - return ruleProduct.includes(productItem.product_id) || + return ( + productItem && + (ruleProduct.includes(productItem.product_id) || ruleProduct.includes(productItem.product.category_id + RulesNumber) - ? productItem - : null; + ? productItem + : null) + ); }) .filter(Boolean); if (!isRuleRecord.length) return; @@ -658,10 +670,13 @@ export class SettlementService { ) { const isRuleRecord = item.record_items ?.map((productItem) => { - return ruleProduct.includes(productItem.product_id) || + return ( + productItem && + (ruleProduct.includes(productItem.product_id) || ruleProduct.includes(productItem.product.category_id + RulesNumber) - ? productItem - : null; + ? productItem + : null) + ); }) .filter(Boolean); if (!isRuleRecord.length) return; @@ -698,10 +713,13 @@ export class SettlementService { ) { const isRuleRecord = item.record_items ?.map((productItem) => { - return ruleProduct.includes(productItem.product_id) || + return ( + productItem && + (ruleProduct.includes(productItem.product_id) || ruleProduct.includes(productItem.product.category_id + RulesNumber) - ? productItem - : null; + ? productItem + : null) + ); }) .filter(Boolean); if (!isRuleRecord.length) return;