mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 09:50:01 +00:00
Accounting: Sales Receipts, COA sync to dashboard, vendor-expense recognition
- Add Sales Receipts page (dashboard/accounting/sales-receipts): records a cash sale (name, address, income account, price, qty) — deposits and books income in one step via a transaction. New accounting.sales_receipts table. - Sync chart of accounts to the accounting dashboard: mirror accounting.accounts into public.chart_of_accounts for platform associations (one-way, same id) so Bill Approvals and every COA consumer use the dashboard's accounts. Legacy rows hidden; Bill Approvals made system-aware. - Vendor-expense recognition: a vendor payment with no bill now books the expense directly (Dr Expense / Cr Bank) on the payment date instead of going to A/P; payments against open bills still clear A/P (applied FIFO). Backfill reclassifies unbilled payments stuck in A/P. Expense Summary report made GL-driven so it follows the same rule. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
create table if not exists accounting.sales_receipts (
|
||||
id uuid primary key default gen_random_uuid(),
|
||||
company_id uuid not null references accounting.companies(id) on delete cascade,
|
||||
number text not null,
|
||||
receipt_date date not null default current_date,
|
||||
customer_name text,
|
||||
customer_address text,
|
||||
income_account_id uuid references accounting.accounts(id),
|
||||
deposit_account_id uuid references accounting.accounts(id),
|
||||
quantity numeric not null default 1,
|
||||
rate numeric not null default 0,
|
||||
total numeric not null default 0,
|
||||
memo text,
|
||||
transaction_id uuid references accounting.transactions(id) on delete set null,
|
||||
created_at timestamptz not null default now(),
|
||||
updated_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
create index if not exists idx_sales_receipts_company on accounting.sales_receipts(company_id);
|
||||
create index if not exists idx_sales_receipts_txn on accounting.sales_receipts(transaction_id);
|
||||
|
||||
alter table accounting.sales_receipts enable row level security;
|
||||
|
||||
create policy "Accounting staff full access" on accounting.sales_receipts
|
||||
for all using (accounting.is_accounting_staff()) with check (accounting.is_accounting_staff());
|
||||
create policy "Members CRUD sales_receipts" on accounting.sales_receipts
|
||||
for all using (accounting.is_company_member(company_id, auth.uid()))
|
||||
with check (accounting.is_company_member(company_id, auth.uid()));
|
||||
create policy "Board view sales_receipts" on accounting.sales_receipts
|
||||
for select using (accounting.is_company_board_member(company_id));
|
||||
|
||||
create trigger trg_sales_receipts_updated
|
||||
before update on accounting.sales_receipts
|
||||
for each row execute function public.update_updated_at_column();
|
||||
|
||||
grant select, insert, update, delete on accounting.sales_receipts to authenticated;
|
||||
grant all on accounting.sales_receipts to service_role;
|
||||
Reference in New Issue
Block a user