From a781431683b2484a3e615c114aafc52159b98847 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Tue, 13 Jan 2026 13:35:56 +0700 Subject: [PATCH 1/9] refactor(FE): Rename Type column header to Jenis --- src/components/pages/closing/ClosingFinanceTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/pages/closing/ClosingFinanceTable.tsx b/src/components/pages/closing/ClosingFinanceTable.tsx index 8c39b3fb..7eb34369 100644 --- a/src/components/pages/closing/ClosingFinanceTable.tsx +++ b/src/components/pages/closing/ClosingFinanceTable.tsx @@ -299,7 +299,7 @@ const ClosingFinanceTable = ({ }, }, { - header: 'Type', + header: 'Jenis', enableSorting: false, accessorFn: (item) => formatTitleCase(item.type || '-'), }, From 502564da0a0d1e36623531d6eb9cc9f7def63ac9 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Tue, 13 Jan 2026 13:43:34 +0700 Subject: [PATCH 2/9] refactor(FE): Exclude step 6 and include step 4 in edit check --- src/app/expense/detail/edit/page.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/expense/detail/edit/page.tsx b/src/app/expense/detail/edit/page.tsx index e254f01d..2fb33484 100644 --- a/src/app/expense/detail/edit/page.tsx +++ b/src/app/expense/detail/edit/page.tsx @@ -38,9 +38,11 @@ const ExpenseEditPage = () => { !isLoadingExpense && isResponseSuccess(expense) && expense.data.latest_approval.step_number !== 5 && + expense.data.latest_approval.step_number !== 6 && (expense.data.latest_approval.step_number === 1 || expense.data.latest_approval.step_number === 2 || - expense.data.latest_approval.step_number === 3); + expense.data.latest_approval.step_number === 3 || + expense.data.latest_approval.step_number === 4); if (!isLoadingExpense && !isExpenseCanBeEdited) { router.back(); From 92bfef850a9eb7f10888b549a7a0600e6184c3d6 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Tue, 13 Jan 2026 14:31:30 +0700 Subject: [PATCH 3/9] refactor(FE): Enhance customer payment PDF export and filters --- .../export/CustomerPaymentExportPDF.tsx | 145 +++++++++++++++--- .../report/finance/tab/CustomerPaymentTab.tsx | 52 +++---- 2 files changed, 145 insertions(+), 52 deletions(-) diff --git a/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx b/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx index 88c556de..08efa409 100644 --- a/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx +++ b/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx @@ -136,41 +136,129 @@ const pdfStyles = StyleSheet.create({ backgroundColor: '#F0F0F0', fontWeight: 'bold', }, + badge: { + backgroundColor: '#1f74bf', + color: '#FFFFFF', + padding: 2, + borderRadius: 2, + fontSize: 7, + fontWeight: 'bold', + alignSelf: 'center', + marginRight: 4, + }, + badgeLunas: { + backgroundColor: '#1f74bf', + color: '#FFFFFF', + }, + badgeBelumLunas: { + backgroundColor: '#F97316', + color: '#FFFFFF', + }, + parameterBadge: { + backgroundColor: '#F5F5F5', + color: '#333333', + padding: 4, + borderRadius: 4, + fontSize: 8, + marginRight: 8, + marginBottom: 4, + }, + parameterContainer: { + flexDirection: 'row', + flexWrap: 'wrap', + marginBottom: 8, + }, }); interface CustomerPaymentExportPDFParams { data: CustomerPaymentReport[]; + params?: { + customer_name?: string; + sales?: string; + start_date?: string; + end_date?: string; + filter_by?: string; + }; } +const getParameterText = ( + params?: CustomerPaymentExportPDFParams['params'] +) => { + const paramsText = []; + + if (params?.customer_name) { + paramsText.push(`Customer: ${params.customer_name}`); + } else { + paramsText.push('Semua Customer'); + } + + if (params?.sales) { + paramsText.push(`Sales: ${params.sales}`); + } + + if (params?.start_date && params?.end_date) { + const startDate = formatDate(params.start_date, 'DD MMM YYYY'); + const endDate = formatDate(params.end_date, 'DD MMM YYYY'); + paramsText.push(`Periode: ${startDate} - ${endDate}`); + } else if (params?.start_date) { + const startDate = formatDate(params.start_date, 'DD MMM YYYY'); + paramsText.push(`Tanggal: ${startDate}`); + } + + const currentDate = formatDate(new Date(), 'DD MMM YYYY HH:mm'); + paramsText.push(`Dicetak: ${currentDate}`); + + return paramsText; +}; + const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { return ( {params.data.map((customerReport, customerIndex) => ( - {/* Title and Customer Info */} + {/* Title and Parameters */} Laporan > Kontrol Pembayaran Customer + + + + Periode:{' '} + {params.params?.start_date + ? formatDate(params.params.start_date, 'DD MMM YYYY') + : '-'}{' '} + s.d{' '} + {params.params?.end_date + ? formatDate(params.params.end_date, 'DD MMM YYYY') + : '-'} + + + + Filter Tanggal: Tanggal DO + + + + Customer: {params.params?.customer_name || 'Semua Customer'} + + + + + Dicetak: {formatDate(new Date(), 'DD MMM YYYY HH:mm')} + + + {customerReport.customer.name} - {customerReport.customer.address || ''} + Alamat: {customerReport.customer.address || '-'} - {customerReport.summary && ( - - Total Saldo Piutang:{' '} - {formatCurrency( - customerReport.summary.total_accounts_receivable - )} - - )} {/* Table */} @@ -181,10 +269,10 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { No - Tgl DO/Bayar + Tanggal DO - Tgl Realisasi + Tanggal Realisasi Aging @@ -193,16 +281,16 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { Referensi - No. Polisi + No Polisi Qty - Berat (Kg) + Berat - AVG + Rata-Rata Harga Awal @@ -214,7 +302,7 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { Harga Akhir - PPN (%) + Pajak Total @@ -223,10 +311,10 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { Pembayaran - Saldo Piutang + Saldo - Ket + Keterangan Pengambilan @@ -304,7 +392,24 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { {formatCurrency(item.accounts_receivable)} - {item.notes || '-'} + {item.notes ? ( + {item.notes} + ) : ( + + + {item.accounts_receivable === 0 + ? 'Lunas' + : 'Belum Lunas'} + + + )} {item.pickup_info || '-'} diff --git a/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx b/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx index 1d8d1993..6cd0ba3d 100644 --- a/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx +++ b/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx @@ -46,7 +46,6 @@ const CustomerPaymentTab = () => { const [filterSales, setFilterSales] = useState([]); const [filterStartDate, setFilterStartDate] = useState(''); const [filterEndDate, setFilterEndDate] = useState(''); - const [filterErrors, setFilterErrors] = useState>({}); const filterModal = useModal(); @@ -75,27 +74,13 @@ const CustomerPaymentTab = () => { setFilterSales([]); setFilterStartDate(''); setFilterEndDate(''); - setFilterErrors({}); }, []); const handleApplyFilters = useCallback(() => { - const errors: Record = {}; - - if (!filterStartDate) { - errors.start_date = 'Tanggal mulai wajib diisi'; - } - if (!filterEndDate) { - errors.end_date = 'Tanggal akhir wajib diisi'; - } - - setFilterErrors(errors); - - if (Object.keys(errors).length === 0) { - setIsSubmitted(true); - setCurrentPage(1); - filterModal.closeModal(); - } - }, [filterModal, filterStartDate, filterEndDate]); + setIsSubmitted(true); + setCurrentPage(1); + filterModal.closeModal(); + }, [filterModal]); // ===== DATA FETCHING ===== const { data: customerPayment, isLoading } = useSWR( @@ -218,7 +203,22 @@ const CustomerPaymentTab = () => { return; } - await generateCustomerPaymentPDF({ data: allDataForExport }); + await generateCustomerPaymentPDF({ + data: allDataForExport, + params: { + customer_name: + filterCustomer.length > 0 + ? filterCustomer.map((c) => c.label).join(', ') + : undefined, + sales: + filterSales.length > 0 + ? filterSales.map((s) => s.label).join(', ') + : undefined, + start_date: filterStartDate || undefined, + end_date: filterEndDate || undefined, + filter_by: 'do_date', + }, + }); toast.success('PDF berhasil dibuat dan diunduh.'); } catch { toast.error('Gagal membuat PDF. Silakan coba lagi.'); @@ -538,15 +538,9 @@ const CustomerPaymentTab = () => { value={filterStartDate} onChange={(e) => { setFilterStartDate(e.target.value); - setFilterErrors((prev) => ({ ...prev, start_date: '' })); }} className={{ wrapper: 'w-full' }} /> - {filterErrors.start_date && ( -

- {filterErrors.start_date} -

- )}
@@ -556,15 +550,9 @@ const CustomerPaymentTab = () => { value={filterEndDate} onChange={(e) => { setFilterEndDate(e.target.value); - setFilterErrors((prev) => ({ ...prev, end_date: '' })); }} className={{ wrapper: 'w-full' }} /> - {filterErrors.end_date && ( -

- {filterErrors.end_date} -

- )}
From 60eaec261d8851ec3c40daab8b250eb85b7380ec Mon Sep 17 00:00:00 2001 From: rstubryan Date: Tue, 13 Jan 2026 15:20:27 +0700 Subject: [PATCH 4/9] refactor(FE): Render payment notes as Badge and highlight balance --- .../report/finance/tab/CustomerPaymentTab.tsx | 58 +++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx b/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx index 6cd0ba3d..2b2c09a2 100644 --- a/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx +++ b/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx @@ -2,6 +2,7 @@ import { useState, useMemo, useCallback } from 'react'; import useSWR from 'swr'; import { Icon } from '@iconify/react'; import Card from '@/components/Card'; +import Badge from '@/components/Badge'; import SelectInput, { useSelect, OptionType, @@ -67,6 +68,38 @@ const CustomerPaymentTab = () => { [] ); + const getPaymentStatusColor = (notes: string) => { + const normalizedValue = notes.toLowerCase(); + + if (normalizedValue === 'lunas') { + return 'bg-info/10 text-info border-info'; + } + + if (normalizedValue.includes('belum')) { + return 'bg-warning/10 text-warning border-warning'; + } + + return 'bg-gray-100 text-gray-600 border-gray-300'; + }; + + const getPaymentStatusIndicatorColor = (notes: string) => { + const normalizedValue = notes.toLowerCase(); + + if (normalizedValue === 'lunas') { + return 'bg-info'; + } + + if (normalizedValue.includes('belum')) { + return 'bg-warning'; + } + + return 'bg-gray-400'; + }; + + const getPaymentStatusText = (notes: string) => { + return notes; + }; + // ===== FILTER HANDLERS ===== const handleResetFilters = useCallback(() => { setIsSubmitted(false); @@ -435,7 +468,9 @@ const CustomerPaymentTab = () => { accessorKey: 'accounts_receivable', cell: (props) => { const value = props.row.original.accounts_receivable; - return
{formatCurrency(value)}
; + return ( +
{formatCurrency(value)}
+ ); }, footer: () => (
@@ -449,7 +484,23 @@ const CustomerPaymentTab = () => { accessorKey: 'notes', cell: (props) => { const value = props.row.original.notes; - return value || '-'; + + if (!value) { + return '-'; + } + + return ( + + {getPaymentStatusText(value)} + + ); }, }, { @@ -647,14 +698,13 @@ const CustomerPaymentTab = () => { total_accounts_receivable: 0, }; - const totalAccountsReceivable = summary.total_accounts_receivable; const tableColumns = getTableColumns(summary); return ( Date: Tue, 13 Jan 2026 15:32:39 +0700 Subject: [PATCH 5/9] refactor(FE): Style accounts receivable in red and adjust badge --- .../report/finance/export/CustomerPaymentExportPDF.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx b/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx index 08efa409..5adcb694 100644 --- a/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx +++ b/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx @@ -154,6 +154,9 @@ const pdfStyles = StyleSheet.create({ backgroundColor: '#F97316', color: '#FFFFFF', }, + textError: { + color: '#DC2626', + }, parameterBadge: { backgroundColor: '#F5F5F5', color: '#333333', @@ -389,7 +392,9 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { {formatCurrency(item.payment)} - {formatCurrency(item.accounts_receivable)} + + {formatCurrency(item.accounts_receivable)} + {item.notes ? ( @@ -483,7 +488,7 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { - + {formatCurrency( customerReport.summary.total_accounts_receivable )} From e77a43300a5a42663b32d1852c7956a1a9103739 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Tue, 13 Jan 2026 16:01:30 +0700 Subject: [PATCH 6/9] refactor(FE): Nest project_flock in Recording and update UI --- .../production/recording/RecordingTable.tsx | 8 +- .../recording/form/RecordingForm.tsx | 92 ++++++++++++------- src/types/api/production/recording.d.ts | 44 ++++++--- 3 files changed, 98 insertions(+), 46 deletions(-) diff --git a/src/components/pages/production/recording/RecordingTable.tsx b/src/components/pages/production/recording/RecordingTable.tsx index 39b17ef7..6b10b26e 100644 --- a/src/components/pages/production/recording/RecordingTable.tsx +++ b/src/components/pages/production/recording/RecordingTable.tsx @@ -678,12 +678,13 @@ const RecordingTable = () => { { header: 'Nama Project', cell: (props) => - `Project ${props.row.original.project_flock_kandang_id}`, + props.row.original.project_flock?.flock_name || '-', }, { header: 'Kategori', cell: (props) => { - const category = props.row.original.project_flock_category; + const category = + props.row.original.project_flock?.project_flock_category; if (!category) return '-'; const color = category === 'LAYING' ? 'info' : 'warning'; return ( @@ -706,7 +707,8 @@ const RecordingTable = () => { { header: 'Populasi Awal', cell: (props) => - props.row.original.total_chick_qty?.toLocaleString() || '-', + props.row.original.project_flock?.total_chick_qty?.toLocaleString() || + '-', }, { header: 'Status Approval', diff --git a/src/components/pages/production/recording/form/RecordingForm.tsx b/src/components/pages/production/recording/form/RecordingForm.tsx index 4966172c..5097fe27 100644 --- a/src/components/pages/production/recording/form/RecordingForm.tsx +++ b/src/components/pages/production/recording/form/RecordingForm.tsx @@ -252,9 +252,13 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { : undefined; const projectFlockKandangDetailUrl = useMemo(() => { - if (type === 'add' || !initialValues?.project_flock_kandang_id) return null; - return `${ProjectFlockKandangApi.basePath}/${initialValues.project_flock_kandang_id}`; - }, [type, initialValues?.project_flock_kandang_id]); + if ( + type === 'add' || + !initialValues?.project_flock?.project_flock_kandang_id + ) + return null; + return `${ProjectFlockKandangApi.basePath}/${initialValues.project_flock.project_flock_kandang_id}`; + }, [type, initialValues?.project_flock?.project_flock_kandang_id]); const { data: projectFlockKandangDetailData } = useSWR( projectFlockKandangDetailUrl, @@ -404,12 +408,12 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { }, [approvedProjectFlockKandangsData]); const isLayingCategory = - initialValues?.project_flock_category === 'LAYING' || + initialValues?.project_flock?.project_flock_category === 'LAYING' || projectFlockKandangLookup?.project_flock?.category === 'LAYING' || projectFlockKandangDetail?.project_flock?.category === 'LAYING'; const isGrowingCategory = - initialValues?.project_flock_category === 'GROWING' || + initialValues?.project_flock?.project_flock_category === 'GROWING' || projectFlockKandangLookup?.project_flock?.category === 'GROWING' || projectFlockKandangDetail?.project_flock?.category === 'GROWING'; @@ -555,7 +559,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { todayRecordings.forEach((recording) => { const recordingDate = recording.record_datetime?.split('T')[0]; if (recordingDate === today) { - recordedIds.add(recording.project_flock_kandang_id); + recordedIds.add(recording.project_flock.project_flock_kandang_id); } }); @@ -1005,7 +1009,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { const hasSameDayRecording = isResponseSuccess(existingRecordings) ? existingRecordings.data?.some( (recording: Recording) => - recording.project_flock_kandang_id === + recording.project_flock.project_flock_kandang_id === projectFlockKandangId && recording.day === nextDayRecording.next_day ) @@ -1543,13 +1547,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { - {initialValues.project_flock_category} + {initialValues.project_flock?.project_flock_category}

@@ -1579,7 +1584,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { {type === 'detail' && initialValues && (
{ - {initialValues.fcr_std && initialValues.fcr_std > 0 - ? formatNumber(initialValues.fcr_std) + {initialValues.project_flock?.fcr?.fcr_std && + initialValues.project_flock?.fcr?.fcr_std > 0 + ? formatNumber( + initialValues.project_flock?.fcr?.fcr_std + ) : '-'} @@ -1630,9 +1638,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { - {initialValues.feed_intake_std && - initialValues.feed_intake_std > 0 - ? formatNumber(initialValues.feed_intake_std) + {initialValues.project_flock?.production_standart + ?.feed_intake_std && + initialValues.project_flock?.production_standart + ?.feed_intake_std > 0 + ? formatNumber( + initialValues.project_flock?.production_standart + ?.feed_intake_std + ) : '-'} @@ -1698,9 +1711,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { colSpan={2} className='text-center py-3 font-semibold' > - {initialValues.total_chick_qty && - initialValues.total_chick_qty > 0 - ? formatNumber(initialValues.total_chick_qty) + {initialValues.project_flock?.total_chick_qty && + initialValues.project_flock?.total_chick_qty > 0 + ? formatNumber( + initialValues.project_flock?.total_chick_qty + ) : '-'} @@ -1712,7 +1727,8 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { {/* Egg Production Section - Only for LAYING category */} {type === 'detail' && initialValues && - initialValues.project_flock_category === 'LAYING' && ( + initialValues.project_flock?.project_flock_category === + 'LAYING' && (
@@ -1744,9 +1760,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { - {initialValues.egg_mass_std && - initialValues.egg_mass_std > 0 - ? formatNumber(initialValues.egg_mass_std) + {initialValues.project_flock?.production_standart + ?.egg_mass_std && + initialValues.project_flock?.production_standart + ?.egg_mass_std > 0 + ? formatNumber( + initialValues.project_flock + ?.production_standart?.egg_mass_std + ) : '-'} @@ -1763,9 +1784,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { - {initialValues.egg_weight_std && - initialValues.egg_weight_std > 0 - ? formatNumber(initialValues.egg_weight_std) + {initialValues.project_flock?.production_standart + ?.egg_weight_std && + initialValues.project_flock?.production_standart + ?.egg_weight_std > 0 + ? formatNumber( + initialValues.project_flock + ?.production_standart?.egg_weight_std + ) : '-'} @@ -1780,9 +1806,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { - {initialValues.hen_day_std !== undefined && - initialValues.hen_day_std > 0 - ? `${initialValues.hen_day_std}%` + {initialValues.project_flock?.production_standart + ?.hen_day_std !== undefined && + initialValues.project_flock?.production_standart + ?.hen_day_std > 0 + ? `${initialValues.project_flock?.production_standart?.hen_day_std}%` : '-'} @@ -1797,9 +1825,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { - {initialValues.hen_house_std !== undefined && - initialValues.hen_house_std > 0 - ? `${initialValues.hen_house_std}%` + {initialValues.project_flock?.production_standart + ?.hen_house_std !== undefined && + initialValues.project_flock?.production_standart + ?.hen_house_std > 0 + ? `${initialValues.project_flock?.production_standart?.hen_house_std}%` : '-'} diff --git a/src/types/api/production/recording.d.ts b/src/types/api/production/recording.d.ts index 1728516a..079bf045 100644 --- a/src/types/api/production/recording.d.ts +++ b/src/types/api/production/recording.d.ts @@ -1,34 +1,52 @@ import { BaseApproval, BaseMetadata, User } from '@/types/api/api-general'; import { ProductWarehouse } from '@/types/api/inventory/product-warehouse'; +import { Warehouse } from '@/types/api/master-data/warehouse'; + +export type ProductionStandard = { + id: number; + week: number; + name: string; + hen_day_std: number; + hen_house_std: number; + feed_intake_std: number; + max_depletion_std: number; + egg_mass_std: number; + egg_weight_std: number; +}; + +export type FCR = { + id: number; + name: string; + fcr_std: number; +}; + +export type ProjectFlock = { + project_flock_kandang_id: number; + flock_name: string; + project_flock_category: 'GROWING' | 'LAYING'; + period: number; + production_standart: ProductionStandard; + fcr: FCR; + total_chick_qty: number; +}; export type ProductionMetrics = { total_depletion_qty: number; cum_depletion_rate: number; cum_intake: number; fcr_value: number; - fcr_std?: number; - total_chick_qty: number; hen_day?: number; hen_house?: number; feed_intake?: number; - feed_intake_std?: number; egg_mass?: number; egg_weight?: number; - hen_day_std?: number; - hen_house_std?: number; - egg_mass_std?: number; - egg_weight_std?: number; - daily_gain?: number; - avg_daily_gain?: number; - cum_depletion?: number; }; export type BaseRecording = { id: number; - project_flock_kandang_id: number; + project_flock: ProjectFlock; record_datetime: string; day: number; - project_flock_category?: 'GROWING' | 'LAYING'; } & ProductionMetrics; export type RecordingDepletion = { @@ -68,6 +86,8 @@ export type Recording = BaseMetadata & BaseRecording & { approval?: BaseApproval; created_user: User; + warehouse?: Warehouse; + product_category?: 'GROWING' | 'LAYING'; depletions?: RecordingDepletion[]; stocks?: RecordingStock[]; eggs?: RecordingEgg[]; From 8481b77c90d38b061440a9a602e519b7d1d35fd3 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Tue, 13 Jan 2026 16:21:41 +0700 Subject: [PATCH 7/9] refactor(FE): Adjust cumulative depletion table layout --- .../recording/form/RecordingForm.tsx | 56 ++++++------------- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/src/components/pages/production/recording/form/RecordingForm.tsx b/src/components/pages/production/recording/form/RecordingForm.tsx index 5097fe27..c279bde7 100644 --- a/src/components/pages/production/recording/form/RecordingForm.tsx +++ b/src/components/pages/production/recording/form/RecordingForm.tsx @@ -1663,54 +1663,31 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
- - - - - - - - - - + - + + + + - - - - - + + +
- DEPLESI KUMULATIF -
- Total - - (%) -
+ Deplesi Kumulatif - {initialValues.total_depletion_qty && - initialValues.total_depletion_qty > 0 - ? formatNumber(initialValues.total_depletion_qty) + {initialValues.cum_depletion_rate && + initialValues.cum_depletion_rate > 0 + ? `${initialValues.cum_depletion_rate.toFixed(2)}%` : '-'} - {initialValues.cum_depletion_rate && - initialValues.cum_depletion_rate > 0 - ? initialValues.cum_depletion_rate.toFixed(2) +
Total Depletion + {initialValues.total_depletion_qty && + initialValues.total_depletion_qty > 0 + ? formatNumber(initialValues.total_depletion_qty) : '-'}
- Total Ayam -
+
Total Ayam {initialValues.project_flock?.total_chick_qty && initialValues.project_flock?.total_chick_qty > 0 ? formatNumber( @@ -1718,6 +1695,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { ) : '-'}
From 582b971c09b6aa394ba5dbbc3ed6db435ad6d5ce Mon Sep 17 00:00:00 2001 From: rstubryan Date: Tue, 13 Jan 2026 16:47:58 +0700 Subject: [PATCH 8/9] refactor(FE): Change endpoint path to reports --- src/components/pages/report/MarketingReportContent.tsx | 2 +- src/services/api/report/marketing-sale.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/pages/report/MarketingReportContent.tsx b/src/components/pages/report/MarketingReportContent.tsx index d54c935a..3ebacecb 100644 --- a/src/components/pages/report/MarketingReportContent.tsx +++ b/src/components/pages/report/MarketingReportContent.tsx @@ -33,7 +33,7 @@ const MarketingReportContent = () => { const [activeTab, setActiveTab] = useState('daily'); return ( -
+
Date: Wed, 14 Jan 2026 00:02:44 +0700 Subject: [PATCH 9/9] refactor(FE): Add record_date to recording payloads --- .../pages/production/recording/form/RecordingForm.tsx | 4 ++++ src/types/api/production/recording.d.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/src/components/pages/production/recording/form/RecordingForm.tsx b/src/components/pages/production/recording/form/RecordingForm.tsx index c279bde7..4f9018fc 100644 --- a/src/components/pages/production/recording/form/RecordingForm.tsx +++ b/src/components/pages/production/recording/form/RecordingForm.tsx @@ -117,8 +117,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { // ===== PAYLOAD CREATION HELPERS ===== const createGrowingPayload = useCallback( (values: RecordingGrowingFormValues) => { + const today = new Date().toISOString().split('T')[0]; return { project_flock_kandang_id: values.project_flock_kandang_id, + record_date: today, stocks: (values.stocks ?? []).map((stock) => ({ product_warehouse_id: stock.product_warehouse_id, qty: Number(stock.qty) || 0, @@ -134,8 +136,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { const createLayingPayload = useCallback( (values: RecordingLayingFormValues) => { + const today = new Date().toISOString().split('T')[0]; return { project_flock_kandang_id: values.project_flock_kandang_id, + record_date: today, stocks: (values.stocks ?? []).map((stock) => ({ product_warehouse_id: stock.product_warehouse_id, qty: Number(stock.qty) || 0, diff --git a/src/types/api/production/recording.d.ts b/src/types/api/production/recording.d.ts index 079bf045..e30abe4c 100644 --- a/src/types/api/production/recording.d.ts +++ b/src/types/api/production/recording.d.ts @@ -101,6 +101,7 @@ export type NextDayRecording = { export type CreateGrowingRecordingPayload = { project_flock_kandang_id: number; + record_date: string; stocks?: { product_warehouse_id: number; qty: number;