File: docs/concepts/tax-direction-determination.concept.md
Concept: Tax Direction Determination
1. Overview
The system must determine the correct accounting direction for tax transactions (e.g., Tax Payable vs. Tax Receivable) based on the context of a voucher. This logic is inspired by the rules in Microsoft Dynamics 365 F&O and is encapsulated in the TaxDirectionDeterminationService.
The determination depends primarily on the "dominant" account type within the voucher (Vendor, Customer, or Ledger) and whether the applied TaxCode is marked as exempt.
2. Determination Flowchart
The following diagram illustrates the simplified decision-making process.
4. Posting Resolution Logic
Once the TaxDirection is determined, the TaxPostingResolverService is used to determine the final accounting entry. This service centralizes the rules for how tax is posted to the General Ledger.
The logic is as follows:
-
Determine Reporting Sign: The service first calculates the sign of the "Actual sales tax amount" as it would appear in reports.
Journal Line Amount Sales Tax Direction Actual Sales Tax Amount Sign Positive (Debit) Sales Tax Receivable Positive Positive (Debit) Sales Tax Payable Negative Negative (Credit) Sales Tax Receivable Negative Negative (Credit) Sales Tax Payable Positive -
Determine GL Account and Voucher Entry: Based on the direction and the calculated sign, the service determines the final debit/credit entry.
Sales Tax Direction Actual Sales Tax Amount Sign Sales Tax Account Used Amount on Voucher Sales Tax Receivable Positive TaxPostingGroup.TaxReceivableLedgerAccountIdPositive (Debit) Sales Tax Receivable Negative TaxPostingGroup.TaxReceivableLedgerAccountIdNegative (Credit) Sales Tax Payable Positive TaxPostingGroup.TaxPayableLedgerAccountIdNegative (Credit) Sales Tax Payable Negative TaxPostingGroup.TaxPayableLedgerAccountIdPositive (Debit)