static void PurchOrderCreate(Args _args)
{
NumberSeq numberSeq;
PurchTable purchTable;
PurchLine purchLine;
ttsBegin;
numberSeq = NumberSeq::newGetNum(PurchParameters::numRefPurchId());
numberSeq.used();
purchTable.PurchId = numberSeq.num();
purchTable.initValue();
purchTable.initFromVendTable(VendTable::find('1001'));
if (!purchTable.validateWrite())
{
throw Exception::Error;
}
purchTable.insert();
purchLine.PurchId = purchTable.PurchId;
purchLine.ItemId = '1205';
purchLine.createLine(true, true, true, true, true, true);
ttsCommit;
info(strFmt(
"Purchase order '%1' has been created",
purchTable.PurchId));
}
..............................................
static void PurchOrderPost(Args _args)
{
PurchFormLetter purchFormLetter;
PurchTable purchTable;
purchTable = PurchTable::find('000409');
purchFormLetter = PurchFormLetter::construct(
DocumentStatus::PurchaseOrder);
purchFormLetter.update(
purchTable,
'',
systemDateGet(),
PurchUpdate::All,
AccountOrder::None,
NoYes::No,
NoYes::Yes);
}
---------------------------------------------------------------------------------
static void Dev_CreatePO_and_Invoice(Args _args)
{
NumberSeq numberSeq;
Purchtable Purchtable;
PurchLine PurchLine;
PurchFormLetter purchFormLetter;
;
ttsbegin;
numberSeq = NumberSeq::newGetNumFromCode(purchParameters::numRefPurchaseOrderId().NumberSequence,true);
// Initialize Purchase order values
Purchtable.initValue();
Purchtable.PurchId = numberSeq.num();
Purchtable.OrderAccount = '3000';
Purchtable.initFromVendTable();
if (!Purchtable.validateWrite())
{
throw Exception::Error;
}
Purchtable.insert();
// Initialize Purchase Line items
PurchLine.PurchId = Purchtable.PurchId;
PurchLine.ItemId = 'B-R14';
PurchLine.createLine(true, true, true, true, true, false);
ttscommit;
purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchtable, // Purchase record Buffer
"Inv_"+purchTable.PurchId, // Invoice Number
systemdateget()); // Transaction date
if (PurchTable::find(purchTable.PurchId).DocumentStatus == DocumentStatus::Invoice)
{
info(strfmt("Posted invoiced journal for purchase order %1",purchTable.PurchId));
}
}
No comments:
Post a Comment