From 45a4a67274dcd8172eba3a9ed171a631c6d1c3b3 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 14 Mar 2025 16:16:47 +0700 Subject: fix code --- src/lib/transaction/components/Transaction.jsx | 348 +++++++++++++++++++++---- src/lib/treckingAwb/component/Manifest.jsx | 4 +- 2 files changed, 297 insertions(+), 55 deletions(-) (limited to 'src/lib') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 299f7a07..5f17b623 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -68,6 +68,25 @@ const Transaction = ({ id }) => { const closeUploadPo = () => setUploadPo(false); const [copied, setCopied] = useState(false); const [toOthers, setToOthers] = useState(null); + const [totalAmount, setTotalAmount] = useState(0); + const [totalDiscountAmount, setTotalDiscountAmount] = useState(0); + + useEffect(() => { + if (transaction?.data?.products) { + let calculateTotalAmount = 0; + let calculateTotalDiscountAmount = 0; + transaction.data.products.forEach((product) => { + calculateTotalAmount += product.price.price * product.quantity; + calculateTotalDiscountAmount += + (product.price.price - product.price.priceDiscount) * + product.quantity; + }); + setTotalAmount(calculateTotalAmount); + setTotalDiscountAmount(calculateTotalDiscountAmount); + } + }, [transaction.data, transaction.isLoading]); + console.log('totalAmount', totalAmount); + console.log('totalDiscountAmount', totalDiscountAmount); const submitUploadPo = async () => { const file = poFile.current.files[0]; const name = poNumber.current.value; @@ -206,32 +225,70 @@ const Transaction = ({ id }) => { transaction.refetch(); }; - const memoizeVariantGroupCard = useMemo( - () => ( -
- -
-

Subtotal

-

{currencyFormat(transaction.data?.amountUntaxed)}

-
-
-

- PPN {((PPN - 1) * 100).toFixed(0)}% -

-

{currencyFormat(transaction.data?.amountTax)}

-
-
-

Biaya Pengiriman

-

{currencyFormat(transaction.data?.deliveryAmount)}

-
-
-

Grand Total

-

{currencyFormat(transaction.data?.amountTotal)}

-
-
- ), - [transaction.data] - ); + const countWeight = (products) => { + if (!products || !Array.isArray(products)) return 0.0; + + const weight = products.reduce( + (total, product) => total + (product.weight * product.quantity || 0), + 0 + ); + return weight + ' Kg'; + }; + + // const memoizeVariantGroupCard = useMemo( + // () => ( + //
+ // + //
Info Pengiriman
+ //
+ //

Metode Pembayaran

+ //

+ // {transaction.data?.paymentType + // ? transaction.data?.paymentType + // ?.replace(/_/g, ' ') + // .replace(/\b\w/g, (char) => char.toUpperCase()) + // : '-'} + //

+ //
+ //
+ //

Berat Barang

+ //

{transaction.data?.pickings[0]?.weightTotal}

+ //
+ //
+ //
+ //

Total Belanja

+ //

{currencyFormat(totalAmount)}

+ //
+ //
+ //

Diskon Belanja

+ //

{'- ' + currencyFormat(totalDiscountAmount)}

+ //
+ //
+ //

Subtotal

+ //

{currencyFormat(transaction.data?.amountUntaxed)}

+ //
+ //
+ //

+ // PPN {((PPN - 1) * 100).toFixed(0)}% + //

+ //

{currencyFormat(transaction.data?.amountTax)}

+ //
+ //
+ //

Biaya Pengiriman

+ //

{currencyFormat(transaction.data?.deliveryAmount)}

+ //
+ //
+ //

Asuransi Pengiriman

+ //

{currencyFormat(transaction.data?.amountTotal)}

+ //
+ //
+ //

Grand Total

+ //

{currencyFormat(transaction.data?.amountTotal)}

+ //
+ //
+ // ), + // [transaction.data] + // ); const memoizeVariantGroupCardReject = useMemo( () => ( @@ -538,28 +595,121 @@ const Transaction = ({ id }) => {
- -
-
- {transaction.data?.name} +

{transaction.data?.name}

+
+ + {transaction.data?.dateOrder + ? formatDate(transaction.data?.dateOrder) + : '-'} + + + {transaction.data?.purchaseOrderName || '-'} - {transaction.data?.paymentTerm} + {transaction.data?.paymentTerm || '-'} {transaction.data?.sales} - - {transaction.data?.dateOrder} -
-
Pengiriman
-
+
+
Info Pengiriman
+ setIdAWB(transaction?.data?.pickings[0]?.id)} + > + Lihat Detail + +
+
+
+ +

+ {transaction.data?.pickings?.length == 0 + ? 'Belum ada pengiriman' + : transaction?.data?.pickings[0].name} +

+
+ +

+ {transaction?.data?.pickings[0]?.carrierName ? ( +

+ {transaction?.data?.pickings[0]?.carrierName} +

+ ) : ( + '-' + )} +

+
+ +

+ {transaction?.data?.pickings[0]?.serviceType && + transaction?.data?.pickings[0]?.carrierName + ? transaction?.data?.pickings[0]?.serviceType + : '-'} +

+
+ +
+ {transaction?.data?.pickings[0]?.trackingNumber || '-'} + {transaction?.data?.pickings[0]?.trackingNumber && ( + + )} +
+
+ +

+ {transaction?.data?.pickings[0]?.eta + ? transaction?.data?.pickings[0]?.eta + : '-'} +

+
+ +
+
+ {transaction?.data?.address?.customer?.name} +
+
+ {transaction?.data?.address?.customer?.phone + ? transaction?.data?.address?.customer?.phone + : '-'} +
+
+ {transaction?.data?.address?.customer?.alamatBisnis} +
+
+
+
+ {/*
{transaction?.data?.pickings?.map((airway) => (
{transaction?.data?.pickings == 0 && (
Belum ada pengiriman
- )} + )} */}
- + {/*

Invoice

@@ -615,11 +765,11 @@ const Transaction = ({ id }) => {
Belum ada invoice
)}
-
+ */} - {!auth?.feature.soApproval && ( + {/* {!auth?.feature.soApproval && (
{transaction.data?.purchaseOrderName || '-'} @@ -647,11 +797,59 @@ const Transaction = ({ id }) => {
)} - + */}
Detail Produk
{transaction?.data?.products.length > 0 ? ( -
{memoizeVariantGroupCard}
+
+ +
Rincian Pembayaran
+
+

Metode Pembayaran

+

+ {transaction.data?.paymentType + ? transaction.data?.paymentType + ?.replace(/_/g, ' ') + .replace(/\b\w/g, (char) => char.toUpperCase()) + : '-'} +

+
+
+

Berat Barang

+

{transaction.data?.pickings[0]?.weightTotal + ' Kg'}

+
+
+
+

Total Belanja

+

{currencyFormat(totalAmount)}

+
+
+

Diskon Belanja

+

{'- ' + currencyFormat(totalDiscountAmount)}

+
+
+

Subtotal

+

{currencyFormat(transaction.data?.amountUntaxed)}

+
+
+

+ PPN {((PPN - 1) * 100).toFixed(0)}% +

+

{currencyFormat(transaction.data?.amountTax)}

+
+
+

Biaya Pengiriman

+

{currencyFormat(transaction.data?.deliveryAmount)}

+
+
+

Asuransi Pengiriman

+

-

+
+
+

Grand Total

+

{currencyFormat(transaction.data?.amountTotal)}

+
+
) : (
Semua produk telah di reject @@ -665,13 +863,13 @@ const Transaction = ({ id }) => {
)} - + {/* */} - + {/* */} - + {/* */} -
+ {/*
{transaction.data?.status == 'draft' && auth?.feature.soApproval && (
@@ -728,7 +926,7 @@ const Transaction = ({ id }) => { Batalkan Transaksi )} -
+
*/} @@ -1018,7 +1216,7 @@ const Transaction = ({ id }) => {
Kurir
:
{transaction?.data?.pickings[0]?.carrierName ? ( -
+

{transaction?.data?.pickings[0]?.carrierName}

@@ -1326,7 +1524,49 @@ const Transaction = ({ id }) => { )} {transaction?.data?.products?.length > 0 && ( -
+ //
+ //
+ //
Subtotal
+ //
+ // {currencyFormat(transaction.data?.amountUntaxed)} + //
+ + //
+ // PPN {((PPN - 1) * 100).toFixed(0)}% + //
+ //
+ // {currencyFormat(transaction.data?.amountTax)} + //
+ + //
+ // Biaya Pengiriman + //
+ //
+ // {currencyFormat(transaction.data?.deliveryAmount)} + //
+ + //
Grand Total
+ //
+ // {currencyFormat(transaction.data?.amountTotal)} + //
+ //
+ //
+ +
+
+
Total Belanja
+
+ {currencyFormat(totalAmount)} +
+ +
Total Diskon
+
+ {'- ' + currencyFormat(totalDiscountAmount)} +
+
+ +
+
Subtotal
@@ -1340,15 +1580,17 @@ const Transaction = ({ id }) => { {currencyFormat(transaction.data?.amountTax)}
-
- Biaya Pengiriman -
+
Biaya Pengiriman
{currencyFormat(transaction.data?.deliveryAmount)}
+
+
+ +
Grand Total
-
+
{currencyFormat(transaction.data?.amountTotal)}
diff --git a/src/lib/treckingAwb/component/Manifest.jsx b/src/lib/treckingAwb/component/Manifest.jsx index 87e01e38..109bc832 100644 --- a/src/lib/treckingAwb/component/Manifest.jsx +++ b/src/lib/treckingAwb/component/Manifest.jsx @@ -120,9 +120,9 @@ const Manifest = ({ idAWB, closePopup }) => { {manifests?.waybillNumber && (
-

No. Resi

+

No. Resi

-

{manifests?.waybillNumber}

+

{manifests?.waybillNumber}