Expand sales, treasury, and parties modules with Jalali calendar and FunZone integrations
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,8 +15,10 @@ import type {
|
||||
Employee,
|
||||
Invoice,
|
||||
Party,
|
||||
PartyAdjustment,
|
||||
Payslip,
|
||||
Product,
|
||||
SalesType,
|
||||
TreasuryTxn,
|
||||
Voucher,
|
||||
} from '../types'
|
||||
@@ -33,6 +35,8 @@ type CollectionKey =
|
||||
| 'parties'
|
||||
| 'products'
|
||||
| 'invoices'
|
||||
| 'salesTypes'
|
||||
| 'partyAdjustments'
|
||||
| 'treasury'
|
||||
| 'employees'
|
||||
| 'payslips'
|
||||
@@ -43,6 +47,8 @@ const ENDPOINT: Record<CollectionKey, string> = {
|
||||
parties: ACCOUNTING_ENDPOINTS.PARTIES,
|
||||
products: ACCOUNTING_ENDPOINTS.PRODUCTS,
|
||||
invoices: ACCOUNTING_ENDPOINTS.INVOICES,
|
||||
salesTypes: ACCOUNTING_ENDPOINTS.SALES_TYPES,
|
||||
partyAdjustments: ACCOUNTING_ENDPOINTS.PARTY_ADJUSTMENTS,
|
||||
treasury: ACCOUNTING_ENDPOINTS.TREASURY,
|
||||
employees: ACCOUNTING_ENDPOINTS.EMPLOYEES,
|
||||
payslips: ACCOUNTING_ENDPOINTS.PAYSLIPS,
|
||||
@@ -71,6 +77,8 @@ const EMPTY_DATA: AppData = {
|
||||
parties: [],
|
||||
products: [],
|
||||
invoices: [],
|
||||
salesTypes: [],
|
||||
partyAdjustments: [],
|
||||
treasury: [],
|
||||
employees: [],
|
||||
payslips: [],
|
||||
@@ -90,11 +98,16 @@ interface AppStoreValue {
|
||||
/** Bulk-creates vouchers (used by the live-data "صدور سند" sync); returns how many were created. */
|
||||
createVouchers: (items: Voucher[]) => Promise<number>
|
||||
upsertParty: (item: Party) => void
|
||||
upsertPartyAsync: (item: Party) => Promise<void>
|
||||
removeParty: (id: string) => void
|
||||
upsertProduct: (item: Product) => void
|
||||
removeProduct: (id: string) => void
|
||||
upsertInvoice: (item: Invoice) => void
|
||||
removeInvoice: (id: string) => void
|
||||
upsertSalesType: (item: SalesType) => void
|
||||
removeSalesType: (id: string) => void
|
||||
upsertPartyAdjustment: (item: PartyAdjustment) => void
|
||||
removePartyAdjustment: (id: string) => void
|
||||
upsertTreasury: (item: TreasuryTxn) => void
|
||||
removeTreasury: (id: string) => void
|
||||
upsertEmployee: (item: Employee) => void
|
||||
@@ -154,19 +167,21 @@ export function AppStoreProvider({ children }: { children: ReactNode }) {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
try {
|
||||
const [accounts, vouchers, parties, products, invoices, treasury, employees, payslips, settings] =
|
||||
const [accounts, vouchers, parties, products, invoices, salesTypes, partyAdjustments, treasury, employees, payslips, settings] =
|
||||
await Promise.all([
|
||||
acct.get(ENDPOINT.accounts).then(asList<Account>),
|
||||
acct.get(ENDPOINT.vouchers).then(asList<Voucher>),
|
||||
acct.get(ENDPOINT.parties).then(asList<Party>),
|
||||
acct.get(ENDPOINT.products).then(asList<Product>),
|
||||
acct.get(ENDPOINT.invoices).then(asList<Invoice>),
|
||||
acct.get(ENDPOINT.salesTypes).then(asList<SalesType>),
|
||||
acct.get(ENDPOINT.partyAdjustments).then(asList<PartyAdjustment>),
|
||||
acct.get(ENDPOINT.treasury).then(asList<TreasuryTxn>),
|
||||
acct.get(ENDPOINT.employees).then(asList<Employee>),
|
||||
acct.get(ENDPOINT.payslips).then(asList<Payslip>),
|
||||
acct.get<CompanySettings>(ACCOUNTING_ENDPOINTS.SETTINGS),
|
||||
])
|
||||
setData({ accounts, vouchers, parties, products, invoices, treasury, employees, payslips, settings })
|
||||
setData({ accounts, vouchers, parties, products, invoices, salesTypes, partyAdjustments, treasury, employees, payslips, settings })
|
||||
setReady(true)
|
||||
} catch (err) {
|
||||
setReady(false)
|
||||
@@ -273,11 +288,16 @@ export function AppStoreProvider({ children }: { children: ReactNode }) {
|
||||
removeVoucher: (id) => void remove('vouchers', id),
|
||||
createVouchers,
|
||||
upsertParty: (item) => void upsert('parties', item),
|
||||
upsertPartyAsync: (item) => upsert('parties', item),
|
||||
removeParty: (id) => void remove('parties', id),
|
||||
upsertProduct: (item) => void upsert('products', item),
|
||||
removeProduct: (id) => void remove('products', id),
|
||||
upsertInvoice: (item) => void upsert('invoices', item),
|
||||
removeInvoice: (id) => void remove('invoices', id),
|
||||
upsertSalesType: (item) => void upsert('salesTypes', item),
|
||||
removeSalesType: (id) => void remove('salesTypes', id),
|
||||
upsertPartyAdjustment: (item) => void upsert('partyAdjustments', item),
|
||||
removePartyAdjustment: (id) => void remove('partyAdjustments', id),
|
||||
upsertTreasury: (item) => void upsert('treasury', item),
|
||||
removeTreasury: (id) => void remove('treasury', id),
|
||||
upsertEmployee: (item) => void upsert('employees', item),
|
||||
|
||||
Reference in New Issue
Block a user