I can't create sales invoice by x++

Hello every one

I want to create sales invoice by using x++ coding but before create its, I want to adjust sales tax

so I have a problems. There is info log pop-up on my screen

"Tax is regulated on sales order ID SO-101245"

"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."

and this is my code

SalesFormLetter salesFormLetter;
SalesTable salesTable;
SalesLine SalesLine;
TaxWorkRegulation TaxWorkRegulation;
TaxOnItem TaxOnItem;
TaxTable TaxTable;
CustInvoiceJour CustInvoiceJour;
;
salesTable = SalesTable::find(“SO-101245”);
select SalesLine where SalesLine.SalesId == SalesTable.SalesId;
while select TaxOnItem where TaxOnItem.TaxItemGroup == SalesLine.TaxItemGroup
{
select TaxTable where TaxTable.TaxCode == TaxOnItem.TaxCode
&& TaxTable.TaxPeriod == SalesLine.TaxGroup;
if(TaxTable.TaxCode)
break;
}
TaxWorkRegulation.HeadingTableId = salesTable.TableId;
TaxWorkRegulation.HeadingRecId = salesTable.RecId;
TaxWorkRegulation.TaxCode = TaxTable.TaxCode;
TaxWorkRegulation.TaxRegulationAmountCur = -295;
TaxWorkRegulation.TaxDirection = TaxDirection::OutgoingTax;
TaxWorkRegulation.insert();
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
salesFormLetter.reArrangeNow(false);
salesFormLetter.update(salesTable, SystemDateGet(),
SalesUpdate::All, AccountOrder::Account, NoYes::No, NoYes::No,Noyes::No);

Help me please. I’m so run-down. I’m not want to be fired. T^T

P.S. Sorry about my english.

Ohh sorry. I’ve posted its twice. please forgive me.

Forgiven [:D]

And duplicate deleted from Navision forum. Moderator.