Static void Purchaseorder()
{
PurchTable purchTable;
PurchLine purchline;
NumberSeq numberSeq;
InventDim InventDimloc;
numberSeq =NumberSeq::newGetNum(purchparameters::numRefPurchId(),true);
purchTable.initValue();
purchTable.PurchId = numberSeq.num();
purchTable.OrderAccount = "US-101";
purchTable.InvoiceAccount ="US-101" ;
purchTable.CurrencyCode = "USD";
purchTable.LanguageId = currentUserLanguage();
purchTable.initFromVendTable();
if (purchTable.validateWrite())
{
purchTable.insert();
}
//purchase order lines
purchLine.PurchId = purchTable.PurchId;
purchLine.ItemId = "D0001" ;
purchLine.itemIdChanged();
select InventDimId from inventDimLoc
where inventDimLoc.InventLocationId=="13"
&& inventDimLoc.InventSiteId=="1";
purchLine.InventDimId=inventDimLoc.InventDimId;
purchLine.PurchQty = 5.0;
purchLine.modifiedField(fieldNum(purchLine, PurchQty));
purchLine.PurchUnit = "EA";
//purchLine.PurchPrice = RealEdit1.realValue();
purchLine.modifiedField(fieldNum(purchLine, PurchPrice));
purchLine.setPriceDiscChangePolicy(PriceDiscSystemSource::ManualEntry,fieldNum(purchLine, PurchPrice));
purchLine.createLine(true, true, true, true, true, true);
ttsBegin;
purchLine.selectForUpdate(true);
// purchLine.InventDimId=inventDimLoc.InventDimId;
purchLine.PurchPrice = 500.0;
purchLine.LineAmount = purchLine.PurchQty * purchLine.PurchPrice ;
purchLine.update();
ttscommit;
info(strFmt("@DAR91",purchTable.PurchId));
}
No comments:
Post a Comment