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

Purchase Invoice Posting - Voucher Entry Creation

Overview

Purchase invoice posting in the General Ledger module creates journal entries for vendor invoices using integrated posting 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 purchase invoice posting system uses a modular strategy pattern with the following main components:

Core Strategy Calculator

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

Individual Strategy Calculators

  1. PurchaseEntriesPostingStrategyCalculator: Creates AP and Inventory/Expense entries
  2. PurchaseDiscountPostingStrategyCalculator: Creates discount entries (contra-expense)
  3. PurchaseTaxPostingStrategyCalculator: Creates VAT receivable entries

Posting Strategy Flow


Purchase Invoice Posting Scenarios

1. Basic Purchase Invoice (No Discounts, No Tax)

Invoice Data:

  • Vendor: ABC Supplier
  • Item A: Office Supplies, 100 units @ $10 = $1,000
  • Item B: Raw Materials, 50 units @ $20 = $1,000
  • Total: $2,000

Voucher Entries Created:

DR  Inventory - Office Supplies      $1,000   (Item A inventory account)
DR Inventory - Raw Materials $1,000 (Item B inventory account)
CR Accounts Payable - ABC Supplier $2,000 (Vendor account)

Strategy Applied: Purchase Entries only

Key Business Rule: Items are posted to inventory accounts based on posting profile configuration (inventory items) or expense accounts (non-inventory items).


2. Purchase Invoice with Mixed Item Types

Invoice Data:

  • Vendor: ABC Supplier
  • Office Supplies (inventory item): $800 → Inventory Account
  • Advertising (expense item): $700 → Expense Account
  • Equipment Maintenance (service): $500 → Expense Account
  • Total: $2,000

Voucher Entries Created:

DR  Inventory - Office Supplies      $800    (Inventory asset account)
DR Advertising Expense $700 (Operating expense account)
DR Maintenance Expense $500 (Operating expense account)
CR Accounts Payable - ABC Supplier $2,000 (Vendor account)

Strategy Applied: Purchase Entries only

Account Resolution: The system uses hierarchical lookup in the inventory posting profile:

  1. Item-Specific Account: If configured for specific item
  2. Category-Specific Account: Based on item category
  3. Default Account: Fallback for the posting type

3. Purchase Invoice with Line Item Discounts

Invoice Data:

  • Vendor: ABC Supplier
  • Item A: $1,000, Discount: $50
  • Item B: $1,000, Discount: $100
  • Subtotal: $2,000, Total Discounts: $150, Net Total: $1,850

Voucher Entries Created:

DR  Inventory - Item A                $1,000   (Full inventory value)
DR Inventory - Item B $1,000 (Full inventory value)
CR Accounts Payable - ABC Supplier $1,850 (Net amount owed)
CR Purchase Discounts - Item A $50 (Contra-expense/Income)
CR Purchase Discounts - Item B $100 (Contra-expense/Income)

Strategies Applied: Purchase Entries + Discount posting

Key Business Rule: Inventory is recorded at full value; discounts are recorded as income/contra-expense accounts, reducing the total cost of purchases.


4. Purchase Invoice with Vendor Cash Discount

Invoice Data:

  • Vendor: ABC Supplier (2% early payment discount terms)
  • Items: $2,000 total
  • Cash Discount: $40 (2% of $2,000)
  • Net Payable: $1,960

Voucher Entries Created:

DR  Inventory - Items                 $2,000   (Full inventory value)
CR Accounts Payable - ABC Supplier $1,960 (Net amount owed after discount)
CR Vendor Cash Discount $40 (Vendor-specific discount account)

Strategies Applied: Purchase Entries + Cash Discount posting


5. Purchase Invoice with VAT/Tax (Tax-Exclusive)

Invoice Data:

  • Vendor: ABC Supplier
  • Items: $1,000 (tax-exclusive)
  • VAT: $200 (20% VAT reclaimable)
  • Total Invoice: $1,200

Voucher Entries Created:

DR  Inventory - Items                 $1,000   (Items at net cost)
DR VAT Receivable $200 (Tax asset - reclaimable from government)
CR Accounts Payable - ABC Supplier $1,200 (Total amount owed including VAT)

Strategies Applied: Purchase Entries + Tax posting

Critical Business Rule: For purchases, VAT creates a receivable (asset) representing tax that can be recovered from tax authorities, unlike sales tax which creates a payable (liability).


6. Purchase Invoice with VAT (Tax-Inclusive)

