mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +00:00
Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into feat/FE/US-285/marketing-closing-report
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import { BaseApiService } from './base';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import { ClosingSales } from '@/types/api/closing/closing';
|
||||
import axios from 'axios';
|
||||
|
||||
export class ClosingApiService extends BaseApiService<
|
||||
ClosingSales,
|
||||
unknown,
|
||||
unknown
|
||||
> {
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import {
|
||||
Closing,
|
||||
ClosingGeneralInformation,
|
||||
ClosingIncomingSapronak,
|
||||
ClosingOutgoingSapronak,
|
||||
} from '@/types/api/closing';
|
||||
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import { ClosingSales } from '@/types/api/closing';
|
||||
|
||||
export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
constructor(basePath: string) {
|
||||
super(basePath);
|
||||
}
|
||||
@@ -19,7 +24,45 @@ export class ClosingApiService extends BaseApiService<
|
||||
return await this.customRequest<BaseApiResponse<ClosingSales>>(
|
||||
getPenjualanPath
|
||||
);
|
||||
} catch {
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse<ClosingSales>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async getAllIncomingSapronakFetcher(
|
||||
endpoint: string
|
||||
): Promise<BaseApiResponse<ClosingIncomingSapronak[]>> {
|
||||
return await httpClientFetcher<BaseApiResponse<ClosingIncomingSapronak[]>>(
|
||||
endpoint
|
||||
);
|
||||
}
|
||||
|
||||
async getAllOutgoingSapronakFetcher(
|
||||
endpoint: string
|
||||
): Promise<BaseApiResponse<ClosingOutgoingSapronak[]>> {
|
||||
return await httpClientFetcher<BaseApiResponse<ClosingOutgoingSapronak[]>>(
|
||||
endpoint
|
||||
);
|
||||
}
|
||||
|
||||
async getGeneralInfo(id: number) {
|
||||
try {
|
||||
const getGeneralInfoPath = `${this.basePath}/${id}`;
|
||||
const getGeneralInfoRes =
|
||||
await httpClient<BaseApiResponse<ClosingGeneralInformation>>(
|
||||
getGeneralInfoPath
|
||||
);
|
||||
|
||||
return getGeneralInfoRes;
|
||||
} catch (error) {
|
||||
if (
|
||||
axios.isAxiosError<BaseApiResponse<ClosingGeneralInformation>>(error)
|
||||
) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
CreateInventoryAdjustmentPayload,
|
||||
InventoryAdjustment,
|
||||
} from '@/types/api/inventory/adjustment';
|
||||
import { InventoryProduct } from '@/types/api/inventory/product';
|
||||
|
||||
export const ProductWarehouseApi = new BaseApiService<
|
||||
ProductWarehouse,
|
||||
@@ -25,8 +26,14 @@ export const MovementApi = new BaseApiService<
|
||||
unknown
|
||||
>('/inventory/transfers');
|
||||
|
||||
export const inventoryAdjustmentApi = new BaseApiService<
|
||||
export const InventoryAdjustmentApi = new BaseApiService<
|
||||
InventoryAdjustment,
|
||||
CreateInventoryAdjustmentPayload,
|
||||
unknown
|
||||
>('/inventory/adjustments');
|
||||
|
||||
export const InventoryProductApi = new BaseApiService<
|
||||
InventoryProduct,
|
||||
unknown,
|
||||
unknown
|
||||
>('/inventory/product-stocks');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseApiService } from './base';
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import {
|
||||
CreateProjectFlockPayload,
|
||||
|
||||
@@ -2,10 +2,189 @@ import { BaseApiService } from '@/services/api/base';
|
||||
import {
|
||||
BaseProjectFlockKandang,
|
||||
ProjectFlockKandang,
|
||||
ClosingProjectFlockKandangPayload,
|
||||
CheckClosingResponse,
|
||||
} from '@/types/api/production/project-flock-kandang';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import { httpClient } from '@/services/http/client';
|
||||
import axios from 'axios';
|
||||
|
||||
export const ProjectFlockKandangApi = new BaseApiService<
|
||||
export class ProjectFlockKandangService extends BaseApiService<
|
||||
BaseProjectFlockKandang,
|
||||
ProjectFlockKandang,
|
||||
unknown
|
||||
>('project-flock-kandang');
|
||||
> {
|
||||
constructor(basePath: string = '') {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close or Unclose Project Flock Kandang
|
||||
*/
|
||||
async closing(
|
||||
id: number,
|
||||
payload: ClosingProjectFlockKandangPayload
|
||||
): Promise<BaseApiResponse<{ message: string }> | undefined> {
|
||||
try {
|
||||
const path = `${this.basePath}/${id}/closing`;
|
||||
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
...(this.header ?? {}),
|
||||
};
|
||||
|
||||
return await httpClient<BaseApiResponse<{ message: string }>>(path, {
|
||||
method: 'POST',
|
||||
body: payload,
|
||||
headers,
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
if (axios.isAxiosError<BaseApiResponse<{ message: string }>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Closing Requirements for Project Flock Kandang
|
||||
* TODO: Replace with actual API call when backend is ready
|
||||
*/
|
||||
async checkClosing(
|
||||
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
|
||||
});
|
||||
|
||||
/*
|
||||
// Original API call - uncomment when backend is ready
|
||||
try {
|
||||
const path = `${this.basePath}/${id}/closing/check`;
|
||||
|
||||
return await httpClient<BaseApiResponse<CheckClosingResponse>>(path, {
|
||||
method: 'GET',
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
if (axios.isAxiosError<BaseApiResponse<CheckClosingResponse>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
export const ProjectFlockKandangApi = new ProjectFlockKandangService(
|
||||
'/production/project-flock-kandangs'
|
||||
);
|
||||
|
||||
@@ -141,6 +141,38 @@ export class ProjectFlockService extends BaseApiService<
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resubmit Project Flock
|
||||
*/
|
||||
async resubmit(
|
||||
id: number,
|
||||
payload: UpdateProjectFlockPayload
|
||||
): Promise<BaseApiResponse<ProjectFlock> | undefined> {
|
||||
try {
|
||||
const updatePath = `${this.basePath}/${id}/resubmit`;
|
||||
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
...(this.header ?? {}),
|
||||
};
|
||||
|
||||
const updateRes = await httpClient<BaseApiResponse<ProjectFlock>>(
|
||||
updatePath,
|
||||
{
|
||||
method: 'PUT',
|
||||
body: payload,
|
||||
headers,
|
||||
}
|
||||
);
|
||||
return updateRes;
|
||||
} catch (error: unknown) {
|
||||
if (axios.isAxiosError<BaseApiResponse<ProjectFlock>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve single Project Flock
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user