From f4adb008ae55e4b340c58c32d45af6d0eaf6eb57 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 12 Mar 2025 14:29:42 +0700 Subject: update detail transaction --- src/lib/transaction/components/Transaction.jsx | 278 +++++++++++++++++++++++-- 1 file changed, 260 insertions(+), 18 deletions(-) (limited to 'src/lib/transaction/components/Transaction.jsx') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index b2fb2c17..32416bc0 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -49,18 +49,19 @@ const Transaction = ({ id }) => { const [reason, setReason] = useState(''); const auth = useAuth(); const { transaction } = useTransaction({ id }); + console.log('transaction', transaction); const statusApprovalWeb = transaction.data?.approvalStep; const [isLoading, setIsLoading] = useState(false); const { queryAirwayBill } = useAirwayBill({ orderId: id }); const [airwayBillPopup, setAirwayBillPopup] = useState(null); - + const [isOpen, setIsOpen] = useState(false); const poNumber = useRef(null); const poFile = useRef(null); const [uploadPo, setUploadPo] = useState(false); const [idAWB, setIdAWB] = useState(null); const openUploadPo = () => setUploadPo(true); const closeUploadPo = () => setUploadPo(false); - + const [copied, setCopied] = useState(false); const submitUploadPo = async () => { const file = poFile.current.files[0]; const name = poNumber.current.value; @@ -208,7 +209,9 @@ const Transaction = ({ id }) => {

{currencyFormat(transaction.data?.amountUntaxed)}

-

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

+

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

{currencyFormat(transaction.data?.amountTax)}

@@ -279,6 +282,35 @@ const Transaction = ({ id }) => { } }; + const handleCopyClick = (waybillNumber) => { + const textToCopy = waybillNumber; + console.log('textToCopy', textToCopy); + navigator.clipboard.writeText(textToCopy); + setCopied(true); + toast.success('No Resi Berhasil di Copy'); + setTimeout(() => setCopied(false), 2000); // Reset copied state after 2 seconds + }; + + const formatDate = (dateString) => { + const months = [ + 'Januari', + 'Februari', + 'Maret', + 'April', + 'Mei', + 'Juni', + 'Juli', + 'Agustus', + 'September', + 'Oktober', + 'November', + 'Desember', + ]; + + const [day, month, year] = dateString.split('/'); + return `${day} ${months[parseInt(month, 10) - 1]} ${year}`; + }; + return ( transaction.data?.name && ( <> @@ -615,13 +647,50 @@ const Transaction = ({ id }) => { )}
-
- - {transaction?.data?.name} - - +
+
-
+
+
+ + {transaction?.data?.name} + + +
+
+
+ +
+
+
+ {/*
)} -
+
*/}
-
+
Nama Sales
: {transaction?.data?.sales}
Tanggal Transaksi
: {transaction?.data?.dateOrder}
-
-
-
Ketentuan Pembayaran
-
: {transaction?.data?.paymentTerm}
{!auth?.feature?.soApproval ? ( <> @@ -729,9 +794,184 @@ const Transaction = ({ id }) => { )}
+
+
Payment Term
+
: {transaction?.data?.paymentTerm}
+ +
Dokumen Pengiriman
+
+ :{' '} + {transaction.data?.pickings?.length === 0 + ? 'Belum ada pengiriman' + : transaction?.data?.pickings[0].name} +
+ +
Invoice Pembelian
+
+ :{' '} + {transaction.data?.invoices?.length === 0 + ? 'Belum ada invoice' + : transaction.data?.invoices?.map((invoice, index) => ( + + {invoice?.name} + {/*
+
+

{invoice?.name}

+
+ {invoice.amountResidual > 0 ? ( +
Belum Lunas
+ ) : ( +
Lunas
+ )} +

+ {currencyFormat(invoice.amountTotal)} +

+
+
+ +
*/} + + ))} +
+
+
+
+ {/*
*/} +
+
+ + Alamat Pengiriman + +
+
Nama Penerima
+
:
+
{transaction?.data?.address?.customer?.name}
+ +
No. Telepon
+
:
+
{transaction?.data?.address?.customer?.phone}
+ +
Email
+
:
+
{transaction?.data?.address?.customer?.email}
+ +
Alamat Pengiriman
+
:
+
+ {transaction?.data?.address?.customer?.alamatBisnis} +
+
+
+
+ + Info Pengiriman + +
+
Nomor Resi
+
:
+
+ {transaction?.data?.pickings[0]?.trackingNumber || '-'} + {transaction?.data?.pickings[0]?.trackingNumber && ( + + )} +
+ +
Kurir
+
:
+
+ {transaction?.data?.pickings[0]?.carrierName ? ( + <> +

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

+ + setIdAWB(transaction?.data?.pickings[0]?.id) + } + > + Lacak Pengiriman + + + ) : ( + '-' + )} +
+ +
Jenis Service
+
:
+
BELUM TAU AMBIL DARI MANA
+ +
Tanggal Kirim
+
:
+
+ {transaction?.data?.pickings[0]?.date + ? formatDate(transaction?.data?.pickings[0]?.date) + : '-'} +
+ +
Estimasi Tiba
+
:
+
+ {transaction?.data?.pickings[0]?.eta + ? transaction?.data?.pickings[0]?.eta + : '-'} +
+ {transaction?.data?.pickings[0] && ( +
+ +
+ )} +
+
-
+
+ + {/*
Informasi Pelanggan
@@ -807,7 +1047,7 @@ const Transaction = ({ id }) => { ))}
-
+
*/}
Rincian Pembelian @@ -976,7 +1216,9 @@ const Transaction = ({ id }) => { {currencyFormat(transaction.data?.amountUntaxed)}
-
PPN {((PPN - 1) * 100).toFixed(0)}%
+
+ PPN {((PPN - 1) * 100).toFixed(0)}% +
{currencyFormat(transaction.data?.amountTax)}
-- cgit v1.2.3 From b4a595eaa8600e7bd1bafcef38abe4c01a5b664c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 12 Mar 2025 16:59:18 +0700 Subject: fix transaction --- src/lib/transaction/components/Transaction.jsx | 58 ++++++++++++++++---------- 1 file changed, 35 insertions(+), 23 deletions(-) (limited to 'src/lib/transaction/components/Transaction.jsx') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 07f9573d..8369c425 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -49,7 +49,6 @@ const Transaction = ({ id }) => { const [reason, setReason] = useState(''); const auth = useAuth(); const { transaction } = useTransaction({ id }); - console.log('transaction', transaction); const statusApprovalWeb = transaction.data?.approvalStep; const [isLoading, setIsLoading] = useState(false); const { queryAirwayBill } = useAirwayBill({ orderId: id }); @@ -284,7 +283,6 @@ const Transaction = ({ id }) => { const handleCopyClick = (waybillNumber) => { const textToCopy = waybillNumber; - console.log('textToCopy', textToCopy); navigator.clipboard.writeText(textToCopy); setCopied(true); toast.success('No Resi Berhasil di Copy'); @@ -755,7 +753,7 @@ const Transaction = ({ id }) => { )}
*/} -
+
Nama Sales
: {transaction?.data?.sales}
@@ -853,11 +851,19 @@ const Transaction = ({ id }) => {
No. Telepon
:
-
{transaction?.data?.address?.customer?.phone}
+
+ {transaction?.data?.address?.customer?.phone + ? transaction?.data?.address?.customer?.phone + : '-'} +
Email
:
-
{transaction?.data?.address?.customer?.email}
+
+ {transaction?.data?.address?.customer?.email + ? transaction?.data?.address?.customer?.email + : '-'} +
Alamat Pengiriman
:
@@ -906,27 +912,33 @@ const Transaction = ({ id }) => {
Kurir
:
-
- {transaction?.data?.pickings[0]?.carrierName ? ( - <> -

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

- - setIdAWB(transaction?.data?.pickings[0]?.id) - } - > - Lacak Pengiriman - - - ) : ( - '-' - )} -
+ {transaction?.data?.pickings[0]?.carrierName ? ( +
+

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

+ + setIdAWB(transaction?.data?.pickings[0]?.id) + } + > + Lacak Pengiriman + +
+ ) : ( + '-' + )}
Jenis Service
:
-
BELUM TAU AMBIL DARI MANA
+
+ {' '} + {transaction?.data?.pickings[0]?.serviceType && + transaction?.data?.pickings[0]?.carrierName + ? transaction?.data?.pickings[0]?.serviceType + : '-'} +
Tanggal Kirim
:
-- cgit v1.2.3 From 1904419f7aa7d2c6ee8644166e270703e969d4b2 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 13 Mar 2025 15:10:18 +0700 Subject: update mobile --- src/lib/transaction/components/Transaction.jsx | 84 +++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 3 deletions(-) (limited to 'src/lib/transaction/components/Transaction.jsx') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 8369c425..2e328a7e 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -17,6 +17,7 @@ import getFileBase64 from '@/core/utils/getFileBase64'; import currencyFormat from '@/core/utils/currencyFormat'; import VariantGroupCard from '@/lib/variant/components/VariantGroupCard'; import { + EllipsisVerticalIcon, ChevronDownIcon, ChevronRightIcon, ChevronUpIcon, @@ -61,6 +62,7 @@ const Transaction = ({ id }) => { const openUploadPo = () => setUploadPo(true); const closeUploadPo = () => setUploadPo(false); const [copied, setCopied] = useState(false); + const [toOthers, setToOthers] = useState(null); const submitUploadPo = async () => { const file = poFile.current.files[0]; const name = poNumber.current.value; @@ -418,9 +420,74 @@ const Transaction = ({ id }) => {
+ + setToOthers(null)} + > +
+ + + +
+
+ +
+
+ + setIdAWB(transaction?.data?.pickings[0]?.id)} + > + Lihat Detail + +
+
{auth?.feature?.soApproval && ( { /> )}
+ +
+
+
Pengiriman
+ +
+
+ setToOthers(transaction?.data)} + /> +
+
-
- -
+
{transaction.data?.name} -- cgit v1.2.3 From af311a10854f092efa57716ffd5329cce0c7d8db Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 13 Mar 2025 16:33:00 +0700 Subject: update mobile --- src/lib/transaction/components/Transaction.jsx | 39 ++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'src/lib/transaction/components/Transaction.jsx') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 2e328a7e..299f7a07 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -41,6 +41,10 @@ import rejectProductApi from '../api/rejectProductApi'; import { useRouter } from 'next/router'; import { gtagPurchase } from '@/core/utils/googleTag'; import { deleteItemCart } from '@/core/utils/cart'; +import { + downloadInvoice, + downloadTaxInvoice, +} from '@/lib/invoice/utils/invoices'; import axios from 'axios'; const Transaction = ({ id }) => { const PPN = process.env.NEXT_PUBLIC_PPN; @@ -50,6 +54,7 @@ const Transaction = ({ id }) => { const [reason, setReason] = useState(''); const auth = useAuth(); const { transaction } = useTransaction({ id }); + console.log('transaction', transaction); const statusApprovalWeb = transaction.data?.approvalStep; const [isLoading, setIsLoading] = useState(false); const { queryAirwayBill } = useAirwayBill({ orderId: id }); @@ -463,7 +468,7 @@ const Transaction = ({ id }) => { -
+
-
- {auth?.feature?.soApproval && ( + {auth?.feature?.soApproval && ( +
- )} -
+
+ )}
-
Pengiriman
+
Status Transaksi
@@ -510,6 +515,28 @@ const Transaction = ({ id }) => { />
+ + {transaction.data?.invoices?.length === 0 ? ( +
-
+ ) : ( + transaction.data?.invoices?.map((invoice, index) => ( +
+
{invoice?.name}
+ downloadInvoice(invoice)} + > + Download + +
+ )) + )} + + +
-- cgit v1.2.3 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 +++++++++++++++++++++---- 1 file changed, 295 insertions(+), 53 deletions(-) (limited to 'src/lib/transaction/components/Transaction.jsx') 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)}
-- cgit v1.2.3 From 6499f025995f13fcf32b2b5f79c8ee14585668fc Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 14 Mar 2025 16:42:45 +0700 Subject: fix mobile --- src/lib/transaction/components/Transaction.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/transaction/components/Transaction.jsx') diff --git a/src/lib/transaction/components/Transaction.jsx b/src/lib/transaction/components/Transaction.jsx index 5f17b623..9216f7f7 100644 --- a/src/lib/transaction/components/Transaction.jsx +++ b/src/lib/transaction/components/Transaction.jsx @@ -574,7 +574,7 @@ const Transaction = ({ id }) => {
{transaction.data?.invoices?.length === 0 ? ( -
-
+

) : ( transaction.data?.invoices?.map((invoice, index) => (