Table: dbo.AR_Payment_Application
Each row in this table represents a payment being applied to a receivable. A payment is either a credit memo (an AR_Transaction of type Credit Memo) or an AR payment (an AR_Payment of any type). A receivable is a regular invoice or a finance charge invoice (an AR_Transaction of type Invoice or Finance Charge). The receivable and payment must belong to the same customer. A given receivable can have multiple payments applied to it until its open balance is zero. A given payment can be applied until its unused amount is zero.
Columns
Name | Type | Constraints | Description
gl_transaction_KEY | int (4) | NOT NULL | This foreign key is the primary key for the table. The associated GL transaction row contains the GL period and journal that the distribution affects.
receivable__gl_transaction_KEY | int (4) | NOT NULL | This required foreign key identifies the receivable being paid by the payment. A receivable is a regular invoice or a finance charge invoice (an AR_Transaction of type Invoice or Finance Charge).
payment__gl_transaction_KEY | int (4) | NOT NULL | This required foreign key identifies the payment paying the receivable. A payment is either a credit memo (an AR_Transaction of type Credit Memo) or an AR payment (an AR_Payment of any type).
application_date | smalldatetime (4) | NOT NULL | This is the date that the payment was applied to the receivable. This is only a date; the time portion is always set to midnight.
was_applied_at_payment_creation | bit (1) | NOT NULL | This boolean is set true if the payment application was made at the time the payment was created. This information is needed to properly determine the amount that hits the unearned revenue account. Monies applied when the payment is created should never count as unearned revenue.

Primary key
Name | Columns | Description
PK_AR_Payment_Application$gl_transaction_KEY | gl_transaction_KEY |

Foreign keys
Name | Columns | Referenced table | Description
FK_AR_Payment_Application__AR_Transaction__receivable__gl_transaction_KEY | receivable__gl_transaction_KEY | AR_Transaction (gl_transaction_KEY) |
FK_AR_Payment_Application__GL_Transaction__gl_transaction_KEY | gl_transaction_KEY | GL_Transaction (gl_transaction_KEY) |
FK_AR_Payment_Application__GL_Transaction__payment__gl_transaction_KEY | payment__gl_transaction_KEY | GL_Transaction (gl_transaction_KEY) |

Incoming foreign keys
Name | Columns | Referencing table | Description
FK_AR_Payment_Application_Distribution__AR_Payment_Application__payment_application__gl_transaction_KEY | payment_application__gl_transaction_KEY | AR_Payment_Application_Distribution |