diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx index b31d018da..51d12a635 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx @@ -199,7 +199,7 @@ const summary = (event: RecordItems, rules: any[], ruleWeight: any) => { calc.name = category.name; calc.count = count; calc.unit = unit; - calc.weight = event.product.weight; + calc.weight = event.product.weight * event.count; } else { // 2. 存在规则(实际重量情况不计算) const plain = rules.find((item) => diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx index 5d8db1ac9..15e4e00f2 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx @@ -40,8 +40,7 @@ export const RecordTotalPrice = (props) => { const computeTotalPrice = () => { const about_product = form.values.items.filter( (item) => - (item?.product && item?.product?.category_id == leaseData?.product?.category_id) || - (leaseData?.product?.id > 99999 && item?.product?.id == leaseData?.product?.id - 99999), + item.product?.id === leaseData.product?.id || item.product?.category_id === leaseData.product?.id - 99999, ); if (!leaseData || !about_product) { return; @@ -49,13 +48,13 @@ export const RecordTotalPrice = (props) => { let allPrice = 0; const rule = leaseData.conversion_logic; if (!rule) return; - if (rule.id == ConversionLogics.ActualWeight) { + if (rule.id === ConversionLogics.ActualWeight) { // 分组总量项 - const weightItem = groupWeight.find( - (item) => item.products?.find((product) => product?.id == leaseData.product?.category_id), + const weightItem = groupWeight.find((item) => + item.products?.find((product) => product?.id === leaseData.product?.category_id), ); // 存在该分组相关产品items - const effectiveData = about_product.find((item) => item.product?.category_id == leaseData.product?.category_id); + const effectiveData = about_product.find((item) => item.product?.category_id === leaseData.product?.category_id); if (!effectiveData) return; if (weightItem && weightItem.weight) { allPrice = weightItem.weight * (leaseData.unit_price || 0); @@ -66,26 +65,26 @@ export const RecordTotalPrice = (props) => { for (const item of about_product) { const foundProduct = reqProduct.data.data.find((product) => product.id === item.product.id).category; const price = leaseData.unit_price || 0; - if (rule.id == ConversionLogics.Keep) { + if (rule.id === ConversionLogics.Keep) { allPrice += price * (item.count || 0); - } else if (rule.id == ConversionLogics.Product) { + } else if (rule.id === ConversionLogics.Product) { if (foundProduct.convertible && !item.product?.ratio) { console.error('产品缺少换算比例', item.product?.label); } const total = foundProduct.convertible ? item?.count * item.product?.ratio : item?.count; allPrice += price * (total || 0); - } else if (rule.id == ConversionLogics.ProductWeight) { + } else if (rule.id === ConversionLogics.ProductWeight) { allPrice += (price * (item.product?.weight || 0) * (item.count || 0)) / 1000; } else { const weightRule = reqWeightRules.data.data.find( (weight_item) => - weight_item.logic_id == rule.id && - (weight_item.product_id == item.product?.id || - weight_item.product_id == item.product?.category_id + 99999), + weight_item.logic_id === rule.id && + (weight_item.product_id === item.product?.id || + weight_item.product_id === item.product?.category_id + 99999), ); - if (weightRule && weightRule.conversion_logic_id == ConversionLogics.Keep) { + if (weightRule && weightRule.conversion_logic_id === ConversionLogics.Keep) { allPrice += price * (item.count || 0) * (weightRule.weight || 0); - } else if (weightRule && weightRule.conversion_logic_id == ConversionLogics.Product) { + } else if (weightRule && weightRule.conversion_logic_id === ConversionLogics.Product) { if (foundProduct.convertible && !item.product?.ratio) { console.error('产品缺少换算比例', item.product?.label); } @@ -132,7 +131,7 @@ export const RecordTotalPrice = (props) => { computeTotalPrice(); } }, [leaseData, products, groupWeight, recordWeight, reqProduct.loading, reqWeightRules.loading]); - return {all_price == 0 ? '-' : formatCurrency(all_price, 2)}; + return {all_price === 0 ? '-' : formatCurrency(all_price, 2)}; }; RecordTotalPrice.displayName = 'RecordTotalPrice'; diff --git a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx index d50fed4e5..a2e536bf3 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx +++ b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx @@ -384,9 +384,11 @@ const PreviewDocument = ({ priceRule.map((item) => ( {item.name} - {item?.unit_price && item.unit_price + '元/' + item.unit} - {item.count} + {item?.unit_price && formatQuantity(item.unit_price, 2) + '元/' + item.unit} + + + {formatQuantity(item.count, 2)} {item.unit} {formatCurrency(item.all_price, 2)} @@ -415,20 +417,20 @@ const PreviewDocument = ({ {item.left_name} - {item?.left_unit_price && item.left_unit_price + '元/' + item.left_unit} + {item?.left_unit_price && formatQuantity(item.left_unit_price, 2) + '元/' + item.left_unit} - {item.left_count} + {formatQuantity(item.left_count, 2)} {item.left_unit} {formatCurrency(item.left_all_price, 2)} {item.left_comment || ''} {item.right_name} - {item?.right_unit_price && item.unit_price + '元/' + item.right_unit} + {item?.right_unit_price && formatQuantity(item.right_unit_price, 2) + '元/' + item.right_unit} - {item.right_count} + {formatQuantity(item.right_count)} {item.right_unit} diff --git a/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts b/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts index 5fa09a915..477621bcc 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts @@ -17,7 +17,7 @@ export class RecordService { // 订单发生变化时更新对应结算单的状态(需要重新计算) this.db.on('records.afterSave', this.updateSettlementStatus.bind(this)); // 老系统导入信息系统数据,record_import存储数据,并根据record_import数据创建对应的单子 - this.db.on('record_import.afterCreate', this.importRecord.bind(this)); + // this.db.on('record_import.afterCreate', this.importRecord.bind(this)); } /** * 处理直发单生成单 @@ -510,7 +510,7 @@ export class RecordService { // 租赁入库, out_stock = 合同中project_id, in_stock = 合同中项目的associated_company_id => 项目表id const associatedCompanyProject = await this.db .getRepository('project') - .findOne({ where: { company_id: contractProject.associated_company_id } }); + .findOne({ where: { company_id: contractProject.associated_company_id, category: '1' } }); if (values.record_category === RecordTypes.rentInStock) { out_stock = contractProject.dataValues;