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

Sales Invoice Posting - Voucher Entry Creation

Overview

Sales invoice posting in the General Ledger module creates journal entries based on multiple integrated strategies. The system automatically determines which posting strategies to apply based on invoice data and configuration. This document explains what entries are created for each scenario and how different invoice features affect the final voucher.

Architecture

The sales invoice posting system uses a modular strategy pattern with the following main components:

Core Strategy Calculator

  • SalesInvoicePostingStrategyCalculator: Main orchestrator that coordinates all sub-strategies
  • SalesInvoiceTransactionData: Comprehensive data structure containing all invoice information
  • PostingCalculationContext: Configuration context with posting profiles and master data

Individual Strategy Calculators

  1. SalesRevenuePostingStrategyCalculator: Creates AR and Revenue entries
  2. CostOfGoodsSoldPostingStrategyCalculator: Creates COGS and Inventory relief entries
  3. SalesDiscountPostingStrategyCalculator: Creates discount entries
  4. SalesCommissionPostingStrategyCalculator: Creates commission entries
  5. SalesTaxPostingStrategyCalculator: Creates tax liability entries

Sales Invoice Posting Scenarios

1. Basic Sales Invoice (No Discounts, No Tax, No Commissions)

Invoice Data:

  • Customer: ACME Corp
  • Item A: 10 units @ $100 = $1,000
  • Item B: 5 units @ $200 = $1,000
  • Total: $2,000

Voucher Entries Created:

DR  Accounts Receivable - ACME Corp    $2,000   (Customer account)
CR Revenue - Product A $1,000 (Item A revenue account)
CR Revenue - Product B $1,000 (Item B revenue account)

Strategy Applied: Revenue posting only


2. Sales Invoice with Cost of Goods Sold

Invoice Data:

  • Customer: ACME Corp
  • Item A: 10 units @ $100 = $1,000 (cost: $60/unit)
  • Item B: 5 units @ $200 = $1,000 (cost: $120/unit)
  • Total: $2,000

Voucher Entries Created:

DR  Accounts Receivable - ACME Corp    $2,000   (Customer account)
CR Revenue - Product A $1,000 (Item A revenue account)
CR Revenue - Product B $1,000 (Item B revenue account)

DR Cost of Goods Sold - Product A $600 (Item A COGS account)
DR Cost of Goods Sold - Product B $600 (Item B COGS account)
CR Inventory - Product A $600 (Item A inventory account)
CR Inventory - Product B $600 (Item B inventory account)

Strategies Applied: Revenue + COGS posting


3. Sales Invoice with Line Item Discounts

Invoice Data:

  • Customer: ACME Corp
  • Item A: 10 units @ $100 = $1,000, Discount: $50
  • Item B: 5 units @ $200 = $1,000, Discount: $100
  • Subtotal: $2,000, Total Discounts: $150, Net Total: $1,850

Voucher Entries Created:

DR  Accounts Receivable - ACME Corp    $1,850   (Net amount after discounts)
DR Sales Discount - Product A $50 (Item A discount account)
DR Sales Discount - Product B $100 (Item B discount account)
CR Revenue - Product A $1,000 (Full revenue amount)
CR Revenue - Product B $1,000 (Full revenue amount)

Strategies Applied: Revenue + Discount posting

Key Business Rule: Revenue is posted at full amount; discounts are posted separately to maintain proper revenue reporting.


4. Sales Invoice with Cash Discount

Invoice Data:

  • Customer: ACME Corp (2% cash discount terms)
  • Items: $2,000 total
  • Cash Discount: $40 (2% of $2,000)
  • Net Receivable: $1,960

Voucher Entries Created:

DR  Accounts Receivable - ACME Corp    $1,960   (Net amount after cash discount)
DR Cash Discount - ACME Corp $40 (Customer-specific discount account)
CR Revenue - Products $2,000 (Full revenue amount)

Strategy Applied: Revenue + Cash Discount posting


5. Sales Invoice with Tax (Tax-Exclusive)

Invoice Data:

  • Customer: ACME Corp
  • Items: $1,000 (tax-exclusive)
  • Tax: $200 (20% VAT)
  • Total Invoice: $1,200

Voucher Entries Created:

DR  Accounts Receivable - ACME Corp    $1,200   (Total amount including tax)
CR Revenue - Products $1,000 (Revenue excluding tax)
CR Tax Payable - VAT Standard $200 (Tax liability)

Strategy Applied: Revenue + Tax posting

Critical Business Rule: AR is posted for the total amount customer owes (including tax). Revenue excludes tax to avoid double-counting.


6. Sales Invoice with Tax (Tax-Inclusive)

Invoice Data:

  • Customer: ACME Corp
  • Items: $1,000 (tax-inclusive amount)
  • Tax: $167 (20% VAT embedded)
  • Net Revenue: $833

