9.2. Database Tracking
Once the order report is processed, the order is complete. Therefore, it is the ideal place to put Interchange tags that make order entries in database tables.
A good model is to place a single record in a database summarizing the order and a series of lines that correspond to each line item in the order. This can be in the same database table. If the order number itself is the key for the summary, a line number can be appended to the order number to show each line of the order.
The following would summarize a sample order number S00001 for part number 00-0011 and 99-102:
code order_number part_number quantity price shipping tax S00001 S00001 3 2010 12.72 100.50 S00001-1 S00001 00-0011 2 1000 UPS yes S00001-2 S00001 99-102 1 10 UPS yes
Fields can be added where needed, perhaps with order status, shipping tracking number, address, customer number, or other information.
The above is accomplished with Interchange's [import ....] tag using the convenient NOTES format:
[set import_status] [import table=orders type=LINE continue=NOTES] code: [value mv_order_number] order_number: [value mv_order_number] quantity: [nitems] price: [subtotal noformat=1] shipping: [shipping noformat=1] tax: [salestax noformat=1] [/import] [item-list] [import table=orders type=LINE continue=NOTES] code: [value mv_order_number]-[item-increment] order_number: [value mv_order_number] quantity: [item-quantity] price: [item-price noformat=1] shipping: [shipping-description] tax: [if-item-field nontaxable]No[else]Yes[/else][/if] [/import][/item-list]