I had been searching the internet to find the code. But i couldnt, every code leads to full invoice or line by line invoice. so i did some exploring to come up with a below code it will invoice partial quantity
I updated the partial sales invoice through code...
SalesFormLetter salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
SalesTable salesTAble;
SalesParmLine parmLine;
;
salesTable = SalesTable::find('FUAE-000002');
salesFormLetter.salesTable(salesTAble);
salesFormLetter.transDate (systemDateGet());
salesFormLetter.specQty (SalesUpdate::All);
//If you want proforma you can enable the code
//salesFormLetter.proforma (true);
//salesFormLetter.printFormLetter (true);
salesFormLetter.createParmUpdateFromParmUpdateRecord(salesFormLetter.s alesParmUpdate());
salesFormLetter.initParmSalesTable(salesTAble);
salesFormLetter.initParameters(salesFormLetter.salesParmUpdate(),Printout::After);
salesFormLetter.initLinesQuery();
while select forUpdate parmLine where parmLine.ParmId == salesFormLetter.parmId()
{
ttsBegin;
parmLine.DeliverNow = 10;
parmLine.setQty(parmLine.salesParmTable().ordering, salesFormLetter.SalesParmUpdate().creditRemaining);
parmLine.setInventDeliverNow();
parmLine.setLineAmount();
parmLine.update();
ttsCommit;
}
salesFormLetter.run();
I updated the partial sales invoice through code...
SalesFormLetter salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
SalesTable salesTAble;
SalesParmLine parmLine;
;
salesTable = SalesTable::find('FUAE-000002');
salesFormLetter.salesTable(salesTAble);
salesFormLetter.transDate (systemDateGet());
salesFormLetter.specQty (SalesUpdate::All);
//If you want proforma you can enable the code
//salesFormLetter.proforma (true);
//salesFormLetter.printFormLetter (true);
salesFormLetter.createParmUpdateFromParmUpdateRecord(salesFormLetter.s alesParmUpdate());
salesFormLetter.initParmSalesTable(salesTAble);
salesFormLetter.initParameters(salesFormLetter.salesParmUpdate(),Printout::After);
salesFormLetter.initLinesQuery();
while select forUpdate parmLine where parmLine.ParmId == salesFormLetter.parmId()
{
ttsBegin;
parmLine.DeliverNow = 10;
parmLine.setQty(parmLine.salesParmTable().ordering, salesFormLetter.SalesParmUpdate().creditRemaining);
parmLine.setInventDeliverNow();
parmLine.setLineAmount();
parmLine.update();
ttsCommit;
}
salesFormLetter.run();
Thanks a lot for a great post!
ReplyDeleteVery good. Please, I have a question!. How can I include misc charges in the invoice? This apply to Puch Order.
ReplyDeleteHi,
ReplyDeleteGreat Post.
How to do same in partial packing slip by code. please help. change the document status is enough??
Nice post you can subscribe MSDAx ERP Related video from here
ReplyDeletehttps://www.youtube.com/user/sksingh1980
This is actually only applicable when you want to invoice all lines to a specific qty or you only have one line on the sales order.
ReplyDeleteFor a partial delivery for specific product, something can be done like this
Public Static boolean postSalesInvoiceItem(SalesId _salesId,ItemId _itemId, Qty _qty)
{
salesFormLetter salesFormLetter;
salesFormletterParmData salesFormLetterParmData;
salesParmUpdate salesParmUpdate;
salesParmTable salesParmTable;
salesParmLine salesParmLine;
salesTable salesTable;
salesLine salesLine;
boolean ret;
salesTable = salesTable::find(_salesId);
try
{
ttsBegin;
// Create salesParamUpdate table
salesFormLetterParmData = salesFormletterParmData::newData(DocumentStatus::Invoice,VersioningUpdateType::Initial);
salesFormLetterParmData.parmOnlyCreateParmUpdate(true);
salesFormLetterParmData.createData(false);
salesParmUpdate = salesFormLetterParmData.parmParmUpdate();
// Set salesParmTable table
salesParmTable.clear();
salesParmTable.TransDate = SystemDateGet();
salesParmTable.Ordering = DocumentStatus::Invoice;
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();
// Set salesParmLine table
select salesLine
where salesLine.salesId == salesTable.salesId
&& salesLine.ItemId == _itemId;
{
salesParmLine.InitFromsalesLine(salesLine);
salesParmLine.DeliverNow = _qty;
salesParmLine.ParmId = salesParmTable.ParmId;
salesParmLine.TableRefId = salesParmTable.TableRefId;
salesParmLine.setQty(DocumentStatus::Invoice, false, true);
salesParmLine.setLineAmount();
salesParmLine.insert();
}
salesFormLetter = salesFormLetter::construct(DocumentStatus::Invoice);
salesFormLetter.transDate(systemDateGet());
salesFormLetter.proforma(false);
salesFormLetter.specQty(salesUpdate::All);
salesFormLetter.salesTable(salesTable);
salesFormLetter.parmId(salesParmTable.ParmId);
salesFormLetter.salesParmUpdate(salesFormLetterParmData.parmParmUpdate());
salesFormLetter.run();
ttsCommit;
}
catch (Exception::Error)
{
ret = false;
}
how to do same thing for packing slip
DeleteHow post multiple sales order for one invoice with selected lines through x++ code??
ReplyDeleteI would highly recommend Mr, Benjamin services to any person in need financial help and they will keep you on top of high directories for any further needs. Once again I commend yourself and your staff for extraordinary service and customer service, as this is a great asset to your company and a pleasant experience to customers such as myself. Wishing you all the best for the future.Mr, Benjamin is best way to get an easy loan,here is there email.. / 247officedept@gmail.com Or talk to Mr Benjamin On WhatsApp Via_+1-989-394-3740 Thank You for helping me with loan once again in my sincerely heart I'm forever grateful.
ReplyDeleteHi,
ReplyDeleteIt's working for entire quantity not for partial Quantity.