Voucher Entries Created:

DR  Accounts Receivable - ACME Corp    $1,000   (Total invoice amount)
CR Revenue - Products $833 (Revenue excluding embedded tax)
CR Tax Payable - VAT Standard $167 (Embedded tax liability)

Strategy Applied: Revenue + Tax posting

Key Difference: With tax-inclusive invoices, revenue is reduced by the embedded tax amount.


7. Sales Invoice with Commissions

Invoice Data:

  • Customer: ACME Corp
  • Item A: $1,000 (5% commission = $50)
  • Item B: $1,000 (3% commission = $30)
  • Total Commission: $80

Voucher Entries Created:

DR  Accounts Receivable - ACME Corp    $2,000   (Customer account)
CR Revenue - Product A $1,000 (Item A revenue account)
CR Revenue - Product B $1,000 (Item B revenue account)

DR Commission Expense - Product A $50 (Item A commission account)
DR Commission Expense - Product B $30 (Item B commission account)
CR Commission Payable $80 (Commission liability)

Strategies Applied: Revenue + Commission posting


8. Comprehensive Sales Invoice (All Features)

Invoice Data:

  • Customer: ACME Corp
  • Item A: 10 units @ $100 = $1,000, Cost: $600, Discount: $50, Commission: $50
  • Item B: 5 units @ $200 = $1,000, Cost: $600, Discount: $100, Commission: $30
  • Subtotal: $2,000, Discounts: $150, Net: $1,850
  • Tax: $370 (20% on $1,850), Invoice Total: $2,220
  • Cash Discount: $44 (2% of $2,220)

Voucher Entries Created:

# Revenue and AR Posting
DR Accounts Receivable - ACME Corp $2,176 (Invoice total minus cash discount)
DR Cash Discount - ACME Corp $44 (Cash discount)
DR Sales Discount - Product A $50 (Line discount)
DR Sales Discount - Product B $100 (Line discount)
CR Revenue - Product A $1,000 (Full revenue)
CR Revenue - Product B $1,000 (Full revenue)
CR Tax Payable - VAT Standard $370 (Tax liability)

# Cost of Goods Sold Posting
DR Cost of Goods Sold - Product A $600 (COGS expense)
DR Cost of Goods Sold - Product B $600 (COGS expense)
CR Inventory - Product A $600 (Inventory relief)
CR Inventory - Product B $600 (Inventory relief)

# Commission Posting
DR Commission Expense - Product A $50 (Commission expense)
DR Commission Expense - Product B $30 (Commission expense)
CR Commission Payable $80 (Commission liability)

All Strategies Applied: Revenue + COGS + Discounts + Tax + Commission

Total Debit Balance: $4,450 Total Credit Balance: $4,450


Posting Strategy Flow

Strategy Selection Logic

The system automatically determines which strategies to apply based on invoice data:

Revenue Strategy (Always Applied)

  • Condition: Invoice has lines
  • Purpose: Create AR debit and Revenue credit entries

COGS Strategy

  • Condition: transactionData.HasItemCosts (any line has ItemCost > 0)
  • Purpose: Create COGS expense and inventory relief entries

Discount Strategy

  • Condition: transactionData.TotalDiscountAmount.Amount > 0
  • Purpose: Create discount debit entries for cash and line discounts

Commission Strategy

  • Condition: transactionData.HasCommissions (any line has CommissionAmount > 0)
  • Purpose: Create commission expense and commission payable entries

Tax Strategy

  • Condition: transactionData.HasTax (TotalTaxAmount > 0)
  • Purpose: Create tax payable credit entries

Account Resolution

Hierarchical Account Lookup

The system uses InventoryPostingProfile for hierarchical account resolution:

  1. Item-Specific Account: If item has specific account configuration
  2. Category-Specific Account: If item category has account configuration
  3. Default Account: Fallback to posting profile default account

Posting Types Used

  • PostingType.SalesRevenue: Revenue accounts
  • PostingType.CostOfGoodsSold: COGS expense accounts
  • PostingType.CostOfUnits: Inventory asset accounts
  • PostingType.SalesDiscount: Discount accounts
  • PostingType.SalesCommission: Commission expense accounts
  • PostingType.SalesCommissionOffset: Commission payable accounts

Dimensional Accounting Integration

Default Dimensions

  • Customer Dimensions: Automatically inherited from customer master data
  • Item Dimensions: Inherited from item master data for item-specific entries
  • Transaction Dimensions: Can be specified at transaction level

Example with Dimensions

DR  AR - ACME Corp [Dept:Sales, Region:East]     $2,000
CR Revenue [Dept:Sales, Region:East, Product:A] $1,000
CR Revenue [Dept:Sales, Region:East, Product:B] $1,000

Technical References

Business Process References


Last Updated: [2025-09-19] | Version: 1.0 | Status: Active Development