انتقل إلى المحتوى الرئيسي

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:

  1. Determine Reporting Sign: The service first calculates the sign of the "Actual sales tax amount" as it would appear in reports.

    Journal Line AmountSales Tax DirectionActual Sales Tax Amount Sign
    Positive (Debit)Sales Tax ReceivablePositive
    Positive (Debit)Sales Tax PayableNegative
    Negative (Credit)Sales Tax ReceivableNegative
    Negative (Credit)Sales Tax PayablePositive
  2. Determine GL Account and Voucher Entry: Based on the direction and the calculated sign, the service determines the final debit/credit entry.

    Sales Tax DirectionActual Sales Tax Amount SignSales Tax Account UsedAmount on Voucher
    Sales Tax ReceivablePositiveTaxPostingGroup.TaxReceivableLedgerAccountIdPositive (Debit)
    Sales Tax ReceivableNegativeTaxPostingGroup.TaxReceivableLedgerAccountIdNegative (Credit)
    Sales Tax PayablePositiveTaxPostingGroup.TaxPayableLedgerAccountIdNegative (Credit)
    Sales Tax PayableNegativeTaxPostingGroup.TaxPayableLedgerAccountIdPositive (Debit)