Table: dbo.Pending_AP_Payment_Application
This table holds pending applications. A pending application is the pairing of one existing payable and one existing payment, or one existing payable and one pending payment. It can be used to create a real (no longer pending) application of payment to payable.
Columns
Name | Type | Constraints | Description
pending_ap_payment_application_KEY | int (4) | NOT NULL | Primary Key for this table.
vendor_KEY | int (4) | NOT NULL | The vendor linked to the payment and the payable.
payable_transaction_KEY | int (4) |  | A foreign key to an existing payable transaction. If this is null then the record is incomplete, but this is an allowed state to save off work in progress. This key will appear in several records for the same client and vendor if one payable is paired with several payments.
payment__gl_transaction_KEY | int (4) |  | A foreign key to an existing payment transaction, and this key will be reused if several payables are linked with one existing payment. To put it another way, several table records for the same client and vendor could have repeats of this key.
pending_ap_payment_KEY | int (4) |  | A foreign key to a pending payment, and this key will be reused if several payables are linked to the same pending payment. To put it another way, several table records for the same client and vendor could have repeats of this key.
application_selection_group_number | int (4) |  | Used when we are linking an existing payment with a payable. This key will be reused if several payables are linked with one existing payment, or several existing payments are linked with one payable. To put it another way, several table records for the same client and vendor could have repeats of this key. Null when not using an existing payment.
payment_selection_group_number | int (4) |  | Used when we are linking a pending payment with a payable. One pending payment can be linked to one or more existing payables with a payment group number. To put it another way, several table records for the same client and vendor could have repeats of this key. Null when not using a pending payment.
paid_amount | decimal (9, 2) | NOT NULL | The amount of this pending application, that is, the amount by which a payment and a payable will be reduced en route to reducing the payable down to an amount remaining to be paid of zero dollars and zero cents.
discount_taken_amount | decimal (9, 2) | NOT NULL | If a discount is to be taken with this application, it will reduce the amount remaining to be paid of the payable by this amount.

Primary key
Name | Columns | Description
PK_Pending_AP_Payment_Application | pending_ap_payment_application_KEY |

Foreign keys
Name | Columns | Referenced table | Description
FK_Pending_AP_Payment_Application__Payable_Transaction__payable_transaction_KEY | payable_transaction_KEY | Payable_Transaction (payable_transaction_KEY) |
FK_Pending_AP_Payment_Application__Pending_AP_Payment__pending_ap_payment_KEY | pending_ap_payment_KEY | Pending_AP_Payment (pending_ap_payment_KEY) |
FK_Pending_AP_Payment_Application__Vendor__vendor_KEY | vendor_KEY | Vendor (vendor_KEY) |
FK_Pending_AP_Payment_Application__GL_Transaction__payment__gl_transaction_KEY | payment__gl_transaction_KEY | GL_Transaction (gl_transaction_KEY) |