chore(FE-199,207): adjust expense type according to the API need

This commit is contained in:
ValdiANS
2025-11-25 09:25:40 +07:00
parent b616f28c95
commit c3e4d4c630
+87 -34
View File
@@ -1,54 +1,107 @@
import { BaseApproval, BaseMetadata } from '@/types/api/api-general';
import { Location } from '@/types/api/master-data/location';
import { Kandang } from '@/types/api/master-data/kandang';
import { Supplier } from '@/types/api/master-data/supplier';
import { Nonstock } from '@/types/api/master-data/nonstock';
import { BaseLocation, Location } from '@/types/api/master-data/location';
import { BaseKandang, Kandang } from '@/types/api/master-data/kandang';
import { BaseSupplier, Supplier } from '@/types/api/master-data/supplier';
import { BaseNonstock, Nonstock } from '@/types/api/master-data/nonstock';
import { BaseUser } from '@/types/api/user';
export type BaseExpense = {
id: number;
reference_number: string;
po_number?: string;
location: Location;
transaction_date: string;
po_number: string | null;
category: 'BOP' | 'NON-BOP';
documents?: {
id: number;
path: string;
}[];
realization_docs?: {
id: number;
path: string;
}[];
expense_date: string;
realization_date?: string;
kandangs: Kandang[];
vendor: Supplier;
request_documents: {
grand_total: number;
location: BaseLocation;
supplier: BaseSupplier;
kandangs: {
id: number;
kandang_id: number;
name: string;
url: string;
pengajuans?: {
id: number;
qty: number;
unit_price: number;
total_price: number;
note?: string;
nonstock: Pick<BaseNonstock, 'id' | 'name' | 'flags'>;
project_flock_kandang: {
id: number;
kandang_id: number;
};
}[];
kandang_expenses: {
kandang: Kandang;
expenses: {
nonstock: Nonstock;
total_quantity: number;
total_expense: number;
notes?: string;
realisasi?: {
id: number;
qty: number;
unit_price: number;
total_price: number;
date: string;
note?: string;
nonstock: Pick<BaseNonstock, 'id' | 'name' | 'flags'>;
project_flock_kandang: {
id: number;
kandang_id: number;
};
}[];
}[];
nominal: number;
paid?: number;
remaining_cost?: number;
approval: BaseApproval;
total_pengajuan: number;
total_realisasi: number;
latest_approval: BaseApproval;
};
export type Expense = BaseMetadata & BaseExpense;
export type CreateExpensePayload = {
locationId: number;
category: 'BOP' | 'NON-BOP';
transaction_date: string;
kandangIds: number[];
vendorId: number;
request_documents: File[];
kandang_expenses: {
kandangId: number;
expenses: {
nonstockId: number;
total_quantity: number;
total_expense: number;
notes?: string;
supplier_id: number;
documents: File[];
cost_per_kandangs: {
kandang_id: number;
cost_items: {
nonstock_id: number;
quantity: number;
total_cost: number;
notes: string;
}[];
}[];
};
export type UpdateExpensePayload = CreateExpensePayload;
export type UpdateExpensePayload = {
category: 'BOP' | 'NON-BOP';
transaction_date: string;
supplier_id: number;
documents: File[];
cost_per_kandang: {
kandang_id: number;
cost_items: {
nonstock_id: number;
quantity: number;
total_cost: number;
notes: string;
}[];
}[];
};
export type CreateExpenseRealizationPayload = {
realization_date: string;
documents: File[];
realizations: {
expense_nonstock_id: number;
qty: number;
unit_price: number;
total_price: number;
notes: string;
}[];
};
export type UpdateExpenseRealizationPayload = CreateExpenseRealizationPayload;