mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 09:50:01 +00:00
Accounting: auto-create record-only bills for no-bill vendor payments (import mode)
Buildium often records vendor payments as direct checks (Dr Expense/Cr Bank) with no bill. For import-mode companies post_bill_gl no-ops, so a bill is a record only. New fn accounting.autocreate_nobill_vendor_bills() creates a paid record-only bill for each such buildium_gl payment (vendor resolved by payee, idempotent by external_id); buildium-gl-sync calls it per import-mode company after each pull. No GL impact, no double-count. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -526,6 +526,17 @@ Deno.serve(async (req) => {
|
||||
} else if (unmappedGl.size > 0) {
|
||||
companyResult.watermark_held = true;
|
||||
}
|
||||
|
||||
// Import-mode: surface no-bill vendor payments (Buildium direct checks that
|
||||
// hit an expense account with no A/P leg) as record-only bills. post_bill_gl
|
||||
// no-ops for gl_auto_post=false companies, so this never touches the GL.
|
||||
if (!dryRun && company.gl_auto_post === false) {
|
||||
const { data: madeBills, error: billErr } =
|
||||
await supabase.schema("accounting").rpc("autocreate_nobill_vendor_bills", { _company_id: company.id });
|
||||
if (billErr) companyResult.errors.push(`autocreate bills: ${billErr.message}`);
|
||||
else if (madeBills) companyResult.autobills_created = madeBills;
|
||||
}
|
||||
|
||||
companyResult.window = { since, until };
|
||||
} catch (e: any) {
|
||||
companyResult.errors.push(e?.message || String(e));
|
||||
|
||||
Reference in New Issue
Block a user