Article ID: KB0063
Where does Commission Plan get the Date Document Paid value?
When a sales document is posted, an associated receivables document is created in table RM_OPEN (RM20101), with the receivables document number = the sales document number and the RM Document Type-All = 1 (invoice) or 8 (return). When the receivables document is fully relieved and the Paid Transaction Removal routine is run, the receivables document is moved from table RM_OPEN to RM_HISTORY (RM30101).
The above is standard Dynamics GP functionality, and it means that when commissions are created or updated for a posted sales document, we look for the associated receivables document in table RM_OPEN. If a record does not exist, we look for the associated receivables document in RM_HISTORY*. Once we find the record in either RM_OPEN or RM_HISTORY, we use the following logic to determine the Commission Plan Date Document Paid (ASIDTIPD)**:
- If the Current Trx Amount (CURTRXAM) of the RM record is not zero, set the Commission Plan Date Document Paid = ‘1900-1-1’ and exit the script (this check is performed only if the record is in RM_OPEN).
- Set the Commission Plan Date Document Paid to the latest of the following 3 dates from the RM record:
- Date Invoice Paid Off (DINVPDOF) – this is the date the document was fully relieved, for both invoices and returns
- GL Posting Date (GLPOSTDT)
- Document Date (DOCDATE)
We use the latest of these dates (rather than just using the Date Invoice Paid Off) for 2 reasons:
- A bug has persisted in Dynamics GP for many versions, which causes an empty Date Invoice Paid Off value even though the receivables document is fully relieved in some instances.
- Within Dynamics GP, it’s possible to have the Document Date, GL Posting Date , and Date Invoice Paid Off not appear in chronological order. For instance, you could have a document date of 2014-5-1, a posting date of 2014-4-1, and a paid off date of 2013-12-1. Using the latest date gives our clients the best chance of including the commission in their next processing run when using a Date Document Paid range in the Process Commissions window.
* If we don’t find the associated receivables document in either RM_OPEN or RM_HISTORY and the sales document is an invoice, we determine whether the invoice represents a WennSoft service call. If the invoice IS a WennSoft service call, we obtain the associated receivables document number from WennSoft tables and look for a record in RM_OPEN / RM_HISTORY for the associated receivables document number and RM Document Type-All = 5 (Service/Repairs). If we find a record, the logic to determine the Commission Plan Date Document Paid is the same as above.
** If the Commission Plan Date Document Paid was manually overridden, all steps to determine the date are skipped.