From c3e4d4c630e3c0bf32419b9aa09c12ce0a05fee6 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Tue, 25 Nov 2025 09:25:40 +0700 Subject: [PATCH] chore(FE-199,207): adjust expense type according to the API need --- src/types/api/expense.d.ts | 125 ++++++++++++++++++++++++++----------- 1 file changed, 89 insertions(+), 36 deletions(-) diff --git a/src/types/api/expense.d.ts b/src/types/api/expense.d.ts index 78a8ac76..71863503 100644 --- a/src/types/api/expense.d.ts +++ b/src/types/api/expense.d.ts @@ -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; - realization_date?: string; - kandangs: Kandang[]; - vendor: Supplier; - request_documents: { - name: string; - url: string; + po_number: string | null; + category: 'BOP' | 'NON-BOP'; + documents?: { + id: number; + path: string; }[]; - kandang_expenses: { - kandang: Kandang; - expenses: { - nonstock: Nonstock; - total_quantity: number; - total_expense: number; - notes?: string; + realization_docs?: { + id: number; + path: string; + }[]; + expense_date: string; + realization_date?: string; + grand_total: number; + location: BaseLocation; + supplier: BaseSupplier; + kandangs: { + id: number; + kandang_id: number; + name: string; + pengajuans?: { + id: number; + qty: number; + unit_price: number; + total_price: number; + note?: string; + nonstock: Pick; + project_flock_kandang: { + id: number; + kandang_id: number; + }; + }[]; + realisasi?: { + id: number; + qty: number; + unit_price: number; + total_price: number; + date: string; + note?: string; + nonstock: Pick; + 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;