protected void executePostingDataPerOrder(str _salesId)
{
SalesFormLetter_PackingSlip salesFormLetter_PackingSlip;
salesFormletterParmData salesFormLetterParmData;
SalesParmTable salesParmTable;
salesParmUpdate salesParmUpdate;
SalesTable salestable = SalesTable::find(_salesId, true);
SalesLine salesLine;
TransDate PackingSlipDate;
PackingSlipDate = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
if (salestable && salestable.SalesStatus == SalesStatus::Backorder)
{
salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::PackingSlip, VersioningUpdateType::Initial);
salesFormLetterParmData.parmOnlyCreateParmUpdate(true);
salesFormLetterParmData.createData(false);
salesParmUpdate = salesFormLetterParmData.parmParmUpdate();
salesParmTable.clear();
salesParmTable.TransDate = PackingSlipDate;
salesParmTable.Ordering = DocumentStatus::PackingSlip;
salesParmTable.ParmJobStatus = ParmJobStatus::Waiting;
salesParmTable.salesId = salesTable.salesId;
salesParmTable.salesName = salesTable.salesName;
salesParmTable.DeliveryName = salesTable.DeliveryName;
salesParmTable.DeliveryPostalAddress = salesTable.DeliveryPostalAddress;
salesParmTable.CustAccount = salesTable.CustAccount;
salesParmTable.CurrencyCode = salesTable.CurrencyCode;
salesParmTable.InvoiceAccount = salesTable.InvoiceAccount;
salesParmTable.ParmId = salesParmUpdate.ParmId;
salesParmTable.insert();
while select salesLine
where salesLine.SalesId == _salesId
&& salesLine.InventTransId
{
salesParmLine.Clear();
salesParmLine.InitFromsalesLine(salesline);
salesParmLine.DeliverNow = salesline.SalesQty;
salesParmLine.ParmId = salesParmTable.ParmId;
salesParmLine.TableRefId = salesParmTable.TableRefId;
salesParmLine.setQty(DocumentStatus::PackingSlip, false, true);
salesParmLine.setLineAmount(salesline);
salesParmLine.closed = NoYes::No; //Set to Yes, if want to short close order line
salesParmLine.insert();
salesParmSubLine.clear();
salesParmSubLine.initValue();
salesParmSubLine.initFromSalesParmLine(salesParmLine);
salesParmSubLine.InventNow = salesLine.SalesQty;
salesParmSubLine.DeliverNow = salesLine.SalesQty;
salesParmSubLine.insert();
}
salesFormLetter_PackingSlip = SalesFormLetter::construct(DocumentStatus::PackingSlip);
salesFormLetter_PackingSlip.transDate(PackingSlipDate);
salesFormLetter_PackingSlip.proforma(NoYes::No);
salesFormLetter_PackingSlip.specQty(salesUpdate::PackingSlip);
salesFormLetter_PackingSlip.salesTable(salesTable);
salesFormLetter_PackingSlip.parmId(salesParmTable.ParmId);
salesFormLetter_PackingSlip.salesParmUpdate(salesFormLetterParmData.parmParmUpdate());
salesFormLetter_PackingSlip.runOperation();
}
}
No comments:
Post a Comment