How adjust an InventTrans programatically?

pedroparra
Member Posts: 58
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!
I can do this in:
Invent, Periodic, Closing and adjustment.
But can I do this programmatically? and How?
Thanks!
0
Comments
-
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 guys0 -
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)
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.com0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions