mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 09:50:01 +00:00
Merge pull request #6 from renee-png/accounting-sales-receipts-coa-sync-expenses
Accounting: sales receipts, COA dashboard sync, accrual A/P, manual deposits, per-association COA, bill-approval sync fix
This commit is contained in:
@@ -2123,12 +2123,21 @@ Deno.serve(async (req) => {
|
||||
const buildiumVendor = buildiumVendorById.get(String(bb.VendorId)) || null;
|
||||
const vendorId = await ensureVendor(buildiumVendor, assocLocalId);
|
||||
|
||||
// Pick first line's GL account as expense account if available
|
||||
// Pick first line's GL account as expense account if available.
|
||||
// chart_of_accounts.account_number stores the Buildium GL Id (see the
|
||||
// glaccounts upsert: account_number = String(gl.Id ...)), so resolve the
|
||||
// line's GL Id from whichever shape Buildium returns it in.
|
||||
const firstLine = Array.isArray(bb.Lines) && bb.Lines.length > 0 ? bb.Lines[0] : null;
|
||||
let expenseAccountId: string | null = null;
|
||||
if (firstLine?.GLAccountId) {
|
||||
const lineGlId = firstLine
|
||||
? (firstLine.GLAccountId
|
||||
?? firstLine.GLAccount?.Id
|
||||
?? firstLine.GLAccount?.GLAccountId
|
||||
?? null)
|
||||
: null;
|
||||
if (lineGlId !== null && lineGlId !== undefined && String(lineGlId) !== "") {
|
||||
const coa = await getCoa(assocLocalId);
|
||||
expenseAccountId = coa.get(String(firstLine.GLAccountId)) || null;
|
||||
expenseAccountId = coa.get(String(lineGlId)) || null;
|
||||
}
|
||||
|
||||
let amount = Number(bb.TotalAmount ?? bb.Amount ?? 0);
|
||||
|
||||
Reference in New Issue
Block a user