# Rule: Sales / Revenue

**Sales = Income-type accounts in chart classes 70 and 71** (services sit at 713, under 71). Do NOT identify sales by the word "Sales" in a name — many customer/supplier accounts contain "Sales" in their names.

Key carve-outs:
- **719 = Discount on Sales** → contra-revenue; subtract it (net sales = gross − discounts).
- **775 = Gain on Foreign Exchange** → Income-type but **financial income, NOT sales**. Exclude from sales totals.
- **Article 59** (e.g. `711400`) → a Lebanese VAT-law carve-out; keep distinct (see rule: vat).

Each sales line exists as several leaf accounts, split by **VAT status** and **currency**. e.g. `711100-00111` = Produced-Goods sales, VATable, LBP.

**Invoice-based sales tools** (`top_selling_items`, `product_profitability`, `customer_profitability`, `sales_by_customer`-style item/customer reports, trends, seasonality) filter periods by the **invoice date `inp_edate`** only — never the value date `inp_vdate`. Their revenue is **net of both discounts**: the per-line `inc_disc` (already inside `inc_lineTotal`) and the invoice-level global `inp_discpercent` (applied by the tools), and ex-VAT (POS lines are stored VAT-inclusive and are stripped), so it reconciles to `inp_gtotal − inp_vat`. If a client's own UNO sales report disagrees with a tool, check the period first; both should now use `inp_edate`.

**Year-end closing:** the `CL` voucher on Dec-31 zeroes every income/expense account. All GL period figures (sales_summary, profit_and_loss, sales_trend, period_compare, expense_breakdown, branch_pnl…) exclude `CL`/`OB`/`FI` vouchers, as UNO's "WithoutClosing" reports do — see rule `gl-periods-and-balances`.

**Use the `sales_summary` tool** — it already applies all of the above (classes 70/71, exclude 775, net 719) and can break down by category / account / currency.

**Document-type set (invoice side, 2026-11-09):** sales = `SA`, `SL`, `DN`, `CS` and `SD` ("Sales Invoice Delivered", UNO sums it with SA/SL even though it moves no stock); returns = `SR`/`RS`, credit notes `CN`/`CB` at entity level. UNO's own POS-VAT rule is `inc_price/1.11` on POS lines (cStockReports.vb GetSalesSummaryByGroup :7427); the tools apply the rate-aware equivalent `÷(1+inc_vat/100)`.

**Invoice-level tools added 2026-11-09 (from the UNO VB classes):** `list_invoices` (header register/search), `invoice_detail` (one document with lines + Σ check), `open_invoices` (unpaid per invoice from UNO's payment allocation), `invoice_payments`, `order_status` (SO/PO/QT open vs delivered), `pos_daily_summary` (Z-report with tender split), `last_price`, `item_sales_history`, `sales_matrix` (any dimension incl. salesman / customer category / region, bonus & return split, margin), `sales_daily`, `sales_by_vat_rate`, `item_price_history`. Walk-in rule and net-line rule apply to all of them.
