Hi Experts,
I am not getting correct data based on date range as given below. I know that need to some correct code.
Please help me.
*This post is locked for comments
And now when you debug it, where date is coming from ?
Yes I did CIL. Code is given below.
private void insertIntoTempTable()
{
SalesTable salesTable;
InventTable inventTable;
InventItemGroupItem inventItemGroupItem;
InventTrans inventTrans;
InventTransOrigin inventTransOrigin;
CustInvoiceJour custInvoiceJour;
CustInvoiceTrans custInvoiceTrans;
TaxTrans taxTrans;
FromDate fromDate;
ToDate toDate;
;
salesTable = SalesTable::find(salesLine.SalesId);
select firstOnly inventTransOrigin where inventTransOrigin.InventTransId == salesLine.InventTransId;
select firstOnly inventTrans where inventTrans.InventTransOrigin == inventTransOrigin.RecId;
select firstOnly taxTrans where taxTrans.InventTransId ==inventTransOrigin.InventTransId ;
select firstOnly custInvoiceJour
where custInvoiceJour.SalesId == salesTable.SalesId
&& custInvoiceJour.InvoiceDate >= fromDate
&& custInvoiceJour.InvoiceDate <= toDate
exists join custInvoiceTrans
where custInvoiceJour.InvoiceId == custInvoiceTrans.InvoiceId
&& custInvoiceTrans.InventTransId == salesLine.InventTransId;
{
salesOrderTmp.CustAccount = salesTable.CustAccount;
salesOrderTmp.AccountName = CustTable::find(salesTable.CustAccount).name();
salesOrderTmp.CustClassificationId = CustTable::find(salesTable.CustAccount).CustClassificationId;
salesOrderTmp.WorkerName = CustTable::find(salesTable.CustAccount).workerName();
salesOrderTmp.Date = custInvoiceJour.InvoiceDate;
salesOrderTmp.InvoiceId = custInvoiceJour.InvoiceId;
salesOrderTmp.SalesId = salesTable.SalesId;
salesOrderTmp.WorkerSales = HcmWorker::find(salesTable.WorkerSalesResponsible).name();
salesOrderTmp.OriginId = salesTable.SalesOriginId;
salesOrderTmp.OriginDescription = SalesOrigin::find(salesTable.SalesOriginId).Description;
salesOrderTmp.ItemId = salesLine.ItemId;
salesOrderTmp.FabricationType = this.getFabricationTypeByDefaultDimension(salesLine.DefaultDimension);
salesOrderTmp.ItemIdDescription = salesLine.itemName();
salesOrderTmp.InventLocationId = InventDim::find(salesLine.InventDimId).InventLocationId;
salesOrderTmp.SalesQty = salesLine.SalesQty;
salesOrderTmp.Selling = salesLine.SalesQty * salesLine.SalesPrice;
salesOrderTmp.COG = salesLine.SalesQty * inventTrans.costPrice();
salesOrderTmp.TaxAmount = taxTrans.TaxAmount;
salesOrderTmp.TaxCode = taxTrans.TaxCode;
salesOrderTmp.GrossProfit = salesOrderTmp.Selling - salesOrderTmp.COG;
if(salesOrderTmp.GrossProfit != 0 && salesOrderTmp.Selling != 0)
{
if(salesOrderTmp.GrossProfit > 0)
salesOrderTmp.LinePercent = (salesOrderTmp.GrossProfit / salesOrderTmp.Selling) * 100;
else
salesOrderTmp.LinePercent = ((salesOrderTmp.GrossProfit / salesOrderTmp.Selling) * 100) * -1;
}
else
salesOrderTmp.LinePercent = 0;
inventTable = InventTable::find(salesLine.ItemId);
select firstOnly inventItemGroupItem
where inventItemGroupItem.ItemId == inventTable.ItemId
&& inventItemGroupItem.ItemDataAreaId == inventTable.dataAreaId
;
salesOrderTmp.Vendor = inventTable.PrimaryVendorId;
salesOrderTmp.SFA_ArabicItemName = inventTable.SFA_ArabicItemName;
salesOrderTmp.VendorName = VendTable::find(inventTable.PrimaryVendorId).name();
salesOrderTmp.ItemGroupId = inventItemGroupItem.ItemGroupId;
salesOrderTmp.insert();
}
}
Did you do CIL after changing your code? Also share new code, so we can see what changes you've done.
Thanks for you support, but still some no changed.
Something like
select firstOnly custInvoiceJour where custInvoiceJour.SalesId == salesTable.SalesId
&& custInvoiceJour.InvoiceDate >= fromDate
&& custInvoiceJour.InvoiceDate <= toDate
exists join custInvoiceTrans
where custInvoiceJour.InvoiceId == custInvoiceTrans.InvoiceId
&& custInvoiceTrans.InventTransId == salesLine.InventTransId
Thanks ievgen,
I tried but no luck. Can you please update code as you suggested.
Thanks again.
You can add where clause for your select to limit custInvoiceTrans by date, that should fix the issue.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156