From 45471a05b8ae745433669551db52e73ab7f86670 Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Fri, 29 Sep 2023 11:02:57 +0900 Subject: [PATCH] =?UTF-8?q?=E8=B3=BC=E5=85=A5=E5=A0=B1=E5=91=8A=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=AE=E3=83=90=E3=82=B0=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../purchasereports/DetailModal.tsx | 12 ++++++----- .../src/pages/purchasereports/index.tsx | 21 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/view/next-project/src/components/purchasereports/DetailModal.tsx b/view/next-project/src/components/purchasereports/DetailModal.tsx index 3bf683b0d..d72bc80aa 100644 --- a/view/next-project/src/components/purchasereports/DetailModal.tsx +++ b/view/next-project/src/components/purchasereports/DetailModal.tsx @@ -66,10 +66,12 @@ const DetailModal: FC = (props) => { // 購入報告の合計金額を計算 const TotalFee = (purchaseReport: PurchaseReport, purchaseItems: PurchaseItem[]) => { let totalFee = 0; - purchaseItems.map((purchaseItem: PurchaseItem) => { - totalFee += purchaseItem.price * purchaseItem.quantity; - }); - totalFee += purchaseReport.addition - purchaseReport.discount; + if (purchaseItems) { + purchaseItems.map((purchaseItem: PurchaseItem) => { + totalFee += purchaseItem.price * purchaseItem.quantity; + }); + totalFee += purchaseReport.addition - purchaseReport.discount; + } return totalFee; }; @@ -161,7 +163,7 @@ const DetailModal: FC = (props) => { {/*
*/} - {props.purchaseReportViewItem?.purchaseItems.map((purchaseItem) => ( + {props.purchaseReportViewItem?.purchaseItems?.map((purchaseItem) => (
{purchaseItem.item}
diff --git a/view/next-project/src/pages/purchasereports/index.tsx b/view/next-project/src/pages/purchasereports/index.tsx index 27faf667a..dd53e909a 100644 --- a/view/next-project/src/pages/purchasereports/index.tsx +++ b/view/next-project/src/pages/purchasereports/index.tsx @@ -93,13 +93,15 @@ export default function PurchaseReports(props: Props) { const TotalFee = useCallback((purchaseReport: PurchaseReport, purchaseItems: PurchaseItem[]) => { let totalFee = 0; - purchaseItems.map((purchaseItem: PurchaseItem) => { - if (purchaseItem.financeCheck) { - totalFee += purchaseItem.price * purchaseItem.quantity; - } - }); - totalFee += purchaseReport.addition - purchaseReport.discount; - return totalFee; + if (purchaseItems) { + purchaseItems.map((purchaseItem: PurchaseItem) => { + if (purchaseItem.financeCheck) { + totalFee += purchaseItem.price * purchaseItem.quantity; + } + }); + totalFee += purchaseReport.addition - purchaseReport.discount; + return totalFee; + } }, []); // すべてのpurchaseReportの合計金額 @@ -107,7 +109,8 @@ export default function PurchaseReports(props: Props) { if (filteredPurchaseReportViews) { let totalFee = 0; filteredPurchaseReportViews.map((purchaseReportView: PurchaseReportView) => { - totalFee += TotalFee(purchaseReportView.purchaseReport, purchaseReportView.purchaseItems); + totalFee += + TotalFee(purchaseReportView.purchaseReport, purchaseReportView.purchaseItems) || 0; }); return totalFee; } @@ -333,7 +336,7 @@ export default function PurchaseReports(props: Props) { )} > {/* name (個数/finasucheck) */} - {purchaseReportViewItem.purchaseItems.map((purchaseItem, index) => ( + {purchaseReportViewItem.purchaseItems?.map((purchaseItem, index) => (
{`${purchaseItem.financeCheck ? '○' : 'x'} ${purchaseItem.item} (${ purchaseItem.quantity