From ff9ae1a2f5614bca94277f25202e13f1c712f3a3 Mon Sep 17 00:00:00 2001 From: "hello@lv" <2256334253@qq.com> Date: Wed, 3 Apr 2024 13:03:56 +0800 Subject: [PATCH] fix_record_price_pdf (#587) Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachycode/pulls/587 Co-authored-by: hello@lv <2256334253@qq.com> Co-committed-by: hello@lv <2256334253@qq.com> --- .changeset/pre.json | 1 + .changeset/rare-lies-applaud.md | 5 +++++ package.json | 2 ++ packages/plugins/@hera/plugin-rental/package.json | 2 +- .../src/server/actions/records-controller.ts | 3 ++- .../src/server/pdf-documents/records-documentV2.tsx | 9 ++++++--- .../src/server/services/record-pdf-service.ts | 4 ++++ 7 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 .changeset/rare-lies-applaud.md diff --git a/.changeset/pre.json b/.changeset/pre.json index d2349e711..197a7ca4d 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -98,6 +98,7 @@ "hot-mugs-double", "long-dolphins-sit", "pretty-wolves-allow", + "rare-lies-applaud", "selfish-lies-enjoy", "six-dolphins-mix", "slimy-sloths-repeat", diff --git a/.changeset/rare-lies-applaud.md b/.changeset/rare-lies-applaud.md new file mode 100644 index 000000000..c3d9e11a1 --- /dev/null +++ b/.changeset/rare-lies-applaud.md @@ -0,0 +1,5 @@ +--- +"@hera/plugin-rental": patch +--- + +购销单线上报错处理,增加log diff --git a/package.json b/package.json index e6b082dde..0bf8db2dd 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,8 @@ "release:force": "lerna publish from-package --yes", "run:example": "tsx -r dotenv/config -r tsconfig-paths/register ./examples/index.ts", "start": "nocobase start", + "tag:p": "changeset", + "tag:v": "changeset version", "tar": "nocobase tar", "tc": "nocobase test:client", "test": "nocobase test", diff --git a/packages/plugins/@hera/plugin-rental/package.json b/packages/plugins/@hera/plugin-rental/package.json index d443ca245..b14a9e9ff 100644 --- a/packages/plugins/@hera/plugin-rental/package.json +++ b/packages/plugins/@hera/plugin-rental/package.json @@ -1,7 +1,7 @@ { "name": "@hera/plugin-rental", "displayName": "professional construction materials rental system - customized based on hera", - "version": "1.7.6-alpha.7", + "version": "1.7.6-alpha.8", "description": "Offering a standardized leasing management system, encompassing comprehensive administration from materials to contracts to labor personnel, while providing a robust financial management mechanism, and real-time monitoring of the operational capacity of the leasing system.", "keywords": [ "System management" diff --git a/packages/plugins/@hera/plugin-rental/src/server/actions/records-controller.ts b/packages/plugins/@hera/plugin-rental/src/server/actions/records-controller.ts index 5819c123e..211b98666 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/actions/records-controller.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/actions/records-controller.ts @@ -158,7 +158,8 @@ export class RecordPreviewController { // 拉标题 const systemSetting = await this.systemSetting.get(); record.systemTitle = systemSetting?.title || '异常数据,请联系相关负责人!'; - const user = await ctx.db.getRepository('users').findOne({ filter: { id: record.createdById } }); + const userID = record.createdById || record.updatedById; + const user = await ctx.db.getRepository('users').findOne({ filter: { id: userID } }); record.nickname = user?.nickname || ''; record.userPhone = user?.phone || ''; record.pdfExplain = pdfExplain[0]?.out_of_storage_explain; 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 346cb9886..42b75c511 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 @@ -362,13 +362,16 @@ const PreviewDocument = ({ {item[column + 'name']} - {formatQuantity(item[column + 'unit_price'], 2) + '元/' + item[column + 'unit']} + {item[column + 'unit_price'] && + formatQuantity(item[column + 'unit_price'], 2) + '元/' + item[column + 'unit']} - {formatQuantity(item[column + 'count'], 2)} + {item[column + 'count'] && formatQuantity(item[column + 'count'], 2)} {item[column + 'unit']} - {formatCurrency(item[column + 'all_price'], 2)} + + {item[column + 'all_price'] && formatCurrency(item[column + 'all_price'], 2)} + {item[column + 'comment'] || ''} diff --git a/packages/plugins/@hera/plugin-rental/src/server/services/record-pdf-service.ts b/packages/plugins/@hera/plugin-rental/src/server/services/record-pdf-service.ts index c5be9c782..21f7e8685 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/services/record-pdf-service.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/services/record-pdf-service.ts @@ -70,6 +70,10 @@ export class RecordPdfService { const setData = Object.values( price_rule.reduce((acc, item) => { + if (!item) { + console.error('报价计算出错', price_rule); + return acc; + } if (!acc[item.name]) { acc[item.name] = { ...item }; } else {