mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 22b3350e4a | |||
| a314a62f1f | |||
| 2bf5f36a77 | |||
| 989e30fbed | |||
| 40139cd636 | |||
| 8c03f10043 | |||
| 89a6e51b48 | |||
| f6727dc4dc | |||
| 1284b22345 | |||
| f73ea182ae | |||
| 047266b6d8 | |||
| 6b95edfb72 | |||
| 4b62b02a13 | |||
| 12a50c6100 | |||
| 09537d84d0 | |||
| 1aa2ca9b31 | |||
| c87107b4ee | |||
| 55b13988bf | |||
| 19033278b3 | |||
| 4a6ac8a57d | |||
| 2b9847e1a9 | |||
| 167769a711 | |||
| 417dbba458 |
@@ -48,6 +48,3 @@ next-env.d.ts
|
|||||||
|
|
||||||
# rtk
|
# rtk
|
||||||
rtk.exe
|
rtk.exe
|
||||||
|
|
||||||
# local specs
|
|
||||||
/local-specs
|
|
||||||
@@ -233,13 +233,8 @@ const TransferToLayingFormModal = () => {
|
|||||||
|
|
||||||
const [maxSourceQuantity, setMaxSourceQuantity] = useState<number>(0);
|
const [maxSourceQuantity, setMaxSourceQuantity] = useState<number>(0);
|
||||||
|
|
||||||
const selectedFlockDestinationRawData = isResponseSuccess(
|
const [selectedFlockDestinationRawData, setSelectedFlockDestinationRawData] =
|
||||||
flockDestinationRawData
|
useState<ProjectFlock | undefined>(undefined);
|
||||||
)
|
|
||||||
? flockDestinationRawData.data.find(
|
|
||||||
(item) => item.id === formik.values.flockDestination?.value
|
|
||||||
)
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
const { data: flockSourceKandangsAvailability } = useSWR(
|
const { data: flockSourceKandangsAvailability } = useSWR(
|
||||||
formik.values.flockSource
|
formik.values.flockSource
|
||||||
@@ -456,15 +451,37 @@ const TransferToLayingFormModal = () => {
|
|||||||
}, [transferToLayingId, transferToLaying]);
|
}, [transferToLayingId, transferToLaying]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!formik.values.flockSource) {
|
||||||
|
setSelectedFlockSourceRawData(undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (isResponseSuccess(flockSourceRawData)) {
|
if (isResponseSuccess(flockSourceRawData)) {
|
||||||
const currentSelectedFlockSourceRawData = flockSourceRawData.data.find(
|
const found = flockSourceRawData.data.find(
|
||||||
(item) => item.id === formik.values.flockSource?.value
|
(item) => item.id === formik.values.flockSource?.value
|
||||||
);
|
);
|
||||||
|
if (found) {
|
||||||
setSelectedFlockSourceRawData(currentSelectedFlockSourceRawData);
|
setSelectedFlockSourceRawData(found);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [flockSourceRawData, formikFlockSource]);
|
}, [flockSourceRawData, formikFlockSource]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!formik.values.flockDestination) {
|
||||||
|
setSelectedFlockDestinationRawData(undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isResponseSuccess(flockDestinationRawData)) {
|
||||||
|
const found = flockDestinationRawData.data.find(
|
||||||
|
(item) => item.id === formik.values.flockDestination?.value
|
||||||
|
);
|
||||||
|
if (found) {
|
||||||
|
setSelectedFlockDestinationRawData(found);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [flockDestinationRawData, formik.values.flockDestination]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
formik.setFieldValue('totalQuantity', totalTransferedChicken);
|
formik.setFieldValue('totalQuantity', totalTransferedChicken);
|
||||||
formik.setFieldValue('maxTotalQuantity', totalTransferedChicken);
|
formik.setFieldValue('maxTotalQuantity', totalTransferedChicken);
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import {
|
|||||||
CustomerPaymentFilterSchema,
|
CustomerPaymentFilterSchema,
|
||||||
CustomerPaymentFilterType,
|
CustomerPaymentFilterType,
|
||||||
} from '@/components/pages/report/finance/filter/CustomerPaymentFilter';
|
} from '@/components/pages/report/finance/filter/CustomerPaymentFilter';
|
||||||
|
import { generateCustomerPaymentExcel } from '@/components/pages/report/finance/export/CustomerPaymentExportXLSX';
|
||||||
import { generateCustomerPaymentPDF } from '@/components/pages/report/finance/export/CustomerPaymentExportPDF';
|
import { generateCustomerPaymentPDF } from '@/components/pages/report/finance/export/CustomerPaymentExportPDF';
|
||||||
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
import { useTabActionsStore } from '@/stores/tab-actions/tab-actions.store';
|
||||||
import CustomerSupplierSkeleton from '@/components/pages/report/finance/skeleton/CustomerSupplierSkeleton';
|
import CustomerSupplierSkeleton from '@/components/pages/report/finance/skeleton/CustomerSupplierSkeleton';
|
||||||
@@ -54,10 +55,7 @@ const CustomerPaymentTab = ({ tabId }: CustomerPaymentTabProps) => {
|
|||||||
// ===== STATE MANAGEMENT =====
|
// ===== STATE MANAGEMENT =====
|
||||||
const [isPdfExportLoading, setIsPdfExportLoading] = useState(false);
|
const [isPdfExportLoading, setIsPdfExportLoading] = useState(false);
|
||||||
const [isExcelExportLoading, setIsExcelExportLoading] = useState(false);
|
const [isExcelExportLoading, setIsExcelExportLoading] = useState(false);
|
||||||
const [isExcelGeneralExportLoading, setIsExcelGeneralExportLoading] =
|
const isAnyExportLoading = isPdfExportLoading || isExcelExportLoading;
|
||||||
useState(false);
|
|
||||||
const isAnyExportLoading =
|
|
||||||
isPdfExportLoading || isExcelExportLoading || isExcelGeneralExportLoading;
|
|
||||||
|
|
||||||
// ===== PAGINATION STATE =====
|
// ===== PAGINATION STATE =====
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
@@ -296,39 +294,28 @@ const CustomerPaymentTab = ({ tabId }: CustomerPaymentTabProps) => {
|
|||||||
}, [filterParams]);
|
}, [filterParams]);
|
||||||
|
|
||||||
// ===== EXPORT HANDLERS =====
|
// ===== EXPORT HANDLERS =====
|
||||||
const handleExportExcelGeneral = useCallback(async () => {
|
|
||||||
setIsExcelGeneralExportLoading(true);
|
|
||||||
try {
|
|
||||||
await FinanceApi.exportCustomerPaymentToExcelGeneral(
|
|
||||||
filterParams.customer_ids,
|
|
||||||
filterParams.filter_by,
|
|
||||||
filterParams.start_date,
|
|
||||||
filterParams.end_date
|
|
||||||
);
|
|
||||||
toast.success('Excel General berhasil dibuat dan diunduh.');
|
|
||||||
} catch {
|
|
||||||
toast.error('Gagal membuat Excel General. Silakan coba lagi.');
|
|
||||||
} finally {
|
|
||||||
setIsExcelGeneralExportLoading(false);
|
|
||||||
}
|
|
||||||
}, [filterParams]);
|
|
||||||
|
|
||||||
const handleExportExcel = useCallback(async () => {
|
const handleExportExcel = useCallback(async () => {
|
||||||
setIsExcelExportLoading(true);
|
setIsExcelExportLoading(true);
|
||||||
try {
|
try {
|
||||||
await FinanceApi.exportCustomerPaymentToExcelCustomerPerSheet(
|
const allDataForExport = await customerPaymentExport();
|
||||||
filterParams.customer_ids,
|
|
||||||
filterParams.filter_by,
|
if (
|
||||||
filterParams.start_date,
|
!allDataForExport ||
|
||||||
filterParams.end_date
|
!Array.isArray(allDataForExport) ||
|
||||||
);
|
allDataForExport.length === 0
|
||||||
|
) {
|
||||||
|
toast.error('Tidak ada data untuk diekspor.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await generateCustomerPaymentExcel({ data: allDataForExport });
|
||||||
toast.success('Excel berhasil dibuat dan diunduh.');
|
toast.success('Excel berhasil dibuat dan diunduh.');
|
||||||
} catch {
|
} catch {
|
||||||
toast.error('Gagal membuat Excel. Silakan coba lagi.');
|
toast.error('Gagal membuat Excel. Silakan coba lagi.');
|
||||||
} finally {
|
} finally {
|
||||||
setIsExcelExportLoading(false);
|
setIsExcelExportLoading(false);
|
||||||
}
|
}
|
||||||
}, [filterParams]);
|
}, [customerPaymentExport]);
|
||||||
|
|
||||||
const handleExportPdf = useCallback(async () => {
|
const handleExportPdf = useCallback(async () => {
|
||||||
setIsPdfExportLoading(true);
|
setIsPdfExportLoading(true);
|
||||||
@@ -435,19 +422,8 @@ const CustomerPaymentTab = ({ tabId }: CustomerPaymentTabProps) => {
|
|||||||
className='w-full p-3 justify-start text-sm text-base-content/50 font-semibold text-nowrap'
|
className='w-full p-3 justify-start text-sm text-base-content/50 font-semibold text-nowrap'
|
||||||
>
|
>
|
||||||
<Icon icon='heroicons:table-cells' width={20} height={20} />
|
<Icon icon='heroicons:table-cells' width={20} height={20} />
|
||||||
Export to Excel - Customer Per Sheet
|
Export to Excel
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
|
||||||
variant='ghost'
|
|
||||||
color='none'
|
|
||||||
onClick={handleExportExcelGeneral}
|
|
||||||
isLoading={isExcelGeneralExportLoading}
|
|
||||||
className='w-full p-3 justify-start text-sm text-base-content/50 font-semibold text-nowrap'
|
|
||||||
>
|
|
||||||
<Icon icon='heroicons:table-cells' width={20} height={20} />
|
|
||||||
Export to Excel - General
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant='ghost'
|
variant='ghost'
|
||||||
color='none'
|
color='none'
|
||||||
@@ -474,10 +450,8 @@ const CustomerPaymentTab = ({ tabId }: CustomerPaymentTabProps) => {
|
|||||||
}, [
|
}, [
|
||||||
tabId,
|
tabId,
|
||||||
isAnyExportLoading,
|
isAnyExportLoading,
|
||||||
handleExportExcelGeneral,
|
|
||||||
handleExportExcel,
|
handleExportExcel,
|
||||||
handleExportPdf,
|
handleExportPdf,
|
||||||
isExcelGeneralExportLoading,
|
|
||||||
isExcelExportLoading,
|
isExcelExportLoading,
|
||||||
isPdfExportLoading,
|
isPdfExportLoading,
|
||||||
filterParams,
|
filterParams,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
DebtSupplier,
|
DebtSupplier,
|
||||||
DebtSupplierFilter,
|
DebtSupplierFilter,
|
||||||
} from '@/types/api/report/debt-supplier';
|
} from '@/types/api/report/debt-supplier';
|
||||||
|
import { generateDebtSupplierExcel } from '@/components/pages/report/finance/export/DebtSupplierExportXLSX';
|
||||||
import { generateDebtSupplierPDF } from '@/components/pages/report/finance/export/DebtSupllierExportPDF';
|
import { generateDebtSupplierPDF } from '@/components/pages/report/finance/export/DebtSupllierExportPDF';
|
||||||
import { Icon } from '@iconify/react';
|
import { Icon } from '@iconify/react';
|
||||||
import { ColumnDef } from '@tanstack/react-table';
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
@@ -76,10 +77,7 @@ const DebtSupplierTab = ({ tabId }: DebtSupplierTabProps) => {
|
|||||||
// ===== STATE MANAGEMENT =====
|
// ===== STATE MANAGEMENT =====
|
||||||
const [isPdfExportLoading, setIsPdfExportLoading] = useState(false);
|
const [isPdfExportLoading, setIsPdfExportLoading] = useState(false);
|
||||||
const [isExcelExportLoading, setIsExcelExportLoading] = useState(false);
|
const [isExcelExportLoading, setIsExcelExportLoading] = useState(false);
|
||||||
const [isExcelGeneralExportLoading, setIsExcelGeneralExportLoading] =
|
const isAnyExportLoading = isPdfExportLoading || isExcelExportLoading;
|
||||||
useState(false);
|
|
||||||
const isAnyExportLoading =
|
|
||||||
isPdfExportLoading || isExcelExportLoading || isExcelGeneralExportLoading;
|
|
||||||
|
|
||||||
// ===== PAGINATION STATE =====
|
// ===== PAGINATION STATE =====
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
@@ -251,19 +249,25 @@ const DebtSupplierTab = ({ tabId }: DebtSupplierTabProps) => {
|
|||||||
const handleExportExcel = useCallback(async () => {
|
const handleExportExcel = useCallback(async () => {
|
||||||
setIsExcelExportLoading(true);
|
setIsExcelExportLoading(true);
|
||||||
try {
|
try {
|
||||||
await DebtSupplierApi.exportToExcelSupplierPerSheet(
|
const allDataForExport = await debtSupplierExport();
|
||||||
filterParams.supplier_ids,
|
|
||||||
filterParams.filter_by,
|
if (
|
||||||
filterParams.start_date,
|
!allDataForExport ||
|
||||||
filterParams.end_date
|
!Array.isArray(allDataForExport) ||
|
||||||
);
|
allDataForExport.length === 0
|
||||||
|
) {
|
||||||
|
toast.error('Tidak ada data untuk diekspor.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
generateDebtSupplierExcel({ data: allDataForExport });
|
||||||
toast.success('Excel berhasil dibuat dan diunduh.');
|
toast.success('Excel berhasil dibuat dan diunduh.');
|
||||||
} catch {
|
} catch {
|
||||||
toast.error('Gagal membuat Excel. Silakan coba lagi.');
|
toast.error('Gagal membuat Excel. Silakan coba lagi.');
|
||||||
} finally {
|
} finally {
|
||||||
setIsExcelExportLoading(false);
|
setIsExcelExportLoading(false);
|
||||||
}
|
}
|
||||||
}, [filterParams]);
|
}, [debtSupplierExport]);
|
||||||
|
|
||||||
const handleExportPdf = useCallback(async () => {
|
const handleExportPdf = useCallback(async () => {
|
||||||
setIsPdfExportLoading(true);
|
setIsPdfExportLoading(true);
|
||||||
@@ -304,23 +308,6 @@ const DebtSupplierTab = ({ tabId }: DebtSupplierTabProps) => {
|
|||||||
formik.values.endDate,
|
formik.values.endDate,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const handleExportExcelGeneral = useCallback(async () => {
|
|
||||||
setIsExcelGeneralExportLoading(true);
|
|
||||||
try {
|
|
||||||
await DebtSupplierApi.exportToExcelGeneral(
|
|
||||||
filterParams.supplier_ids,
|
|
||||||
filterParams.filter_by,
|
|
||||||
filterParams.start_date,
|
|
||||||
filterParams.end_date
|
|
||||||
);
|
|
||||||
toast.success('Excel General berhasil dibuat dan diunduh.');
|
|
||||||
} catch {
|
|
||||||
toast.error('Gagal membuat Excel General. Silakan coba lagi.');
|
|
||||||
} finally {
|
|
||||||
setIsExcelGeneralExportLoading(false);
|
|
||||||
}
|
|
||||||
}, [filterParams]);
|
|
||||||
|
|
||||||
// ===== TAB ACTIONS COMPONENT =====
|
// ===== TAB ACTIONS COMPONENT =====
|
||||||
const TabActions = useMemo(() => {
|
const TabActions = useMemo(() => {
|
||||||
return function TabActionsComponent() {
|
return function TabActionsComponent() {
|
||||||
@@ -383,17 +370,7 @@ const DebtSupplierTab = ({ tabId }: DebtSupplierTabProps) => {
|
|||||||
className='w-full p-3 justify-start text-sm text-base-content/50 font-semibold text-nowrap'
|
className='w-full p-3 justify-start text-sm text-base-content/50 font-semibold text-nowrap'
|
||||||
>
|
>
|
||||||
<Icon icon='heroicons:table-cells' width={20} height={20} />
|
<Icon icon='heroicons:table-cells' width={20} height={20} />
|
||||||
Export to Excel - Supplier Per Sheet
|
Export to Excel
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
variant='ghost'
|
|
||||||
color='none'
|
|
||||||
onClick={handleExportExcelGeneral}
|
|
||||||
isLoading={isExcelGeneralExportLoading}
|
|
||||||
className='w-full p-3 justify-start text-sm text-base-content/50 font-semibold text-nowrap'
|
|
||||||
>
|
|
||||||
<Icon icon='heroicons:table-cells' width={20} height={20} />
|
|
||||||
Export to Excel - General
|
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
variant='ghost'
|
variant='ghost'
|
||||||
@@ -423,10 +400,8 @@ const DebtSupplierTab = ({ tabId }: DebtSupplierTabProps) => {
|
|||||||
filterParams,
|
filterParams,
|
||||||
isAnyExportLoading,
|
isAnyExportLoading,
|
||||||
handleExportExcel,
|
handleExportExcel,
|
||||||
handleExportExcelGeneral,
|
|
||||||
handleExportPdf,
|
handleExportPdf,
|
||||||
isExcelExportLoading,
|
isExcelExportLoading,
|
||||||
isExcelGeneralExportLoading,
|
|
||||||
isPdfExportLoading,
|
isPdfExportLoading,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -184,11 +184,6 @@ export function DailyChecklistContent() {
|
|||||||
const [emptyKandangEndDateError, setEmptyKandangEndDateError] =
|
const [emptyKandangEndDateError, setEmptyKandangEndDateError] =
|
||||||
useState<string>('');
|
useState<string>('');
|
||||||
|
|
||||||
const [preloadedKandang, setPreloadedKandang] = useState<{
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
} | null>(null);
|
|
||||||
|
|
||||||
const [existingDocuments, setExistingDocuments] = useState<Document[]>([]);
|
const [existingDocuments, setExistingDocuments] = useState<Document[]>([]);
|
||||||
const [documents, setDocuments] = useState<File[]>([]);
|
const [documents, setDocuments] = useState<File[]>([]);
|
||||||
const [deletedDocumentIds, setDeletedDocumentIds] = useState<number[]>([]);
|
const [deletedDocumentIds, setDeletedDocumentIds] = useState<number[]>([]);
|
||||||
@@ -233,11 +228,7 @@ export function DailyChecklistContent() {
|
|||||||
const rawDate = data.date || '';
|
const rawDate = data.date || '';
|
||||||
setDate(rawDate.length > 10 ? rawDate.slice(0, 10) : rawDate);
|
setDate(rawDate.length > 10 ? rawDate.slice(0, 10) : rawDate);
|
||||||
skipKandangClearRef.current = true;
|
skipKandangClearRef.current = true;
|
||||||
const loadedKandangId = String(data.kandang?.id || '');
|
setKandangId(String(data.kandang?.id || ''));
|
||||||
setKandangId(loadedKandangId);
|
|
||||||
if (data.kandang?.name) {
|
|
||||||
setPreloadedKandang({ id: loadedKandangId, name: data.kandang.name });
|
|
||||||
}
|
|
||||||
|
|
||||||
const isEmptyKandang =
|
const isEmptyKandang =
|
||||||
!!data.empty_kandang || data.category === 'empty_kandang';
|
!!data.empty_kandang || data.category === 'empty_kandang';
|
||||||
@@ -1171,17 +1162,9 @@ export function DailyChecklistContent() {
|
|||||||
<SelectValue placeholder='Pilih kandang' />
|
<SelectValue placeholder='Pilih kandang' />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent onScroll={handleKandangScroll}>
|
<SelectContent onScroll={handleKandangScroll}>
|
||||||
{preloadedKandang &&
|
{kandangOptions.map((kandang) => (
|
||||||
!kandangOptions.some(
|
|
||||||
(k) => String(k.value) === preloadedKandang.id
|
|
||||||
) && (
|
|
||||||
<SelectItem value={preloadedKandang.id}>
|
|
||||||
{preloadedKandang.name}
|
|
||||||
</SelectItem>
|
|
||||||
)}
|
|
||||||
{kandangOptions.map((kandang, kandangIdx) => (
|
|
||||||
<SelectItem
|
<SelectItem
|
||||||
key={`${kandang.value}-${kandangIdx}`}
|
key={kandang.value}
|
||||||
value={String(kandang.value)}
|
value={String(kandang.value)}
|
||||||
>
|
>
|
||||||
{kandang.label}
|
{kandang.label}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { BaseApiService } from '@/services/api/base';
|
import { BaseApiService } from '@/services/api/base';
|
||||||
import { httpClient } from '@/services/http/client';
|
|
||||||
import { formatDate } from '@/lib/helper';
|
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
import { BaseApiResponse } from '@/types/api/api-general';
|
||||||
import { DebtSupplier } from '@/types/api/report/debt-supplier';
|
import { DebtSupplier } from '@/types/api/report/debt-supplier';
|
||||||
|
|
||||||
@@ -13,82 +11,6 @@ export class DebtSupplierApiService extends BaseApiService<
|
|||||||
super(basePath);
|
super(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
async exportToExcelGeneral(
|
|
||||||
supplier_ids?: string,
|
|
||||||
filter_by?: string,
|
|
||||||
start_date?: string,
|
|
||||||
end_date?: string
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
|
||||||
|
|
||||||
if (supplier_ids) params.set('supplier_ids', supplier_ids);
|
|
||||||
if (filter_by) params.set('filter_by', filter_by);
|
|
||||||
if (start_date) params.set('start_date', start_date);
|
|
||||||
if (end_date) params.set('end_date', end_date);
|
|
||||||
params.set('export', 'excel-all');
|
|
||||||
params.set('page', '1');
|
|
||||||
params.set('limit', '99999999999');
|
|
||||||
|
|
||||||
const queryString = `?${params.toString()}`;
|
|
||||||
|
|
||||||
const res = await httpClient<Blob>(
|
|
||||||
`${this.basePath.replace(/\/$/, '')}/debt-supplier${queryString}`,
|
|
||||||
{
|
|
||||||
method: 'GET',
|
|
||||||
responseType: 'blob',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const url = window.URL.createObjectURL(new Blob([res]));
|
|
||||||
const link = document.createElement('a');
|
|
||||||
link.href = url;
|
|
||||||
|
|
||||||
const fileName = `laporan-hutang-supplier-general-${formatDate(Date.now(), 'DD-MM-YYYY')}.xlsx`;
|
|
||||||
link.setAttribute('download', fileName);
|
|
||||||
|
|
||||||
document.body.appendChild(link);
|
|
||||||
link.click();
|
|
||||||
link.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
async exportToExcelSupplierPerSheet(
|
|
||||||
supplier_ids?: string,
|
|
||||||
filter_by?: string,
|
|
||||||
start_date?: string,
|
|
||||||
end_date?: string
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
|
||||||
|
|
||||||
if (supplier_ids) params.set('supplier_ids', supplier_ids);
|
|
||||||
if (filter_by) params.set('filter_by', filter_by);
|
|
||||||
if (start_date) params.set('start_date', start_date);
|
|
||||||
if (end_date) params.set('end_date', end_date);
|
|
||||||
params.set('export', 'excel');
|
|
||||||
params.set('page', '1');
|
|
||||||
params.set('limit', '99999999999');
|
|
||||||
|
|
||||||
const queryString = `?${params.toString()}`;
|
|
||||||
|
|
||||||
const res = await httpClient<Blob>(
|
|
||||||
`${this.basePath.replace(/\/$/, '')}/debt-supplier${queryString}`,
|
|
||||||
{
|
|
||||||
method: 'GET',
|
|
||||||
responseType: 'blob',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const url = window.URL.createObjectURL(new Blob([res]));
|
|
||||||
const link = document.createElement('a');
|
|
||||||
link.href = url;
|
|
||||||
|
|
||||||
const fileName = `laporan-hutang-supplier-per-sheet-${formatDate(Date.now(), 'DD-MM-YYYY')}.xlsx`;
|
|
||||||
link.setAttribute('download', fileName);
|
|
||||||
|
|
||||||
document.body.appendChild(link);
|
|
||||||
link.click();
|
|
||||||
link.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
async getDebtSupplierReport(
|
async getDebtSupplierReport(
|
||||||
supplier_ids?: string,
|
supplier_ids?: string,
|
||||||
filter_by?: string,
|
filter_by?: string,
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { BaseApiService } from '@/services/api/base';
|
import { BaseApiService } from '@/services/api/base';
|
||||||
import { httpClient } from '@/services/http/client';
|
|
||||||
import { formatDate } from '@/lib/helper';
|
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
import { BaseApiResponse } from '@/types/api/api-general';
|
||||||
import { CustomerPaymentReport } from '@/types/api/report/customer-payment';
|
import { CustomerPaymentReport } from '@/types/api/report/customer-payment';
|
||||||
|
|
||||||
@@ -13,78 +11,6 @@ export class FinanceApiService extends BaseApiService<
|
|||||||
super(basePath);
|
super(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
async exportCustomerPaymentToExcelGeneral(
|
|
||||||
customer_ids?: string,
|
|
||||||
filter_by?: string,
|
|
||||||
start_date?: string,
|
|
||||||
end_date?: string
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
|
||||||
|
|
||||||
if (customer_ids) params.set('customer_ids', customer_ids);
|
|
||||||
if (filter_by) params.set('filter_by', filter_by);
|
|
||||||
if (start_date) params.set('start_date', start_date);
|
|
||||||
if (end_date) params.set('end_date', end_date);
|
|
||||||
params.set('export', 'excel-all');
|
|
||||||
params.set('page', '1');
|
|
||||||
params.set('limit', '9999999999');
|
|
||||||
|
|
||||||
const res = await httpClient<Blob>(
|
|
||||||
`${this.basePath}/customer-payment?${params.toString()}`,
|
|
||||||
{
|
|
||||||
method: 'GET',
|
|
||||||
responseType: 'blob',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const url = window.URL.createObjectURL(new Blob([res]));
|
|
||||||
const link = document.createElement('a');
|
|
||||||
link.href = url;
|
|
||||||
|
|
||||||
const fileName = `laporan-piutang-customer-general-${formatDate(Date.now(), 'DD-MM-YYYY')}.xlsx`;
|
|
||||||
link.setAttribute('download', fileName);
|
|
||||||
|
|
||||||
document.body.appendChild(link);
|
|
||||||
link.click();
|
|
||||||
link.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
async exportCustomerPaymentToExcelCustomerPerSheet(
|
|
||||||
customer_ids?: string,
|
|
||||||
filter_by?: string,
|
|
||||||
start_date?: string,
|
|
||||||
end_date?: string
|
|
||||||
) {
|
|
||||||
const params = new URLSearchParams();
|
|
||||||
|
|
||||||
if (customer_ids) params.set('customer_ids', customer_ids);
|
|
||||||
if (filter_by) params.set('filter_by', filter_by);
|
|
||||||
if (start_date) params.set('start_date', start_date);
|
|
||||||
if (end_date) params.set('end_date', end_date);
|
|
||||||
params.set('export', 'excel');
|
|
||||||
params.set('page', '1');
|
|
||||||
params.set('limit', '9999999999');
|
|
||||||
|
|
||||||
const res = await httpClient<Blob>(
|
|
||||||
`${this.basePath}/customer-payment?${params.toString()}`,
|
|
||||||
{
|
|
||||||
method: 'GET',
|
|
||||||
responseType: 'blob',
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const url = window.URL.createObjectURL(new Blob([res]));
|
|
||||||
const link = document.createElement('a');
|
|
||||||
link.href = url;
|
|
||||||
|
|
||||||
const fileName = `laporan-piutang-customer-per-sheet-${formatDate(Date.now(), 'DD-MM-YYYY')}.xlsx`;
|
|
||||||
link.setAttribute('download', fileName);
|
|
||||||
|
|
||||||
document.body.appendChild(link);
|
|
||||||
link.click();
|
|
||||||
link.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
async getCustomerPaymentReport(
|
async getCustomerPaymentReport(
|
||||||
customer_ids?: string,
|
customer_ids?: string,
|
||||||
// TODO: Uncomment when BE is ready
|
// TODO: Uncomment when BE is ready
|
||||||
|
|||||||
Reference in New Issue
Block a user