How adjust an InventTrans programatically?

pedroparrapedroparra Member Posts: 58
edited 2006-01-29 in Dynamics AX
Hi, I want to adjust the physical transaction produced by a invoiced purch line so can I add an adjustment to the Financial Cost Amount.

I can do this in:

Invent, Periodic, Closing and adjustment.

But can I do this programmatically? and How?

Thanks!

Comments

  • pedroparrapedroparra Member Posts: 58
    Hi,
    I have tried this way to do this:

    In PurchFormLetter_Invoice class, at the end of the method updateNow I have included a call to a new method of PurchFormLetter created in order to include my modifications:

    private void adjustInventTransMP(PurchLine _purchLine)
    {
    PurchTable pTable2;
    InventTransAdjust _inventTransAdjust;
    NumberSeq _numberSeq;
    ;


    pTable2 = PurchTable::find( purchLine.PurchId);
    if ((pTable2.TipoPedido == TipoPedido::MateriaPrima) &&
    (pTable2.Portes == JJ_Portes::Debidos &&
    pTable2.CosteTransporte != 0 )){
    ttsbegin;
    numberSeq = NumberSeq::newGetNum(InventClosing::numberSequenceReference(InventAdjustmentType::Transaction));
    _inventTransAdjust = new InventTransAdjust( today(), numberSeq.num());
    _inventTransAdjust.updateNow( InventTrans::findTransId( _purchLine.InventTransId, true),
    NoYes::No,
    NoYes::No,
    pTable2.CosteTransporte);
    info("Se ajustó la transaccion de inventario añadiendo el coste de transporte de MP.");
    ttscommit;
    }
    }

    Here I explain want I have done:

    For some types of Purch orders (MateriaPrima) we want to include the cost of the transport in the total cost of the item purchased but not include that cost in a post to ledger because we have purch orders for transport created in other place.

    So we want to adjust the physical transaction in order to include the cost of the transport in the total cost of the item purchased.

    In the code of this new method I use the class InventTransAdjust to adjust the cost.

    Is this code correct? I can identify the transaction of a purchline with only the InventTransId field?

    Thanks guys
  • ManekazeManekaze Member Posts: 6
    Hi Pedro,

    Is this code correct? I can identify the transaction of a purchline with only the InventTransId field?

    I've not tested your code but ... it seems to be correct. (But I can recommend to you that you try it in a test environment first :wink: )

    You can identify the transaction of a purchline with the inventTransId field with no problems in normal circumstances, the only "strange" thing you can found (depends on the user way of work) is that you can get many inventtrans lines for each purchline.

    Good luck

    Mkz.

    Note :Pedro seems to be an Spanish name, please don't forget to visit www.trucosaxapta.com :mrgreen:
    http://www.TrucosAx.com
    A Dynamics Ax (Axapta) tricks site in Spanish language :)
Sign In or Register to comment.