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

// Filename: docs/concepts/settle-and-post-sales-tax.concept.md

Concept: Settle and Post Sales Tax Process

1. Overview

The "Settle and Post Sales Tax" process is a critical financial operation that transforms the numerous individual tax transactions accumulated over a period into a single, consolidated liability owed to a tax authority. This process effectively "clears" the tax subledger for a given period and creates a standard vendor invoice in the Accounts Payable (AP) module, allowing the tax liability to be paid using the standard vendor payment workflow.

The primary business goals are:

  • To determine the net tax liability (Payable - Receivable) for a specific tax period.
  • To create a complete and auditable accounting trail that closes out the individual tax transactions.
  • To generate a payable invoice to the tax authority (treated as a vendor) in the AP module.
  • To enable the final closing of the tax period, ensuring no further transactions can be posted to it.

2. Actors & Key Components

  • Actor: Accountant or financial controller.
  • Trigger: A user-initiated command via an API endpoint for a specific TaxPeriod.
  • Core Aggregates:
    • TaxPeriod / TaxPeriodHeader / TaxAuthority: Define the context of the settlement.
    • TaxTransaction: The source data; the detailed subledger of tax amounts.
    • LedgerJournalHeader: The temporary journal used to create the settlement accounting entries.
    • GeneralJournalEntry: The final, immutable accounting record of the settlement.
  • Core Services:
    • SettleAndPostSalesTaxCommandHandler: The application service that orchestrates the entire process.
    • ITaxSettlementCalculationService: A pure domain service that calculates the net liability.
    • IGeneralJournalEntryRepository: Used to fetch original transactions and save the new offsetting transactions.
    • ILedgerJournalRepository: Used to create and post the settlement journal.

3. Process Flow Diagram

This sequence diagram illustrates the interactions between the different components during the settlement process.