3
votes

There is a new feature called Vendor Prepayments in AX 2012. It basically allows a company to prepay a vendor before the receipt of any goods. This was not there in AX 2009. So a user can basically attach a Prepayment record to a Purchase order and then post something called Prepayment invoice. When goods finally arrive, this Prepayment invoice is then applied to the "Real" Vendor invoice and settled. Its pretty straightforward and i guess logical.

My requirement is to do this Prepayment Invoice posting by code in X++.

If i try to use the PurchFormLetter class like below, it will post the Real invoice, which wont be correct as in the case of prepayments, there is no inventory transactions.

purchFormLetter = PurchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchTable,
                       '8001',
                       systemDateGet(),
                       PurchUpdate::All,
                       AccountOrder::None,
                       NoYes::No,
                       NoYes::Yes);

I have looked around in AX Dev Guides, on google, on blogs but no help.

Does anybody know this?

1

1 Answers

0
votes

I believe you should look into PurchPrepayTable table logic and PurchPrepayTable form. If you are using a single prepayment for a single purchase order then you can link the prepayment with a purchase using PurchPrepayTable.PurchTable. If you're willing to accomplish that by calling the X++ code, I would recommend:

  • Check if any PurchPrepayTable exists for the purchase order;
  • If it does -- update it (please make sure you run all validations before that);
  • If it does not -- create a new prepayment (please also refer to PurchPrepayTable table methods to make sure your values in prepayment pass all validations).