Accounting Transaction
Introduction
The AccountingTransaction entity is a polymorphic aggregate root that represents all financial documents in the system - invoices (accounts receivable), bills (accounts payable), and credit memos. Unlike most entities that represent a single concept, AccountingTransaction uses the AccountingTransactionType enum to differentiate between these three document types, each serving a distinct business purpose.
AccountingTransaction provides intelligent payment tracking with automatic recalculation of balances, status transitions, and charge management. It supports draft mode for work-in-progress documents, payment term integration for automatic due date calculation, job linkage for consolidated billing, and custom values for extensibility. The entity automatically transitions between Open and Paid statuses based on payment application, cascading status changes to associated charges.
Entity Structure
Properties
| Property Name | Type | Required | Description |
|---|---|---|---|
| AccountingTransactionId | int | Yes | Primary key - unique transaction identifier |
| AccountingTransactionType | AccountingTransactionType | Yes | Type of transaction (Invoice, Bill, CreditMemo) |
| AccountingTransactionStatus | AccountingTransactionStatus | Yes | Current status (Open, Paid, Void) |
| OrganizationId | int | Yes | Organization owning this transaction (multi-tenancy) |
| DivisionId | int | Yes | Division for data partitioning |
| Division | Division | No | Navigation property to division |
| TransactionNumber | string | Yes | Human-readable transaction number (e.g., INV-2025-001) |
| TransactionDate | DateTime | Yes | Date transaction was created/posted |
| DueDate | DateTime | Yes | Payment due date (calculated from payment terms) |
| PaidDate | DateTime? | No | Date transaction was fully paid (set automatically) |
| ApplyToContactID | int? | No | Customer (Invoice) or Vendor (Bill) contact |
| ApplyToContact | Contact | No | Navigation property to customer/vendor |
| BillToContactAddressId | int? | No | Billing address for this transaction |
| BillToContactAddress | ContactAddress | No | Navigation property to billing address |
| AccountId | int? | No | GL account for posting |
| Account | AccountingAccount | No | Navigation property to GL account |
| PaymentTermsId | int? | No | Payment terms for this transaction |
| PaymentTerm | PaymentTerm | No | Navigation property to payment terms |
| AmountDue | decimal | Yes | Current balance due (Total charges - Total payments) |
| AmountPaid | decimal | Yes | Total amount paid against this transaction |
| PaidAs | PaidAs | Yes | Prepaid or Collect (freight payment method) |
| Note | string? | No | Internal notes or comments |
| IsDraft | bool | Yes | Whether transaction is draft (default: false) |
| CustomValues | Dictionary<string, object?> | No | Extensible custom properties dictionary |
| Created | DateTime | Yes | Creation timestamp (inherited from AuditableEntity) |
| CreatedBy | string | Yes | User ID who created the transaction (inherited) |
| LastModified | DateTime | Yes | Last modification timestamp (inherited) |
| LastModifiedBy | string | Yes | User ID who last modified (inherited) |
AccountingTransactionType Enum
Determines the nature and purpose of the financial document:
| Value | Description | Business Purpose | Affects |
|---|---|---|---|
| Invoice | Accounts Receivable document | Bill customer for services rendered | Increases customer AR balance |
| Bill | Accounts Payable document | Record vendor charges to pay | Increases vendor AP balance |
| CreditMemo | Accounts Receivable adjustment | Reduce customer balance (refund, discount, correction) | Decreases customer AR balance |
AccountingTransactionStatus Enum
Represents the payment lifecycle:
| Value | Description | Transition Rules |
|---|---|---|
| Open | Has outstanding balance due | Initial status when charges exist; automatic transition from Paid when new charges added |
| Paid | Fully paid, no balance due | Automatic transition when AmountDue <= 0 after payment application |
| Void | Cancelled transaction | Manual void; AmountDue and AmountPaid set to 0 |
Relationships (Navigation Properties)
| Relationship | Type | Description |
|---|---|---|
| Charges | ICollection<Charge> | Charges included in this transaction |
| AccountingTransactionCharges | ICollection<AccountingTransactionCharges> | Junction table for transaction-charge relationships |
| Payments | ICollection<Payment> | Payments applied to this transaction |
| AccountingTransactionPayments | ICollection<AccountingTransactionPayment> | Junction table for transaction-payment relationships with amount applied |
| Jobs | ICollection<Job> | Jobs associated with this transaction |
| JobAccountingTransactions | ICollection<JobAccountingTransaction> | Junction table for job-transaction relationships |
| Division | Division | Parent division |
| Account | AccountingAccount | GL account for posting |
| PaymentTerm | PaymentTerm | Payment terms |
| ApplyToContact | Contact | Customer (Invoice) or Vendor (Bill) |
| BillToContactAddress | ContactAddress | Billing address |
| Organization | Organization | Parent organization |