How SQL-Ledger fits together
SQL-Ledger is one application with one database, not a bundle of modules that exchange files. Every screen reads the same master data, every document that has a financial effect posts into the same ledger table, and every report is a query over that table. This page explains the three layers and how information moves between them; the feature pages then cover each screen in turn.
The three layers
- Master data — customers, vendors, parts and assemblies, employees, projects, and the chart of accounts. These are set up once and referred to by everything else. The chart is the linking structure: every part, customer, tax and payment method points at accounts in it.
- Documents — quotations, orders, invoices, receipts and payments, time cards,
payroll runs, journal entries. Each is keyed on its own screen, refers to master data, and carries its own
header table (
ar,ap,oe,gl) with line tables (invoice,orderitems) underneath. - The ledger — a single table,
acc_trans, holding one row per debit or credit, keyed to the document that made it and the account it hit. Financial statements, the trial balance, ageing, tax returns and the GL report are all read from here.
The everyday picture: sales, purchasing, cash and the ledger
Most businesses live in four modules. You invoice customers and receive their money; you record what vendors bill you and pay them; the bank account sits in the middle; and anything else goes in as a journal entry. Every one of those actions writes rows into the same ledger, and the reports read them back.
The full picture
The rest of the system — quotations and orders, point of sale, inventory and assemblies, payroll, time cards, vouchers, the storefront — either feeds those four modules or posts into the same ledger alongside them. Solid arrows are postings to the ledger. Dashed arrows are documents that carry information forward without posting anything: a quotation or an order changes nothing in the books until it becomes an invoice.
acc_trans, and every report at the bottom is a query over those rows.What happens when a document posts
Take a sales invoice. Pressing Post does all of the following in one database transaction, so the books can never be half-updated:
- A header row is written to
ar: customer, dates, invoice number, currency and rate, totals, and who posted it. - One row per line goes to
invoice: the part, quantity, price, discount, and the project if any. - For each stocked part, the on-hand quantity is reduced in the chosen warehouse and the cost of goods is worked out from the layers it came in at.
- The ledger rows are written to
acc_trans: a debit to the receivables control account for the total, a credit to each income account for its lines, a credit to each tax account, and a debit to COGS with a matching credit to inventory for the stock that left. Every row carries the invoice’strans_id, thechart_idof the account, the amount and the date. - If a payment was keyed on the same screen, a debit to the bank account and a credit to receivables follow.
- If the audit trail is on, the action is logged with the user and the moment.
A vendor invoice does the same in the other direction (payables, expense or inventory, tax paid). A payment or
receipt writes just the bank and control-account rows against the invoice it settles. A payroll run writes wages
expense, each deduction’s liability, and the net pay to payables. A journal entry writes exactly the rows you
keyed. Whatever the origin, the rows look the same in acc_trans, which is why one trial balance covers
all of them.
What does not post
- Quotations, RFQs, sales orders and purchase orders. They live in
oeandorderitems, reserve or expect stock, and carry their lines forward — but nothing reachesacc_transuntil an invoice is raised from them. - Time cards, until they are billed onto an invoice.
- Vouchers, until the batch is approved and posted. Until then they are held with a voucher number and can be edited or discarded.
- Recurring schedules: the template document is stored; each occurrence is posted when it is processed.
Why the chart of accounts matters
Every row in the ledger points at an account, so the chart decides what the reports can say. Accounts carry flags for what may use them: a part’s income, COGS and inventory accounts, a customer’s receivables account, the bank accounts offered on a receipt, the tax accounts that appear as tax codes. Departments and projects are additional keys on the same rows, which is how a division or a job can be reported without a second chart.
Reading it back
Because everything is in one table, every report is a filter over it: the trial balance sums each account between two dates, the balance sheet sums the asset, liability and equity accounts up to a date, the income statement sums income and expense between two dates, ageing groups the open receivables rows by customer and age, the tax report sums the tax accounts. Every figure on every report is a link back to the document that made the rows, and that document links back to the customer, vendor, part or employee it referred to.
Where to go next
- Setting up: Administration, Chart of accounts, Taxes, Access control.
- Selling: Customers, Orders, Invoicing, Accounts receivable.
- Buying: Vendors, Accounts payable, Cheques, Inventory.
- The books: General ledger, Financial statements, Reports, Audit control.