Invoice Data:

  • Vendor: ABC Supplier
  • Items: $1,000 (tax-inclusive amount)
  • Embedded VAT: $167 (20% embedded)
  • Net Item Cost: $833

Voucher Entries Created:

DR  Inventory - Items                 $833    (Items at net cost excluding embedded VAT)
DR VAT Receivable $167 (Embedded VAT reclaimable)
CR Accounts Payable - ABC Supplier $1,000 (Total invoice amount)

Strategy Applied: Purchase Entries + Tax posting

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


7. Comprehensive Purchase Invoice (All Features)

Invoice Data:

  • Vendor: ABC Supplier
  • Item A: $1,000, Discount: $50
  • Item B: $1,000, Discount: $100
  • Subtotal: $2,000, Discounts: $150, Net: $1,850
  • VAT: $370 (20% on $1,850), Invoice Total: $2,220
  • Cash Discount: $44 (2% of $2,220)

Voucher Entries Created:

# Purchase Entries and Discounts
DR Inventory - Item A $1,000 (Full inventory value)
DR Inventory - Item B $1,000 (Full inventory value)
DR VAT Receivable $370 (VAT reclaimable)
CR Accounts Payable - ABC Supplier $2,176 (Total minus cash discount)
CR Purchase Discounts - Item A $50 (Line discount)
CR Purchase Discounts - Item B $100 (Line discount)
CR Vendor Cash Discount $44 (Early payment discount)

All Strategies Applied: Purchase Entries + Discounts + Tax

Total Debit Balance: $2,370 Total Credit Balance: $2,370


Strategy Selection Logic

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

Purchase Entries Strategy (Always Applied)

  • Condition: Invoice has lines
  • Purpose: Create AP credit and Inventory/Expense debit entries

Discount Strategy

  • Condition: transactionData.HasDiscounts (TotalDiscountAmount > 0 OR CashDiscountAmount > 0)
  • Purpose: Create discount credit entries for cash and line discounts

Tax Strategy

  • Condition: transactionData.HasTax (TotalTaxAmount > 0)
  • Purpose: Create VAT receivable debit entries

Account Resolution & Posting Types

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.PurchaseAccrual: Accounts Payable (vendor liability)
  • PostingType.CostOfPurchasedMaterials: Inventory/Expense accounts (asset/expense)
  • PostingType.PurchaseDiscount: Purchase discount accounts (contra-expense)
  • Tax Receivable Posting: VAT reclaimable accounts (asset)

Item Type Determination

The posting profile determines whether items should be posted to:

  • Inventory Accounts: For items tracked in inventory (raw materials, finished goods)
  • Expense Accounts: For items expensed immediately (office supplies, services)

Dimensional Accounting Integration

Default Dimensions

  • Vendor Dimensions: Automatically inherited from vendor 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  Inventory [Dept:Production, Location:Warehouse1]  $1,000
DR Inventory [Dept:Office, Location:HQ] $1,000
CR AP - Vendor [Dept:Purchasing, Region:East] $2,000

Tax Handling Differences

Purchase vs Sales Tax Treatment

AspectPurchase InvoicesSales Invoices
Tax NatureVAT Receivable (Asset)VAT Payable (Liability)
Tax RecoveryReclaimable from governmentOwed to government
Journal EntryDR VAT ReceivableCR VAT Payable
Balance SheetCurrent AssetCurrent Liability

VAT Recovery Process

  1. Purchase VAT: Recorded as receivable when invoice posted
  2. VAT Return: Claimed back from tax authorities quarterly/monthly
  3. Settlement: VAT receivables offset against VAT payables

Common Business Scenarios

Scenario 1: Office Supplies Purchase

DR  Office Supplies Expense     $500
CR Accounts Payable $500

Reason: Office supplies are expensed immediately, not tracked as inventory.

Scenario 2: Raw Materials Purchase

DR  Raw Materials Inventory     $10,000
CR Accounts Payable $10,000

Reason: Raw materials are tracked as inventory assets until used in production.

Scenario 3: Professional Services

DR  Professional Fees Expense   $2,000
DR VAT Receivable $400
CR Accounts Payable $2,400

Reason: Services are expensed immediately with reclaimable VAT.

Scenario 4: Equipment Purchase

DR  Equipment (Fixed Asset)     $50,000
DR VAT Receivable $10,000
CR Accounts Payable $60,000

Reason: Equipment is capitalized as fixed asset with reclaimable VAT.


Technical References

Business Process References

Cross-Reference with Sales


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