feat: enhance invoice item updates
This commit is contained in:
@@ -4,6 +4,7 @@ import type {
|
|||||||
ShopPOResponse,
|
ShopPOResponse,
|
||||||
InvoiceResponse,
|
InvoiceResponse,
|
||||||
InvoiceStatus,
|
InvoiceStatus,
|
||||||
|
InvoiceVersionResponse,
|
||||||
PaymentStatus,
|
PaymentStatus,
|
||||||
PaymentResponse,
|
PaymentResponse,
|
||||||
PaymentMethod,
|
PaymentMethod,
|
||||||
@@ -93,8 +94,14 @@ export const invoices = {
|
|||||||
print: (id: string, printedByUserId?: string | null) =>
|
print: (id: string, printedByUserId?: string | null) =>
|
||||||
api.post<InvoiceResponse>(`/invoices/${id}/print`, { printedByUserId }).then(r => r.data),
|
api.post<InvoiceResponse>(`/invoices/${id}/print`, { printedByUserId }).then(r => r.data),
|
||||||
|
|
||||||
finalize: (id: string, finalizedByUserId?: string | null) =>
|
finalize: (id: string, finalizedByUserId?: string | null, adjustments?: { invoiceItemId: string; adjustedQuantity: number; isRemoved?: boolean }[]) =>
|
||||||
api.post<InvoiceResponse>(`/invoices/${id}/finalize`, { finalizedByUserId }).then(r => r.data),
|
api.post<InvoiceResponse>(`/invoices/${id}/finalize`, { finalizedByUserId, adjustments }).then(r => r.data),
|
||||||
|
|
||||||
|
updateItems: (id: string, items: { invoiceItemId?: string; itemId?: string; quantity: number; unitPrice?: number | null; isRemoved?: boolean }[], editedByUserId?: string | null) =>
|
||||||
|
api.put<InvoiceResponse>(`/invoices/${id}/items`, { items, editedByUserId }).then(r => r.data),
|
||||||
|
|
||||||
|
versions: (id: string) =>
|
||||||
|
api.get<InvoiceVersionResponse[]>(`/invoices/${id}/versions`).then(r => r.data),
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Payments ─────────────────────────────────────────────────────────────────
|
// ─── Payments ─────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export type PurchaseOrderStatus =
|
|||||||
| 'Issued' | 'PartiallyReceived' | 'Received' | 'Closed' | 'Cancelled'
|
| 'Issued' | 'PartiallyReceived' | 'Received' | 'Closed' | 'Cancelled'
|
||||||
export type ShopPOStatus = 'Pending' | 'PartiallyFulfilled' | 'Fulfilled' | 'Cancelled'
|
export type ShopPOStatus = 'Pending' | 'PartiallyFulfilled' | 'Fulfilled' | 'Cancelled'
|
||||||
export type InvoiceStatus = 'Draft' | 'Printed' | 'Finalized'
|
export type InvoiceStatus = 'Draft' | 'Printed' | 'Finalized'
|
||||||
|
export type InvoiceVersionStage = 'Created' | 'DraftEdited' | 'Printed' | 'Finalized'
|
||||||
export type InvoiceCreationMode = 'ModeA' | 'ModeB'
|
export type InvoiceCreationMode = 'ModeA' | 'ModeB'
|
||||||
export type PaymentStatus = 'Pending' | 'PartiallyPaid' | 'Paid'
|
export type PaymentStatus = 'Pending' | 'PartiallyPaid' | 'Paid'
|
||||||
export type PaymentMethod = 'Cash' | 'Cheque' | 'Credit'
|
export type PaymentMethod = 'Cash' | 'Cheque' | 'Credit'
|
||||||
@@ -1001,6 +1002,36 @@ export interface ShopPOResponse {
|
|||||||
cancelledByRole: string | null
|
cancelledByRole: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface InvoiceItemResponse {
|
||||||
|
id: string
|
||||||
|
shopPOItemId: string | null
|
||||||
|
itemId: string
|
||||||
|
itemName: string
|
||||||
|
orderedQuantity: number | null
|
||||||
|
quantity: number
|
||||||
|
unitPrice: number
|
||||||
|
isRemoved: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InvoiceVersionItemResponse {
|
||||||
|
shopPOItemId: string | null
|
||||||
|
itemId: string
|
||||||
|
itemName: string
|
||||||
|
quantity: number
|
||||||
|
unitPrice: number
|
||||||
|
isRemoved: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InvoiceVersionResponse {
|
||||||
|
id: string
|
||||||
|
versionNumber: number
|
||||||
|
stage: InvoiceVersionStage
|
||||||
|
totalAmount: number
|
||||||
|
createdBy: string
|
||||||
|
createdAt: string
|
||||||
|
items: InvoiceVersionItemResponse[]
|
||||||
|
}
|
||||||
|
|
||||||
export interface InvoiceResponse {
|
export interface InvoiceResponse {
|
||||||
id: string
|
id: string
|
||||||
shopPOId: string
|
shopPOId: string
|
||||||
@@ -1017,6 +1048,7 @@ export interface InvoiceResponse {
|
|||||||
paidAmount: number
|
paidAmount: number
|
||||||
isActive: boolean
|
isActive: boolean
|
||||||
createdAt: string
|
createdAt: string
|
||||||
|
items: InvoiceItemResponse[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OutstandingPaymentsResponse {
|
export interface OutstandingPaymentsResponse {
|
||||||
|
|||||||
Reference in New Issue
Block a user