Hi,
I can adjust the sales tax on the order, but when I try to convert it to an invoice I get the following error.
Tax is regulated on sales order ID S24601
Tax regulations are found Sales orders cannot be rearranged when individual sales orders are tax regulated.
Remove the regulation on the orders, rearrange and regulate the tax on the summary order.
Update has been canceled because of an error.
The closest I've come is using the code below:
// This is the only method in the ImportToAX Class
str ImportSalesOrder (str CustAccount, str _oppNo,SalesPrice MinPmtAmt, int qty, TaxItemGroup taxItemGroup, SalesPrice SlsTax)
{
InventDim inventDim;
NumberSeq NumberSeq;
SalesTotals SalesTotals;
TaxRegulation TaxRegulation;
;
retval = "";
try
{
// Obtain the next SalesId (Next Number Sequence)...
NumberSeq = NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId().numberSequence);
salesTable.SalesId = NumberSeq.num();
// Create the Sales Order...
salesTable.initValue();
salesTable.CustAccount = CustAccount;
salesTable.PurchOrderFormNum = _oppNo;
salesTable.SalesResponsible = "CADMIN";
salesTable.initFromCustTable();
salesTable.insert();
// Create the Sales Line...
//salesLine.clear();
salesLine.SalesId = salesTable.SalesId;
// The following three lines were added, because AX was requiring a defined site for inventory dimensions…
inventDim = salesLine.inventDim();
inventDim.InventSiteId = "A2b";
salesLine.setInventDimIdFromInventDim(inventDim);
// Item information
salesLine.ItemId = 'ZA-MS';
salesLine.SalesPrice = (MinPmtAmt/qty);
salesLine.LineAmount = MinPmtAmt;
salesLine.SalesQty = qty;
salesLine.QtyOrdered = qty;
salesLine.SalesUnit = 'EA';
salesLine.TaxItemGroup = taxItemGroup;
// Create the Invoice
salesLine.createLine(NoYes::Yes, NoYes::Yes, NoYes::No, NoYes::Yes, NoYes::No, NoYes::No);
////////////////// Test code for sales tax adjustment
salesTotals = salesTotals::construct(salesTable, salesUpdate::All);
taxRegulation = TaxRegulation::newTaxRegulation(salesTotals.tax());
taxRegulation.allocateAmount(SlsTax);
taxRegulation.saveTaxRegulation();
//////////////////////
retval = salesTable.SalesId;
}
catch
{
retval = "";
}
return retval;
}
SalesFormLetter CreateInvoice(TransDate MinDate, boolean doPrint, SalesPrice SlsTax)
{
PrintJobSettings printJobSettings;
SalesFormLetter_Invoice letter=SalesFormLetter::construct(DocumentStatus::Invoice);
taxRegulation taxRegulation;
TaxWorkRegulation TaxWorkRegulation;
salesTotals salesTotals;
SalesParmUpdate SalesParmUpdate;
;
// Create the Invoice
ttsBegin;
printJobSettings = new PrintJobSettings();
printJobSettings.SetTarget(PrintMedium::Printer);
printJobSettings.suppressScalingMessage(true);
letter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());
letter.update(salesTable, MinDate, SalesUpdate::All, AccountOrder::None, false, doPrint);
ret = letter;
ttsCommit;
return ret;
}
Any help would be greatly appreciated.
Thanks,
Dave