Add manual invoice creation mode with new API & UI flow
Introduced "ModeB" for manual invoice creation in system config. Added backend endpoints and service logic for creating invoices from confirmed Shop POs, with validation and error handling. Updated DTOs to support optional CreatedByUserId. On the frontend, added configuration card to toggle modes, a dialog for manual invoice creation, and UI updates to support the new workflow. Enables admins to choose between automatic and manual invoice creation.
This commit is contained in:
@@ -11,7 +11,7 @@ export { stock } from './stock'
|
||||
export { productReports, stockReports, dashboardReports } from './reports'
|
||||
export { shopPos, invoices, payments } from './sales'
|
||||
export { saleReturns, claims, supplierClaims } from './returns-claims'
|
||||
export { sysConfig, ITEM_TRACKING_KEYS, GRN_TAX_KEYS, grnTaxSettings, DEFAULT_GRN_TAX_SETTINGS } from './sys-config'
|
||||
export { sysConfig, ITEM_TRACKING_KEYS, GRN_TAX_KEYS, grnTaxSettings, DEFAULT_GRN_TAX_SETTINGS, invoiceCreationMode, INVOICE_CREATION_MODE_KEY, DEFAULT_INVOICE_CREATION_MODE } from './sys-config'
|
||||
export { bankAccounts } from './bank-accounts'
|
||||
export { chequeBooks, chequePages } from './cheques'
|
||||
export { receivedCheques } from './received-cheques'
|
||||
|
||||
@@ -48,6 +48,9 @@ export const shopPos = {
|
||||
get: (id: string) =>
|
||||
api.get<ShopPOResponse>(`/shop-pos/${id}`).then(r => r.data),
|
||||
|
||||
confirmedWithoutInvoice: (params?: { agentId?: string; routeId?: string; shopId?: string }) =>
|
||||
api.get<ShopPOResponse[]>('/shop-pos/confirmed-without-invoice', { params }).then(r => r.data),
|
||||
|
||||
create: (body: CreateShopPOBody) =>
|
||||
api.post<ShopPOResponse>('/shop-pos', body).then(r => r.data),
|
||||
|
||||
@@ -84,6 +87,9 @@ export const invoices = {
|
||||
get: (id: string) =>
|
||||
api.get<InvoiceResponse>(`/invoices/${id}`).then(r => r.data),
|
||||
|
||||
create: (shopPOId: string, createdByUserId?: string | null) =>
|
||||
api.post<InvoiceResponse>('/invoices', { shopPOId, createdByUserId }).then(r => r.data),
|
||||
|
||||
print: (id: string, printedByUserId?: string | null) =>
|
||||
api.post<InvoiceResponse>(`/invoices/${id}/print`, { printedByUserId }).then(r => r.data),
|
||||
|
||||
|
||||
@@ -72,3 +72,19 @@ export const grnTaxSettings = {
|
||||
.getAll()
|
||||
.then(all => parseGrnTaxSettings(Object.fromEntries(all.map(c => [c.key, c.value])))),
|
||||
}
|
||||
|
||||
// ─── Invoice creation mode (must match Distribution.Features.SysConfig.SysConfigService) ─────
|
||||
|
||||
export const INVOICE_CREATION_MODE_KEY = 'InvoiceCreationMode'
|
||||
|
||||
export type InvoiceCreationMode = 'ModeA' | 'ModeB'
|
||||
|
||||
export const DEFAULT_INVOICE_CREATION_MODE: InvoiceCreationMode = 'ModeB'
|
||||
|
||||
export const invoiceCreationMode = {
|
||||
get: () =>
|
||||
api.get<{ mode: InvoiceCreationMode }>('/sys-config/invoice-creation-mode').then(r => r.data.mode),
|
||||
|
||||
set: (mode: InvoiceCreationMode) =>
|
||||
api.put('/sys-config/invoice-creation-mode', { mode }).then(r => r.data),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user