Skip to content

Commit

Permalink
Merge pull request #646 from NUTFes/develop
Browse files Browse the repository at this point in the history
購入報告すり抜けバグ対応リリース
  • Loading branch information
imaimai17468 authored Sep 29, 2023
2 parents 298251b + c372a96 commit 834e477
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
12 changes: 7 additions & 5 deletions view/next-project/src/components/purchasereports/DetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ const DetailModal: FC<ModalProps> = (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;
};

Expand Down Expand Up @@ -161,7 +163,7 @@ const DetailModal: FC<ModalProps> = (props) => {
</thead>
<tbody className='w-full border border-x-white-0 border-b-primary-1 border-t-white-0'>
{/* <div className='flex items-start'> */}
{props.purchaseReportViewItem?.purchaseItems.map((purchaseItem) => (
{props.purchaseReportViewItem?.purchaseItems?.map((purchaseItem) => (
<tr key={purchaseItem.id} className='w-full'>
<td className='border-b py-3'>
<div className='text-center text-sm text-black-300'>{purchaseItem.item}</div>
Expand Down
21 changes: 12 additions & 9 deletions view/next-project/src/pages/purchasereports/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,24 @@ 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の合計金額
const totalReportFee = useMemo(() => {
if (filteredPurchaseReportViews) {
let totalFee = 0;
filteredPurchaseReportViews.map((purchaseReportView: PurchaseReportView) => {
totalFee += TotalFee(purchaseReportView.purchaseReport, purchaseReportView.purchaseItems);
totalFee +=
TotalFee(purchaseReportView.purchaseReport, purchaseReportView.purchaseItems) || 0;
});
return totalFee;
}
Expand Down Expand Up @@ -333,7 +336,7 @@ export default function PurchaseReports(props: Props) {
)}
>
{/* name (個数/finasucheck) */}
{purchaseReportViewItem.purchaseItems.map((purchaseItem, index) => (
{purchaseReportViewItem.purchaseItems?.map((purchaseItem, index) => (
<div key={index}>
{`${purchaseItem.financeCheck ? '○' : 'x'} ${purchaseItem.item} (${
purchaseItem.quantity
Expand Down

0 comments on commit 834e477

Please sign in to comment.