mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-21 13:55:45 +00:00
Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-334/TASK-344-345-slicing-and-integrate-expedition-hpp-report-table
This commit is contained in:
+131
-28
@@ -6,10 +6,20 @@ import {
|
||||
ClosingGeneralInformation,
|
||||
ClosingIncomingSapronak,
|
||||
ClosingOutgoingSapronak,
|
||||
ClosingCostOfRevenueExpedition,
|
||||
ClosingOverhead,
|
||||
ClosingSapronakCalculation,
|
||||
} from '@/types/api/closing';
|
||||
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import {
|
||||
dummyGetAllFetcher,
|
||||
dummyGetSingle,
|
||||
dummyGetAllIncomingSapronakFetcher,
|
||||
dummyGetAllOutgoingSapronakFetcher,
|
||||
dummyGetGeneralInfo,
|
||||
dummyGetPerhitunganSapronak,
|
||||
dummyGetOverhead,
|
||||
} from '@/dummy/closing.dummy';
|
||||
import { ClosingSales } from '@/types/api/closing';
|
||||
|
||||
export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
@@ -17,6 +27,38 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
async getAllFetcher(endpoint: string): Promise<BaseApiResponse<Closing[]>> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// return await dummyGetAllFetcher();
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
return await httpClientFetcher<BaseApiResponse<Closing[]>>(endpoint);
|
||||
}
|
||||
|
||||
async getSingle(id: number): Promise<BaseApiResponse<Closing> | undefined> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// try {
|
||||
// return await dummyGetSingle(id);
|
||||
// } catch (error) {
|
||||
// if (axios.isAxiosError<BaseApiResponse<Closing>>(error)) {
|
||||
// return error.response?.data;
|
||||
// }
|
||||
// return undefined;
|
||||
// }
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
try {
|
||||
const getSinglePath = `${this.basePath}/${id}`;
|
||||
const getSingleRes =
|
||||
await httpClient<BaseApiResponse<Closing>>(getSinglePath);
|
||||
return getSingleRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse<Closing>>(error)) {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async getPenjualan(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingSales> | undefined> {
|
||||
@@ -34,31 +76,13 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
}
|
||||
}
|
||||
|
||||
async getHppEkspedisi(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingCostOfRevenueExpedition> | undefined> {
|
||||
try {
|
||||
const getHppEkspedisiPath = `${this.basePath}/${id}/hpp-ekspedisi`;
|
||||
const getHppEkspedisiRes =
|
||||
await httpClient<BaseApiResponse<ClosingCostOfRevenueExpedition>>(
|
||||
getHppEkspedisiPath
|
||||
);
|
||||
return getHppEkspedisiRes;
|
||||
} catch (error) {
|
||||
if (
|
||||
axios.isAxiosError<BaseApiResponse<ClosingCostOfRevenueExpedition>>(
|
||||
error
|
||||
)
|
||||
) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async getAllIncomingSapronakFetcher(
|
||||
endpoint: string
|
||||
): Promise<BaseApiResponse<ClosingIncomingSapronak[]>> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// return await dummyGetAllIncomingSapronakFetcher();
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
return await httpClientFetcher<BaseApiResponse<ClosingIncomingSapronak[]>>(
|
||||
endpoint
|
||||
);
|
||||
@@ -67,19 +91,37 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
async getAllOutgoingSapronakFetcher(
|
||||
endpoint: string
|
||||
): Promise<BaseApiResponse<ClosingOutgoingSapronak[]>> {
|
||||
return await httpClientFetcher<BaseApiResponse<ClosingOutgoingSapronak[]>>(
|
||||
endpoint
|
||||
);
|
||||
// TODO: Remove this block when backend is ready
|
||||
return await dummyGetAllOutgoingSapronakFetcher();
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
// return await httpClientFetcher<BaseApiResponse<ClosingOutgoingSapronak[]>>(
|
||||
// endpoint
|
||||
// );
|
||||
}
|
||||
|
||||
async getGeneralInfo(id: number) {
|
||||
async getGeneralInfo(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingGeneralInformation> | undefined> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// try {
|
||||
// return await dummyGetGeneralInfo(id);
|
||||
// } catch (error) {
|
||||
// if (
|
||||
// axios.isAxiosError<BaseApiResponse<ClosingGeneralInformation>>(error)
|
||||
// ) {
|
||||
// return error.response?.data;
|
||||
// }
|
||||
// return undefined;
|
||||
// }
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
try {
|
||||
const getGeneralInfoPath = `${this.basePath}/${id}`;
|
||||
const getGeneralInfoRes =
|
||||
await httpClient<BaseApiResponse<ClosingGeneralInformation>>(
|
||||
getGeneralInfoPath
|
||||
);
|
||||
|
||||
return getGeneralInfoRes;
|
||||
} catch (error) {
|
||||
if (
|
||||
@@ -90,6 +132,67 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async getPerhitunganSapronak(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingSapronakCalculation> | undefined> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// try {
|
||||
// return await dummyGetPerhitunganSapronak(id);
|
||||
// } catch (error) {
|
||||
// if (
|
||||
// axios.isAxiosError<BaseApiResponse<ClosingSapronakCalculation>>(error)
|
||||
// ) {
|
||||
// return error.response?.data;
|
||||
// }
|
||||
// return undefined;
|
||||
// }
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
try {
|
||||
const path = `${this.basePath}/${id}/perhitungan_sapronak`;
|
||||
return await httpClient<BaseApiResponse<ClosingSapronakCalculation>>(
|
||||
path,
|
||||
{
|
||||
method: 'GET',
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
if (
|
||||
axios.isAxiosError<BaseApiResponse<ClosingSapronakCalculation>>(error)
|
||||
) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async getOverhead(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingOverhead> | undefined> {
|
||||
// TODO: Remove this block when backend is ready
|
||||
// try {
|
||||
// return await dummyGetOverhead(id);
|
||||
// } catch (error) {
|
||||
// if (axios.isAxiosError<BaseApiResponse<ClosingOverhead>>(error)) {
|
||||
// return error.response?.data;
|
||||
// }
|
||||
// return undefined;
|
||||
// }
|
||||
|
||||
// Uncomment this when backend is ready
|
||||
try {
|
||||
const path = `${this.basePath}/${id}/overhead`;
|
||||
return await httpClient<BaseApiResponse<ClosingOverhead>>(path, {
|
||||
method: 'GET',
|
||||
});
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse<ClosingOverhead>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const ClosingApi = new ClosingApiService('/closings');
|
||||
|
||||
@@ -54,120 +54,119 @@ export class ProjectFlockKandangService extends BaseApiService<
|
||||
id: number
|
||||
): Promise<BaseApiResponse<CheckClosingResponse> | undefined> {
|
||||
// Dummy data - replace with actual API call when backend is ready
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve({
|
||||
code: 200,
|
||||
status: 'success',
|
||||
message: 'Cek persyaratan closing kandang',
|
||||
data: {
|
||||
unfinished_expenses: 2,
|
||||
stock_remaining: [
|
||||
{
|
||||
id: 1,
|
||||
product_id: 1,
|
||||
warehouse_id: 1,
|
||||
quantity: 0,
|
||||
product: {
|
||||
id: 1,
|
||||
name: 'Pakan Starter',
|
||||
brand: 'Brand A',
|
||||
sku: 'PKN-STR-001',
|
||||
product_price: 15000,
|
||||
selling_price: 17000,
|
||||
tax: 0,
|
||||
expiry_period: 365,
|
||||
flags: ['active'],
|
||||
uom: {
|
||||
id: 1,
|
||||
name: 'Kg',
|
||||
created_user: {
|
||||
id: 1,
|
||||
id_user: 1,
|
||||
email: 'admin@example.com',
|
||||
name: 'Admin User',
|
||||
},
|
||||
created_at: '2024-01-01',
|
||||
updated_at: '2024-01-01',
|
||||
},
|
||||
product_category: {
|
||||
id: 1,
|
||||
name: 'Pakan',
|
||||
code: 'PKN',
|
||||
created_user: {
|
||||
id: 1,
|
||||
id_user: 1,
|
||||
email: 'admin@example.com',
|
||||
name: 'Admin User',
|
||||
},
|
||||
created_at: '2024-01-01',
|
||||
updated_at: '2024-01-01',
|
||||
},
|
||||
suppliers: [],
|
||||
created_user: {
|
||||
id: 1,
|
||||
id_user: 1,
|
||||
email: 'admin@example.com',
|
||||
name: 'Admin User',
|
||||
},
|
||||
created_at: '2024-01-01',
|
||||
updated_at: '2024-01-01',
|
||||
},
|
||||
warehouse: {
|
||||
id: 1,
|
||||
name: 'Gudang Utama',
|
||||
type: 'AREA',
|
||||
area: {
|
||||
id: 1,
|
||||
name: 'Area 1',
|
||||
},
|
||||
created_user: {
|
||||
id: 1,
|
||||
id_user: 1,
|
||||
email: 'admin@example.com',
|
||||
name: 'Admin User',
|
||||
},
|
||||
created_at: '2024-01-01',
|
||||
updated_at: '2024-01-01',
|
||||
},
|
||||
created_user: {
|
||||
id: 1,
|
||||
id_user: 1,
|
||||
email: 'admin@example.com',
|
||||
name: 'Admin User',
|
||||
},
|
||||
created_at: '2025-01-01',
|
||||
updated_at: '2025-01-01',
|
||||
},
|
||||
],
|
||||
expenses: [
|
||||
{
|
||||
id: 1,
|
||||
po_number: 'PO-BOP-LTI-00001',
|
||||
category: 'NON-BOP',
|
||||
total: 110000,
|
||||
status: 'SELESAI',
|
||||
step_name: 'Approval Finance',
|
||||
step: 5,
|
||||
reference_number: 'BOP-LTI-00001',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
po_number: 'PO-BOP-LTI-00003',
|
||||
category: 'BOP',
|
||||
total: 110000,
|
||||
status: 'SELESAI',
|
||||
step_name: 'Approval Finance',
|
||||
step: 5,
|
||||
reference_number: 'BOP-LTI-00003',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
}, 500); // Simulate network delay
|
||||
});
|
||||
// return new Promise((resolve) => {
|
||||
// setTimeout(() => {
|
||||
// resolve({
|
||||
// code: 200,
|
||||
// status: 'success',
|
||||
// message: 'Cek persyaratan closing kandang',
|
||||
// data: {
|
||||
// unfinished_expenses: id % 2 === 1 ? 2 : 0,
|
||||
// stock_remaining: [
|
||||
// {
|
||||
// id: 1,
|
||||
// product_id: 1,
|
||||
// warehouse_id: 1,
|
||||
// quantity: id % 2 === 1 ? 100 : 0,
|
||||
// product: {
|
||||
// id: 1,
|
||||
// name: 'Pakan Starter',
|
||||
// brand: 'Brand A',
|
||||
// sku: 'PKN-STR-001',
|
||||
// product_price: 15000,
|
||||
// selling_price: 17000,
|
||||
// tax: 0,
|
||||
// expiry_period: 365,
|
||||
// flags: ['active'],
|
||||
// uom: {
|
||||
// id: 1,
|
||||
// name: 'Kg',
|
||||
// created_user: {
|
||||
// id: 1,
|
||||
// id_user: 1,
|
||||
// email: 'admin@example.com',
|
||||
// name: 'Admin User',
|
||||
// },
|
||||
// created_at: '2024-01-01',
|
||||
// updated_at: '2024-01-01',
|
||||
// },
|
||||
// product_category: {
|
||||
// id: 1,
|
||||
// name: 'Pakan',
|
||||
// code: 'PKN',
|
||||
// created_user: {
|
||||
// id: 1,
|
||||
// id_user: 1,
|
||||
// email: 'admin@example.com',
|
||||
// name: 'Admin User',
|
||||
// },
|
||||
// created_at: '2024-01-01',
|
||||
// updated_at: '2024-01-01',
|
||||
// },
|
||||
// suppliers: [],
|
||||
// created_user: {
|
||||
// id: 1,
|
||||
// id_user: 1,
|
||||
// email: 'admin@example.com',
|
||||
// name: 'Admin User',
|
||||
// },
|
||||
// created_at: '2024-01-01',
|
||||
// updated_at: '2024-01-01',
|
||||
// },
|
||||
// warehouse: {
|
||||
// id: 1,
|
||||
// name: 'Gudang Utama',
|
||||
// type: 'AREA',
|
||||
// area: {
|
||||
// id: 1,
|
||||
// name: 'Area 1',
|
||||
// },
|
||||
// created_user: {
|
||||
// id: 1,
|
||||
// id_user: 1,
|
||||
// email: 'admin@example.com',
|
||||
// name: 'Admin User',
|
||||
// },
|
||||
// created_at: '2024-01-01',
|
||||
// updated_at: '2024-01-01',
|
||||
// },
|
||||
// created_user: {
|
||||
// id: 1,
|
||||
// id_user: 1,
|
||||
// email: 'admin@example.com',
|
||||
// name: 'Admin User',
|
||||
// },
|
||||
// created_at: '2025-01-01',
|
||||
// updated_at: '2025-01-01',
|
||||
// },
|
||||
// ],
|
||||
// expenses: [
|
||||
// {
|
||||
// id: 1,
|
||||
// po_number: 'PO-BOP-LTI-00001',
|
||||
// category: 'NON-BOP',
|
||||
// total: 110000,
|
||||
// status: id % 2 === 1 ? 'PENGAJUAN' : 'SELESAI',
|
||||
// step_name: id % 2 === 1 ? 'Approval Finance' : 'Selesai',
|
||||
// step: id % 2 === 1 ? 1 : 5,
|
||||
// reference_number: 'BOP-LTI-00001',
|
||||
// },
|
||||
// {
|
||||
// id: 3,
|
||||
// po_number: 'PO-BOP-LTI-00003',
|
||||
// category: 'BOP',
|
||||
// total: 110000,
|
||||
// status: id % 2 === 1 ? 'PENGAJUAN' : 'SELESAI',
|
||||
// step_name: id % 2 === 1 ? 'Approval Finance' : 'Selesai',
|
||||
// step: id % 2 === 1 ? 1 : 5,
|
||||
// reference_number: 'BOP-LTI-00003',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// });
|
||||
// }, 500); // Simulate network delay
|
||||
// });
|
||||
|
||||
/*
|
||||
// Original API call - uncomment when backend is ready
|
||||
try {
|
||||
const path = `${this.basePath}/${id}/closing/check`;
|
||||
@@ -181,7 +180,6 @@ export class ProjectFlockKandangService extends BaseApiService<
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user