Hi all,
Happy new year, we've had a request from the users to add commodity codes for the sales invoice. This is fine, we already have a class which adds a bunch of information to the sales invoice (see below)
I cannot get either of the lines
salesInvoiceTmp.CommodityCode = EcoResCategory::find(inventTable.IntrastatCommodity).Code;
salesInvoiceTmp.CommodityCode = EcoResCategory::commodityCode(inventTable.IntrastatCommodity);
to save to salesinvoicetmp, as far as i'm concerned both lines above should work. When checking the tables in SQL i should get at least one code returned but the invoice is returning nothing. What am I missing?
class SalesInvoiceHandler
{
[PostHandlerFor(classStr(SalesInvoiceDP), methodstr(SalesInvoiceDP, processReport))]
public static void TmpTablePostHandler(XppPrePostArgs arguments)
{
SalesInvoiceDP dpInstance = arguments.getThis() as SalesInvoiceDP;
SalesInvoiceTmp salesInvoiceTmp = dpInstance.getSalesInvoiceTmp();
ttsbegin;
while select forUpdate salesInvoiceTmp
{
CustFormletterParameters custFormLetterParameters = CustFormletterParameters::find();
CustInvoiceJour custInvoiceJour = custInvoiceJour::findRecId(salesInvoiceTmp.JournalRecId);
CustInvoiceTrans custInvoiceTrans;
CustInvoiceTrans custInvoiceTrans2;
EcoResCategory ecoResCategory;
EcoResProduct ecoResProduct;
EcoResProductTranslation ecoResProductTranslation;
InventDim inventDim;
InventItemBarcode inventItemBarCode;
SalesLine salesLine;
select inventDim where inventDim.ConfigId == salesInvoiceTmp.ConfigId
&& inventDim.InventColorId == salesInvoiceTmp.InventColorId
&& inventDim.InventSizeId == salesInvoiceTmp.InventSizeId
&& inventDim.InventStyleId == salesInvoiceTmp.InventStyleId
&& inventDim.InventSiteId == ""
&& inventDim.InventLocationId == ""
&& inventDim.WMSLocationId == ""
&& inventDim.InventStatusId == "";
select * from inventItemBarCode where inventItemBarcode.inventDimId == inventDim.inventDimId
&& inventItemBarCode.ItemId == salesInvoiceTmp.ItemId
&& inventItemBarCode.BarcodeSetupId == "EAN-13";
salesInvoiceTmp.ItemBarCodeEAN = inventItemBarcode.ItemBarCode;
select * from inventItemBarCode where inventItemBarcode.inventDimId == inventDim.inventDimId
&& inventItemBarCode.ItemId == salesInvoiceTmp.ItemId
&& inventItemBarCode.BarcodeSetupId == "GTIN-12";
salesInvoiceTmp.ItemBarCodeUPC = inventItemBarcode.ItemBarCode;
select firstonly * from custInvoiceTrans where custInvoiceTrans.SalesId == custInvoiceJour.SalesId
&& custInvoiceTrans.InvoiceId == custInvoiceJour.InvoiceId
&& custInvoiceTrans.InvoiceDate == custInvoiceJour.InvoiceDate
&& custInvoiceTrans.numberSequenceGroup == custInvoiceJour.numberSequenceGroup
join salesLine where salesLine.InventTransId == custInvoiceTrans.InventTransId
join custInvoiceTrans2 where custInvoiceTrans2.RecId == salesLine.RefReturnInvoiceTrans_W;
salesInvoiceTmp.OrigInvoiceId = custInvoiceTrans2.InvoiceId;
InventTable inventTable = InventTable::find(salesInvoiceTmp.ItemId);
salesInvoiceTmp.CommodityCode = EcoResCategory::find(inventTable.IntrastatCommodity).Code;
//salesInvoiceTmp.CommodityCode = EcoResCategory::commodityCode(inventTable.IntrastatCommodity);
if (custFormLetterParameters.PrintProductName)
{
select firstonly * from ecoResProduct where ecoResProduct.DisplayProductNumber == salesInvoiceTmp.ItemId
join ecoResProductTranslation where ecoResProductTranslation.Product == ecoResProduct.RecId;
salesInvoiceTmp.Name = ecoResProductTranslation.Name;
}
salesInvoiceTmp.SumVATEuro = CurrencyExchangeHelper::curAmount2CurAmount(salesInvoiceTmp.SumTax, salesInvoiceTmp.CustInvoiceJourCurrencyCode, "EUR" , custInvoiceJour.InvoiceDate);
salesInvoiceTmp.update();
}
ttscommit;
}
}
After getting my debugging working again, it seems like for some reason the code in the update salesinvoicetmp is not executing, it's skipping going into the method... why would this be? Handler class is supposed to execute after DP class.

Report
All responses (
Answers (