The Source Document Framework (Accounting Framework) will provide functionality necessary to record business events and create accounting for the newly created document – accounting distributions and subledger journal entries. But you will need to inform the framework how to deal with your document.

a)      Reference source document header

  • Modify the table definition of your document header table adding SourceDocumentHeader field of type SourceDocumentHeaderRecId.
  • Add your header table to SourceDocumentHeaderImplementation map (under AOT/Data Dictionary/Maps/SourceDocumentHeaderImplementation/Mappings) – adding a mapping to SourceDocumentHeader field from your header table.
  • Create an enum following the naming convention SourceDocument_MyDocument. Add values None = 0, MyDocument = 1. This enum and its values will be used by SourceDocumentExtensionAttribute to bind your classes to the framework in later steps.
  • Treat map as an interface: implement all methods from the map on the table – namely:

- parmSourceDocHeaderTypeEnumValue(): return appropriate value from the SourceDocument_MyDocument enum you created earlier

- parmSourceDocHeaderTypeEnumName(): return the name of the SourceDocument_MyDocument enum you created earlier

See existing implementations on CustInvoiceTable, VendInvoiceInfoTable and PurchTable tables for examples related to Customer Invoice, Vendor Invoice and Purchase Order documents respectively.

b)      Reference source document line

  • Modify the table definition of your document line table adding SourceDocumentLine field of type SourceDocumentLineRecId.
  • Add your line table to SourceDocumentLineImplementation map (under AOT/Data Dictionary/Maps/SourceDocumentLineImplementation/Mappings) – adding a mapping to SourceDocumentLine field from your line table.
  • Create an enum following the naming convention SourceDocumentLine_MyDocument. Add values None = 0, MyDocumentLine = 1. This enum and its values will be used by SourceDocumentExtensionAttribute to tie your classes to the framework in later steps.
  • Treat map as an interface: implement all methods from the map on the table – is this step you will use new base enums created in prior step. The following methods need to be implemented:

- parmSourceDocLineTypeEnumValue(): return appropriate value from the SourceDocumentLine_MyDocument  enum you created earlier

- parmSourceDocLineTypeEnumName(): return the name of the SourceDocumentLine_MyDocument enum you created earlier

- parmSourceDocumentHeader(): should return corresponding SourceDocumentHeader record

- parmParentSourceDocumentLine(): should return source document line which is a parent for given source document line (for example – tax line could return its parent invoice line)

- parmExchangeRateDate(): should return date of the exchange rate for given line

 See existing implementations on CustInvoiceLine, VendInvoiceInfoLine and PurchLine tables for examples related to Customer Invoice, Vendor Invoice and Purchase Order documents respectively.

c)       You may need to also modify your header table to be able to act like a line if you expect any accounting related to monetary amounts on the header. In AX 2012 an example of header related amount for which distributions are being created is Round-off (VendInvoiceInfoTable.InvoiceRoundOff).

  • In this case the header table needs do go through the same steps as the above step 2b described for the line table.
  • Add the enum value for the totals line (MyDocumentTotalsLine = 2) to the SourceDocumentLine_MyDocument enum which you created in step 2b.

 

Below is a data model diagram outlining the important relationships between your tables and the framework tables:


 

Next - Step 3: Perform initial wiring to Source Document Framework – document classes