Projects:
LK_BlobCustomer, LK_CostCenterfix, LK_FamsBug, LK_FamsIssue
-------------------------------------------------------------------------------To validate on form level description field for FreeTextinvoice form
[ExtensionOf(formDataSourceStr(CustFreeInvoice, CustInvoiceLine))]
internal final class LK_CustFreeInvoiceForm_Extension
{
public boolean validateWrite()
{
boolean ret = next validateWrite();
FormStringControl invoiceTxt = this.formRun().design().controlName("CustInvoiceLine_InvoiceTxt") as FormStringControl;
if (!invoiceTxt.valueStr())
{
ret = checkFailed("Invoice Text in line details must be filled in.");
}
return ret;
}
}
----------------------------------------------------------------------------------------------------------------------------
FAMS integrtion
Asset discard sold class
/// <summary>
/// This class <c>LK_FAMS_AssetSoldDiscardService</c> is Used for FAMS Asset Sold and Discard Integration and support class for the <c>LK_FAMS_AssetSoldDiscardService</c> class.
/// </summary>
/// <remarks>
/// This class is only used from the FAMS Asset Sold and Discard Integration.
/// </remarks>
class LK_FAMS_AssetSoldDiscardService extends SysOperationServiceBase
{
#LK_IntegrationConstant
/// <summary>
/// This Method is used to process the Service
/// </summary>
public void process()
{
AssetParameters assetParameters;
CustInvoiceTable custInvoiceTable;
LedgerJournalTable ledgerJournalTable;
LedgerJournalTrans ledgerJournalTrans;
CLRObject sysException;
str messages;
select firstonly LK_FromDateAssetSoldIntegration,LK_FromDateAssetDiscardIntegration from assetParameters;
if (curExt() == "@LK_Label:LensKartIndiaLegalEntity" || curExt() == "@LK_Label:DealsKartLegalEntity")
{
while select custInvoiceTable
where custInvoiceTable.CreatedDateTime >= assetParameters.LK_FromDateAssetSoldIntegration
{
try
{
if (custInvoiceTable.LK_ToBeSyncInFAMS == NoYes::Yes)
{
this.assetSold(custInvoiceTable);
}
}
catch
{
sysException = CLRInterop::getLastException();
while (sysException)
{
messages += sysException.get_Message();
sysException = sysException.get_innerexception();
}
continue;
}
}
while select ledgerJournalTrans
join ledgerJournalTable
where ledgerJournalTrans.JournalNum == ledgerJournalTable.JournalNum
&& ledgerJournalTable.CreatedDateTime >= assetParameters.LK_FromDateAssetDiscardIntegration
&& ledgerJournalTable.LK_ToBeSyncInFAMS == NoYes::Yes
{
try
{
this.assetDiscard(ledgerJournalTrans);
}
catch (Exception::Error)
{
sysException = CLRInterop::getLastException();
while (sysException)
{
messages += sysException.get_Message();
sysException = sysException.get_innerException();
}
}
}
}
}
/// <summary>
/// Get Token Access
/// </summary>
/// <param name = "lk_OutwardIntegration">Setup used for Integration</param>
/// <returns>Access token</returns>
public str getToken(LK_OutwardIntegration lk_OutwardIntegration)
{
str url;
str jsonString, tokenstr;
System.Net.HttpWebRequest request;
System.Net.HttpWebResponse response;
System.IO.Stream dataStream;
System.IO.StreamReader streamRead;
System.Net.ServicePoint servicePoint;
CLRObject clrObj;
System.Text.Encoding utf8;
Map serialMap;
System.Byte[] byteArrayBody;
System.Net.WebHeaderCollection headers;
str token;
MapEnumerator mapEnumerator;
container tokenContainer, tokenContainer1;
int i;
headers = new System.Net.WebHeaderCollection();
new InteropPermission(InteropKind::ClrInterop).assert();
str byteStr = strfmt('{ \"%1\": \"%2\", \"%3\": \"%4\"}', "@LK_Label:LKusername", lk_OutwardIntegration.Merchant_Key, "@LK_Label:LKpassword", lk_OutwardIntegration.Merchant_Pass);
headers = new System.Net.WebHeaderCollection();
url = lk_OutwardIntegration.AuthorizationUrl;
clrObj = System.Net.WebRequest::Create(url);
request = clrObj;
request.set_Method("@LK_Label:Post");
request.set_KeepAlive(true);
request.Accept = #ContentType;
utf8 = System.Text.Encoding::get_UTF8();
byteArrayBody = utf8.GetBytes(byteStr);
request.set_Headers(headers);
request.ContentType = #ContentType;
var stream = request.GetRequestStream();
if (stream)
{
stream.Write(byteArrayBody, 0, byteArrayBody.Length);
}
servicePoint = request.get_ServicePoint();
System.Net.ServicePointManager::set_Expect100Continue(false);
System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);
response = request.GetResponse();
dataStream = response.GetResponseStream();
streamRead = new System.IO.StreamReader(dataStream);
jsonString = streamRead.ReadToEnd();
serialMap = RetailCommonWebAPI::getMapFromJsonString(jsonString);
//start
mapEnumerator = serialMap.getEnumerator();
while(mapEnumerator.moveNext())
{
switch (mapEnumerator.currentKey())
{
case "@LK_Label:AccessToken":
tokenContainer = mapEnumerator.currentValue();
for (i=1; i<= conLen(tokenContainer);i++)
{
tokenContainer1 = conPeek(tokenContainer,i);
tokenstr = conPeek(tokenContainer1,1);
}
break;
}
}
//end
dataStream.Close();
response.Close();
token = tokenstr;
return token;
}
/// <summary>
/// This method used for Asset sold
/// </summary>
/// <param name = "custInvoiceTable">Get the data using Invoice Journal</param>
public Void assetSold(CustInvoiceTable custInvoiceTable)
{
System.Net.HttpWebRequest request;
System.Net.HttpWebResponse response = new System.Net.HttpWebResponse();
System.Byte[] bytes;
System.Text.Encoding utf8;
System.Net.WebHeaderCollection httpHeader;
System.Net.WebException webException;
System.IO.StreamReader streamReader;
str token;
System.IO.Stream requestStream, responseStream;
str companyName, companyLocation;
str destinationUrl;
str requestJson, responseJson;
AssetTable assetTable;
CustInvoiceLine custInvoiceLine;
LK_OutwardIntegration lk_OutwardIntegration;
LK_FAMS_AssetSoldDiscardLog lk_AssetSoldDiscardLog;
LK_FAMS_AssetSoldDiscardRequestContract lk_AssetSoldDiscardRequestContract;
lk_AssetSoldDiscardRequestContract = new LK_FAMS_AssetSoldDiscardRequestContract();
custInvoiceTable.selectForUpdate(true);
while select custInvoiceLine
where custInvoiceLine.ParentRecId == custInvoiceTable.RecId
join firstonly Location, LK_FAMSAssetCode from assetTable
where assetTable.AssetId == custInvoiceLine.AssetId
{
if(curExt() == "@LK_Label:LensKartIndiaLegalEntity")
{
companyLocation = "@LK_Label:LensKartSymbol" + assetTable.Location;
companyName = companyLocation + '-' + AssetLocation::find(assetTable.Location).Name;
}
if(curExt() == "@LK_Label:DealsKartLegalEntity")
{
companyLocation = "@LK_Label:DealsKartSymbol" + assetTable.Location;
companyName = companyLocation + '-' + AssetLocation::find(assetTable.Location).Name;
}
//M Vinodkumar - Validating values before request json 6 Aug 2025 - Start
requestJson = '';
responseJson = '';
if(assetTable.LK_FAMSAssetCode && companyName && custInvoiceTable.InvoiceId && custInvoiceTable.InvoiceDate && custInvoiceLine.UnitPrice && custInvoiceLine.InvoiceTxt)
{
lk_AssetSoldDiscardRequestContract.parmAssetCode(assetTable.LK_FAMSAssetCode);
lk_AssetSoldDiscardRequestContract.parmBranchName(companyName);
lk_AssetSoldDiscardRequestContract.parmSaleType(#SaleTypeSales);
lk_AssetSoldDiscardRequestContract.parmInvoiceNo(custInvoiceTable.InvoiceId);
lk_AssetSoldDiscardRequestContract.parmDateSoldOn(any2Str(custInvoiceTable.InvoiceDate));
lk_AssetSoldDiscardRequestContract.parmSoldValue(custInvoiceLine.UnitPrice);
lk_AssetSoldDiscardRequestContract.parmRemarks(custInvoiceLine.InvoiceTxt);
requestJson = FormJsonSerializer::serializeClass(lk_AssetSoldDiscardRequestContract);
Info(requestJson);
}
if (requestJson == '')
{
// Log the invalid request JSON
lk_AssetSoldDiscardLog.clear();
lk_AssetSoldDiscardLog.APIName = "@LK_Label:LK_FamsAssetSoldDiscard";
lk_AssetSoldDiscardLog.AssetId = custInvoiceLine.AssetId;
if(!assetTable.LK_FAMSAssetCode)
{
requestJson = "@LK_Label:LK_FAMSAssetcodemissing";
}
if(!companyName)
{ if(requestJson != '') requestJson += ',';
requestJson += "@LK_Label:LK_BranchNamemissing";
}
if(!custInvoiceTable.InvoiceId)
{
if(requestJson != '') requestJson += ',';
requestJson += "@LK_Label:LK_InvoiceIdmissing";
}
if(!custInvoiceTable.InvoiceDate)
{
if(requestJson != '') requestJson += ',';
requestJson += "@LK_Label:LK_InvoiceDatemissing";
}
if(custInvoiceLine.UnitPrice == 0)
{
if(requestJson != '') requestJson += ',';
requestJson += "@LK_Label:LK_UnitPricemissing";
}
if(!custInvoiceLine.InvoiceTxt)
{
if(requestJson != '') requestJson += ',';
requestJson += "@LK_Label:LK_InvoiceTxtmissing";
}
requestJson = "@LK_Label:LK_FlowerbracesStart" + requestJson + "@LK_Label:LK_FlowerbracesEnd";
lk_AssetSoldDiscardLog.RequestedPayload = requestJson;
lk_AssetSoldDiscardLog.Status = LK_Success_Fail_Enum::Failed;
lk_AssetSoldDiscardLog.ErrorLog = "@LK_Label:LK_InvalidJSONformat";
lk_AssetSoldDiscardLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_AssetSoldDiscardLog.insert();
}
//M Vinodkumar - Validating values before request json 6 Aug 2025 - End
else
{
try
{
select firstonly lk_OutwardIntegration
where lk_OutwardIntegration.APIName == "@LK_Label:LK_FamsAssetSoldDiscard";
token = this.getToken(lk_OutwardIntegration);
new InteropPermission(InteropKind::ClrInterop).assert();
httpHeader = new System.Net.WebHeaderCollection();
destinationUrl = lk_OutwardIntegration.API_URL;
request = System.Net.WebRequest::Create(destinationUrl);
utf8 = System.Text.Encoding::get_UTF8();
bytes = utf8.GetBytes(requestJson);
httpHeader.Add("@LK_Label:Authorization", "@LK_Label:LK_Bearer"+ ' '+ token);
httpHeader.Add("@LK_Label:ApplicationId",lk_OutwardIntegration.API_Id);
request.set_Method("@LK_Label:Post");
request.set_Headers(httpHeader);
request.set_ContentType(#ContentType);
request.set_Accept(#ContentType);
request.set_KeepAlive(true);
request.set_ContentLength(bytes.get_Length());
requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.get_Length());
response = request.GetResponse();
responseStream = response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
//info(responseJson);
LK_FAMS_AssetSoldDiscardResponseContract xppObject = new LK_FAMS_AssetSoldDiscardResponseContract();
xppObject = FormJsonSerializer::deserializeObject(
classNum(LK_FAMS_AssetSoldDiscardResponseContract),
responseJson);
lk_AssetSoldDiscardLog.clear();
if (xppObject.parmSyncStatus() == 0)
{
lk_AssetSoldDiscardLog.APIName = lk_OutwardIntegration.APIName;
lk_AssetSoldDiscardLog.AssetId = custInvoiceLine.AssetId;
lk_AssetSoldDiscardLog.AssetSaleId = xppObject.parmAssetSaleID();
lk_AssetSoldDiscardLog.RequestedPayload = requestJson;
lk_AssetSoldDiscardLog.ResponsePayload = responseJson;
lk_AssetSoldDiscardLog.AssetCode = xppObject.parmAssetCode();
lk_AssetSoldDiscardLog.ErrorLog = xppObject.parmSyncRemarks();
lk_AssetSoldDiscardLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_AssetSoldDiscardLog.Status = LK_Success_Fail_Enum::Failed;
lk_AssetSoldDiscardLog.URL = lk_OutwardIntegration.API_URL;
lk_AssetSoldDiscardLog.insert();
Error(xppObject.parmSyncRemarks());
}
else
{
lk_AssetSoldDiscardLog.APIName = lk_OutwardIntegration.APIName;
lk_AssetSoldDiscardLog.AssetId = custInvoiceLine.AssetId;
lk_AssetSoldDiscardLog.AssetSaleId = xppObject.parmAssetSaleID();
lk_AssetSoldDiscardLog.RequestedPayload = requestJson;
lk_AssetSoldDiscardLog.ResponsePayload = responseJson;
lk_AssetSoldDiscardLog.AssetCode = xppObject.parmAssetCode();
lk_AssetSoldDiscardLog.ErrorLog = xppObject.parmSyncRemarks();
lk_AssetSoldDiscardLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_AssetSoldDiscardLog.Status = LK_Success_Fail_Enum::Success;
lk_AssetSoldDiscardLog.URL = lk_OutwardIntegration.API_URL;
lk_AssetSoldDiscardLog.insert();
if(custInvoiceTable.RecId)
{
ttsbegin;
custInvoiceTable.LK_ToBeSyncInFAMS = NoYes::No;
custInvoiceTable.doUpdate();
ttscommit;
}
info(xppObject.parmSyncRemarks());
}
}
catch (webException)
{
responseStream = webException.Response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
// Insert error log into the table
lk_AssetSoldDiscardLog.AssetId = custInvoiceLine.AssetId;
lk_AssetSoldDiscardLog.RequestedPayload = requestJson;
lk_AssetSoldDiscardLog.ResponsePayload = responseJson;
lk_AssetSoldDiscardLog.ErrorLog = webException.Message;
lk_AssetSoldDiscardLog.APIName = "@LK_Label:LK_FamsAssetSoldDiscard";
lk_AssetSoldDiscardLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_AssetSoldDiscardLog.Status = LK_Success_Fail_Enum::Failed;
lk_AssetSoldDiscardLog.URL = lk_OutwardIntegration.API_URL;
lk_AssetSoldDiscardLog.insert();
}
requestStream.Close();
streamReader.Close();
responseStream.Close();
response.Close();
}
}
}
/// <summary>
/// This Method is used to discard the asset
/// </summary>
/// <param name = "ledgerJournalTrans">LedgerJournalTransaction</param>
public Void assetDiscard(LedgerJournalTrans ledgerJournalTrans)
{
System.Net.HttpWebRequest request;
System.Net.HttpWebResponse response = new System.Net.HttpWebResponse();
System.Byte[] bytes;
System.Text.Encoding utf8;
System.IO.Stream requestStream, responseStream;
System.IO.StreamReader streamReader;
System.Net.WebHeaderCollection httpHeader;
System.Net.WebException webException;
str token;
str companyName, companyLocation;
str destinationUrl;
str requestJson, responseJson;
LK_OutwardIntegration lk_OutwardIntegration;
LedgerJournalTable ledgerJournalTable = ledgerJournalTrans.ledgerJournalTable();
LK_FAMS_AssetSoldDiscardLog lk_AssetSoldDiscardLog;
LK_FAMS_AssetSoldDiscardRequestContract lk_AssetSoldDiscardRequestContract;
lk_AssetSoldDiscardRequestContract = new LK_FAMS_AssetSoldDiscardRequestContract();
AssetTable assetTable;
ledgerJournalTable.selectForUpdate(true);
select firstonly Location,LK_FAMSAssetCode from assetTable
where assetTable.AssetId == ledgerJournalTrans.accountDisplay();
if(curExt() == "@LK_Label:LensKartIndiaLegalEntity")
{
companyLocation = "@LK_Label:LensKartSymbol" + assetTable.Location;
companyName = companyLocation + '-' + AssetLocation::find(assetTable.Location).Name;
}
if(curExt() == "@LK_Label:DealsKartLegalEntity")
{
companyLocation = "@LK_Label:DealsKartSymbol" + assetTable.Location;
companyName = companyLocation + '-' + AssetLocation::find(assetTable.Location).Name;
}
//M Vinodkumar - Validating values before request json 6 Aug 2025 - Start
requestJson = '';
responseJson = '';
if (assetTable.LK_FAMSAssetCode && companyName && ledgerJournalTrans.Voucher && ledgerJournalTrans.TransDate && ledgerJournalTrans.Txt)
{
lk_AssetSoldDiscardRequestContract.parmAssetCode(assetTable.LK_FAMSAssetCode);
lk_AssetSoldDiscardRequestContract.parmBranchName(companyName);
lk_AssetSoldDiscardRequestContract.parmSaleType(#SalesTypeDiscard);
lk_AssetSoldDiscardRequestContract.parmInvoiceNo(ledgerJournalTrans.Voucher);
lk_AssetSoldDiscardRequestContract.parmDateSoldOn(any2Str(ledgerJournalTrans.TransDate));
lk_AssetSoldDiscardRequestContract.parmSoldValue(0);
lk_AssetSoldDiscardRequestContract.parmRemarks(ledgerJournalTrans.Txt);
requestJson = FormJsonSerializer::serializeClass(lk_AssetSoldDiscardRequestContract);
Info(requestJson);
}
if (requestJson == '')
{
// Log the invalid request JSON
lk_AssetSoldDiscardLog.AssetId = ledgerJournalTrans.accountDisplay();
if (!assetTable.LK_FAMSAssetCode)
{
requestJson = "@LK_Label:LK_FAMSAssetcodemissing";
}
if (!companyName)
{
if(requestJson != '') requestJson += ',';
requestJson += "@LK_Label:LK_BranchNamemissing";
}
if (!ledgerJournalTrans.Voucher)
{
if(requestJson != '') requestJson += ',';
requestJson += "@LK_Label:LK_Vouchermissing";
}
if (!ledgerJournalTrans.TransDate)
{
if(requestJson != '') requestJson += ',';
requestJson += "@LK_Label:LK_TransDatemissing";
}
if (!ledgerJournalTrans.Txt)
{
if(requestJson != '') requestJson += ',';
requestJson += "@LK_Label:LK_Txtmissing";
}
requestJson = "@LK_Label:LK_FlowerbracesStart" + requestJson + "@LK_Label:LK_FlowerbracesEnd";
lk_AssetSoldDiscardLog.RequestedPayload = requestJson;
lk_AssetSoldDiscardLog.ErrorLog = "@LK_Label:LK_InvalidJSONformat";
lk_AssetSoldDiscardLog.APIName = "@LK_Label:LK_FamsAssetSoldDiscard";
lk_AssetSoldDiscardLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_AssetSoldDiscardLog.Status = LK_Success_Fail_Enum::Failed;
lk_AssetSoldDiscardLog.insert();
}
//M Vinodkumar - Validating values before request json 6 Aug 2025 - end
else
{
try
{
select firstonly lk_OutwardIntegration
where lk_OutwardIntegration.APIName == "@LK_Label:LK_FamsAssetSoldDiscard";
token = this.getToken(lk_OutwardIntegration);
new InteropPermission(InteropKind::ClrInterop).assert();
httpHeader = new System.Net.WebHeaderCollection();
destinationUrl = lk_OutwardIntegration.API_URL;
request = System.Net.WebRequest::Create(destinationUrl);
utf8 = System.Text.Encoding::get_UTF8();
bytes = utf8.GetBytes(requestJson);
httpHeader.Add("@LK_Label:Authorization", "@LK_Label:LK_Bearer" +' ' + token);
httpHeader.Add("@LK_Label:ApplicationId",lk_OutwardIntegration.API_Id);
request.set_Method("@LK_Label:Post");
request.set_Headers(httpHeader);
request.set_ContentType(#ContentType);
request.set_Accept(#ContentType);
request.set_KeepAlive(true);
request.set_ContentLength(bytes.get_Length());
requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.get_Length());
response = request.GetResponse();
responseStream = response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
info(responseJson);
LK_FAMS_AssetSoldDiscardResponseContract xppObject = new LK_FAMS_AssetSoldDiscardResponseContract();
xppObject= FormJsonSerializer::deserializeObject(
classNum(LK_FAMS_AssetSoldDiscardResponseContract),
responseJson);
lk_AssetSoldDiscardLog.clear();
if (xppObject.parmSyncStatus() == 0)
{
lk_AssetSoldDiscardLog.APIName = lk_OutwardIntegration.APIName;
lk_AssetSoldDiscardLog.AssetSaleId = xppObject.parmAssetSaleID();
lk_AssetSoldDiscardLog.AssetId = ledgerJournalTrans.accountDisplay();
lk_AssetSoldDiscardLog.RequestedPayload = requestJson;
lk_AssetSoldDiscardLog.ResponsePayload = responseJson;
lk_AssetSoldDiscardLog.AssetCode = xppObject.parmAssetCode();
lk_AssetSoldDiscardLog.ErrorLog = xppObject.parmSyncRemarks();
lk_AssetSoldDiscardLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_AssetSoldDiscardLog.Status = LK_Success_Fail_Enum::Failed;
lk_AssetSoldDiscardLog.URL = lk_OutwardIntegration.API_URL;
lk_AssetSoldDiscardLog.insert();
Error(xppObject.parmSyncRemarks());
}
else
{
lk_AssetSoldDiscardLog.APIName = lk_OutwardIntegration.APIName;
lk_AssetSoldDiscardLog.AssetId = ledgerJournalTrans.accountDisplay();
lk_AssetSoldDiscardLog.AssetSaleId = xppObject.parmAssetSaleID();
lk_AssetSoldDiscardLog.RequestedPayload = requestJson;
lk_AssetSoldDiscardLog.ResponsePayload = responseJson;
lk_AssetSoldDiscardLog.AssetCode = xppObject.parmAssetCode();
lk_AssetSoldDiscardLog.ErrorLog = xppObject.parmSyncRemarks();
lk_AssetSoldDiscardLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_AssetSoldDiscardLog.Status = LK_Success_Fail_Enum::Success;
lk_AssetSoldDiscardLog.URL = lk_OutwardIntegration.API_URL;
lk_AssetSoldDiscardLog.insert();
if(ledgerJournalTable.RecId)
{
ttsbegin;
ledgerJournalTable.LK_ToBeSyncInFAMS = NoYes::No;
ledgerJournalTable.doUpdate();
ttscommit;
}
info(xppObject.parmSyncRemarks());
}
}
catch (webException)
{
responseStream = webException.Response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
// Insert error log into the table
lk_AssetSoldDiscardLog.AssetId = ledgerJournalTrans.accountDisplay();
lk_AssetSoldDiscardLog.RequestedPayload = requestJson;
lk_AssetSoldDiscardLog.ResponsePayload = responseJson;
lk_AssetSoldDiscardLog.ErrorLog = webException.Message;
lk_AssetSoldDiscardLog.APIName = "@LK_Label:LK_FamsAssetSoldDiscard";
lk_AssetSoldDiscardLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_AssetSoldDiscardLog.Status = LK_Success_Fail_Enum::Failed;
lk_AssetSoldDiscardLog.URL = lk_OutwardIntegration.API_URL;
lk_AssetSoldDiscardLog.insert();
}
requestStream.Close();
streamReader.Close();
responseStream.Close();
response.Close();
}
}
}
----------------------------------------------------------------------------------------------------------------------------
Branch integration
/// <summary>
/// This class <c>LK_FAMS_BranchMasterIntegration</c> is Used for FAMS Bank Master Integration and support class for the <c>LK_FAMS_BranchMasterIntegration</c> class.
/// </summary>
/// <remarks>
/// This class is only used from the FAMS Bank Master Integration.
/// </remarks>
class LK_FAMS_BranchMasterIntegration
{
#LK_IntegrationConstant
/// <summary>
/// This Method is used to retrive the Access Token to establish connection between Branch Master Integration
/// </summary>
/// <param name = "lk_OutwardIntegration">It contains Setup related to LK outbound integration</param>
/// <returns>Access Token</returns>
public str getToken(LK_OutwardIntegration lk_OutwardIntegration)
{
str url;
str jsonString, tokenstr;
System.Net.HttpWebRequest request;
System.Net.HttpWebResponse response;
System.IO.Stream dataStream;
System.IO.StreamReader streamRead;
System.Net.ServicePoint servicePoint;
CLRObject clrObj;
System.Text.Encoding utf8;
Map serialMap;
System.Byte[] byteArrayBody;
str token;
MapEnumerator mapEnumerator;
container tokenContainer, tokenContainer1;
int i;
int intOffset = 0;
System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection();
new InteropPermission(InteropKind::ClrInterop).assert();
str byteStr = strfmt('{ \"%1\": \"%2\", \"%3\": \"%4\"}', "@LK_Label:LKusername", lk_OutwardIntegration.Merchant_Key, "@LK_Label:LKpassword", lk_OutwardIntegration.Merchant_Pass);
headers = new System.Net.WebHeaderCollection();
url = lk_OutwardIntegration.AuthorizationUrl;
clrObj = System.Net.WebRequest::Create(url);
request = clrObj;
request.set_Method("@LK_Label:Post");
request.set_KeepAlive(true);
request.Accept = #ContentType;
utf8 = System.Text.Encoding::get_UTF8();
byteArrayBody = utf8.GetBytes(byteStr);
request.set_Headers(headers);
request.ContentType = #ContentType;
var stream = request.GetRequestStream();
if (stream)
{
stream.Write(byteArrayBody, intOffset, byteArrayBody.Length);
}
servicePoint = request.get_ServicePoint();
System.Net.ServicePointManager::set_Expect100Continue(false);
System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);
response = request.GetResponse();
dataStream = response.GetResponseStream();
streamRead = new System.IO.StreamReader(dataStream);
jsonString = streamRead.ReadToEnd();
serialMap = RetailCommonWebAPI::getMapFromJsonString(jsonString);
//start
mapEnumerator = serialMap.getEnumerator();
while (mapEnumerator.moveNext())
{
switch (mapEnumerator.currentKey())
{
case "@LK_Label:AccessToken":
tokenContainer = mapEnumerator.currentValue();
for (i=1; i<= conLen(tokenContainer);i++)
{
tokenContainer1 = conPeek(tokenContainer,i);
tokenstr = conPeek(tokenContainer1,1);
}
break;
}
}
dataStream.Close();
response.Close();
token = tokenstr;
return token;
}
/// <summary>
/// This method is used to Create Branch Master API
/// </summary>
/// <param name = "_assetLocationId">It retrive the Data from D 365 based on Asset Location id</param>
public void branchMasterCreateAPI(AssetLocationId _assetLocationId)
{
str destinationUrl;
str requestJson, responseJson;
System.Net.HttpWebRequest request;
System.Net.HttpWebResponse response = new System.Net.HttpWebResponse();
System.Byte[] bytes;
System.Text.Encoding utf8;
System.IO.Stream requestStream, responseStream;
System.IO.StreamReader streamReader;
System.Net.WebException webException;
System.Net.WebHeaderCollection httpHeader;
AssetLocation assetLocation;
CompanyInfo companyInfo;
LogisticsPostalAddress logisticsPostalAdderess;
LK_OutwardIntegration lk_OutwardIntegration;
LK_FAMS_BranchMaster_Log lk_FAMS_BranchMaster_Log;
str token;
str companyName, companyLocation;
companyInfo = CompanyInfo::find();
assetLocation = AssetLocation::find(_assetLocationId, true);
select firstonly Street,ZipCode,City,State from logisticsPostalAdderess
where logisticsPostalAdderess.Location == assetLocation.LogisticsLocation;
if (curExt() == "@LK_Label:LensKartIndiaLegalEntity")
{
companyLocation = "@LK_Label:LensKartSymbol" + assetLocation.Location;
companyName = companyLocation + '-' + assetLocation.Name;
}
if (curExt() == "@LK_Label:DealsKartLegalEntity")
{
companyLocation = "@LK_Label:DealsKartSymbol" + assetLocation.Location;
companyName = companyLocation + '-' + assetLocation.Name;
}
requestJson = strfmt('{ \"%1\": \"%2\", \"%3\": \"%4\", \"%5\": \"%6\", \"%7\": \"%8\", \"%9\": \"%10\", \"%11\": \"%12\", \"%13\": \"%14\", \"%15\": \"%16\",'+
'\"%17\": \"%18\"}',
#ParentCompanyName, companyInfo.Name,
#CompanyCode, companyLocation,
#CompanyName, companyName,
#Phone, #SamplePhone,
#Address1, logisticsPostalAdderess.Street,
#PinCode, logisticsPostalAdderess.ZipCode,
#CityName, logisticsPostalAdderess.City,
#StateName, logisticsPostalAdderess.State,
#CountryName, #CountryIN);
try
{
select firstonly lk_OutwardIntegration
where lk_OutwardIntegration.APIName == "@LK_Label:BranchCreation";
token = this.getToken(lk_OutwardIntegration);
new InteropPermission(InteropKind::ClrInterop).assert();
httpHeader = new System.Net.WebHeaderCollection();
destinationUrl = lk_OutwardIntegration.API_URL;
request = System.Net.WebRequest::Create(destinationUrl);
utf8 = System.Text.Encoding::get_UTF8();
bytes = utf8.GetBytes(requestJson);
httpHeader.Add("@LK_Label:Authorization", "@LK_Label:LK_Bearer" + ' '+ token);
httpHeader.Add("@LK_Label:ApplicationId",lk_OutwardIntegration.API_Id);
request.set_Method("@LK_Label:Post");
request.set_Headers(httpHeader);
request.set_ContentType(#ContentType);
request.set_Accept(#ContentType);
request.set_KeepAlive(true);
request.set_ContentLength(bytes.get_Length());
requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.get_Length());
response = request.GetResponse();
responseStream = response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
//info(responseJson);
LK_FAMS_BranchMasterIntegrationResponseContract xppObject = new LK_FAMS_BranchMasterIntegrationResponseContract();
xppObject = FormJsonSerializer::deserializeObject(
classNum(LK_FAMS_BranchMasterIntegrationResponseContract),
responseJson);
lk_FAMS_BranchMaster_Log.clear();
if (xppObject.parmSyncStatus() == 0)
{
lk_FAMS_BranchMaster_Log.CompanyID = int2Str(xppObject.parmCompanyId());
lk_FAMS_BranchMaster_Log.BranchName = xppObject.parmCompanyName();
lk_FAMS_BranchMaster_Log.RequestedPayload = requestJson;
lk_FAMS_BranchMaster_Log.ResponsePayload = responseJson;
lk_FAMS_BranchMaster_Log.BranchCode = xppObject.parmCompanyCode();
lk_FAMS_BranchMaster_Log.ErrorLog = xppObject.parmSyncRemarks();
lk_FAMS_BranchMaster_Log.APIName = lk_OutwardIntegration.APIName;
lk_FAMS_BranchMaster_Log.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_BranchMaster_Log.Status = LK_Success_Fail_Enum::Failed;
lk_FAMS_BranchMaster_Log.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_BranchMaster_Log.insert();
info(xppObject.parmSyncRemarks());
}
else
{
lk_FAMS_BranchMaster_Log.CompanyID = int2Str(xppObject.parmCompanyId());
lk_FAMS_BranchMaster_Log.BranchName = xppObject.parmCompanyName();
lk_FAMS_BranchMaster_Log.RequestedPayload = requestJson;
lk_FAMS_BranchMaster_Log.ResponsePayload = responseJson;
lk_FAMS_BranchMaster_Log.BranchCode = xppObject.parmCompanyCode();
lk_FAMS_BranchMaster_Log.ErrorLog = xppObject.parmSyncRemarks();
lk_FAMS_BranchMaster_Log.APIName = lk_OutwardIntegration.APIName;
lk_FAMS_BranchMaster_Log.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_BranchMaster_Log.Status = LK_Success_Fail_Enum::Success;
lk_FAMS_BranchMaster_Log.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_BranchMaster_Log.insert();
info(xppObject.parmSyncRemarks());
if (assetLocation.RecId)
{
ttsbegin;
assetLocation.LK_CompanyID = int2Str(xppObject.parmCompanyId());
assetLocation.doUpdate();
ttscommit;
}
}
}
catch (webException)
{
// Log detailed error info for debugging
responseStream = webException.Response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
// Insert error log into the table
lk_FAMS_BranchMaster_Log.RequestedPayload = requestJson;
lk_FAMS_BranchMaster_Log.ResponsePayload = responseJson;
lk_FAMS_BranchMaster_Log.ErrorLog = webException.Message;
lk_FAMS_BranchMaster_Log.APIName = "@LK_Label:BranchCreation";
lk_FAMS_BranchMaster_Log.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_BranchMaster_Log.Status = LK_Success_Fail_Enum::Failed;
lk_FAMS_BranchMaster_Log.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_BranchMaster_Log.insert();
}
requestStream.Close();
streamReader.Close();
responseStream.Close();
response.Close();
}
/// <summary>
/// This method is used for updating the Branch master data
/// </summary>
/// <param name = "_assetLocationId">AssetLocation id </param>
public void branchMasterUpdateAPI(AssetLocationId _assetLocationId)
{
str destinationUrl;
str requestJson, responseJson;
System.Net.HttpWebRequest request;
System.Net.HttpWebResponse response = new System.Net.HttpWebResponse();
System.Byte[] bytes;
System.Text.Encoding utf8;
System.IO.Stream requestStream, responseStream;
System.IO.StreamReader streamReader;
System.Net.WebException webException;
System.Net.WebHeaderCollection httpHeader;
AssetLocation assetLocation;
CompanyInfo companyInfo;
LogisticsPostalAddress logisticsPostalAdderess;
LK_OutwardIntegration lk_OutwardIntegration;
LK_FAMS_BranchMaster_Log lk_FAMS_BranchMaster_Log;
str token;
str companyName,companyLocation;
companyInfo = CompanyInfo::find();
assetLocation = AssetLocation::find(_assetLocationId, true);
select firstonly Street,ZipCode,City,State from logisticsPostalAdderess
where logisticsPostalAdderess.Location == assetLocation.LogisticsLocation;
if(curExt() == "@LK_Label:LensKartIndiaLegalEntity")
{
companyLocation = "@LK_Label:LensKartSymbol" + assetLocation.Location;
companyName = companyLocation + '-' + assetLocation.Name;
}
if(curExt() == "@LK_Label:DealsKartLegalEntity")
{
companyLocation = "@LK_Label:DealsKartSymbol" + assetLocation.Location;
companyName = companyLocation + '-' + assetLocation.Name;
}
requestJson = strfmt('{ \"%1\": \%2\, \"%3\": \"%4\", \"%5\": \"%6\", \"%7\": \"%8\", \"%9\": \"%10\", \"%11\": \"%12\", \"%13\": \"%14\", \"%15\": \"%16\",'+
'\"%17\": \"%18\", \"%19\": \"%20\"}',
#CompanyId, str2Int(assetLocation.LK_CompanyID),
#ParentCompanyName, companyInfo.Name,
#CompanyCode, companyLocation,
#CompanyName, companyName,
#Phone, #SamplePhone,
#Address1, logisticsPostalAdderess.Street,
#PinCode, logisticsPostalAdderess.ZipCode,
#CityName, logisticsPostalAdderess.City,
#StateName, logisticsPostalAdderess.State,
#CountryName , #CountryIN);
try
{
select firstonly lk_OutwardIntegration
where lk_OutwardIntegration.APIName == "@LK_Label:BranchUpdation";
token = this.getToken(lk_OutwardIntegration);
new InteropPermission(InteropKind::ClrInterop).assert();
httpHeader = new System.Net.WebHeaderCollection();
destinationUrl = lk_OutwardIntegration.API_URL;
request = System.Net.WebRequest::Create(destinationUrl);
utf8 = System.Text.Encoding::get_UTF8();
bytes = utf8.GetBytes(requestJson);
httpHeader.Add("@LK_Label:Authorization", "@LK_Label:LK_Bearer" + ' '+ token);
httpHeader.Add("@LK_Label:ApplicationId",lk_OutwardIntegration.API_Id);
request.set_Method("@LK_Label:Post");
request.set_Headers(httpHeader);
request.set_ContentType(#ContentType);
request.set_Accept(#ContentType);
request.set_KeepAlive(true);
request.set_ContentLength(bytes.get_Length());
requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.get_Length());
response = request.GetResponse();
responseStream = response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
LK_FAMS_BranchMasterIntegrationResponseContract xppObject = new LK_FAMS_BranchMasterIntegrationResponseContract();
xppObject = FormJsonSerializer::deserializeObject(
classNum(LK_FAMS_BranchMasterIntegrationResponseContract),
responseJson);
lk_FAMS_BranchMaster_Log.clear();
if (xppObject.parmSyncStatus() == 0)
{
lk_FAMS_BranchMaster_Log.CompanyID = int2Str(xppObject.parmCompanyId());
lk_FAMS_BranchMaster_Log.BranchName = xppObject.parmCompanyName();
lk_FAMS_BranchMaster_Log.RequestedPayload = requestJson;
lk_FAMS_BranchMaster_Log.ResponsePayload = responseJson;
lk_FAMS_BranchMaster_Log.BranchCode = xppObject.parmCompanyCode();
lk_FAMS_BranchMaster_Log.ErrorLog = xppObject.parmSyncRemarks();
lk_FAMS_BranchMaster_Log.APIName = lk_OutwardIntegration.APIName;
lk_FAMS_BranchMaster_Log.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_BranchMaster_Log.Status = LK_Success_Fail_Enum::Failed;
lk_FAMS_BranchMaster_Log.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_BranchMaster_Log.insert();
info(xppObject.parmSyncRemarks());
}
else
{
lk_FAMS_BranchMaster_Log.CompanyID = int2Str(xppObject.parmCompanyId());
lk_FAMS_BranchMaster_Log.BranchName = xppObject.parmCompanyName();
lk_FAMS_BranchMaster_Log.RequestedPayload = requestJson;
lk_FAMS_BranchMaster_Log.ResponsePayload = responseJson;
lk_FAMS_BranchMaster_Log.BranchCode = xppObject.parmCompanyCode();
lk_FAMS_BranchMaster_Log.ErrorLog = xppObject.parmSyncRemarks();
lk_FAMS_BranchMaster_Log.APIName = lk_OutwardIntegration.APIName;
lk_FAMS_BranchMaster_Log.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_BranchMaster_Log.Status = LK_Success_Fail_Enum::Success;
lk_FAMS_BranchMaster_Log.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_BranchMaster_Log.insert();
info(xppObject.parmSyncRemarks());
}
}
catch (webException)
{
// Log detailed error info for debugging
responseStream = webException.Response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
// Insert error log into the table
lk_FAMS_BranchMaster_Log.RequestedPayload = requestJson;
lk_FAMS_BranchMaster_Log.ResponsePayload = responseJson;
lk_FAMS_BranchMaster_Log.ErrorLog = webException.Message;
lk_FAMS_BranchMaster_Log.APIName = "@LK_Label:BranchUpdation";
lk_FAMS_BranchMaster_Log.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_BranchMaster_Log.Status = LK_Success_Fail_Enum::Failed;
lk_FAMS_BranchMaster_Log.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_BranchMaster_Log.insert();
}
requestStream.Close();
streamReader.Close();
responseStream.Close();
response.Close();
}
}
----------------------------------------------------------------------------------------------------------------------------
Asset master integration
/// <summary>
/// This class <c>LK_FAMSAssetMasterIntegrationService</c> is Used for FAMS Asset Master Integration and support class for the <c>LK_FAMSAssetMasterIntegrationService</c> class.
/// </summary>
/// <remarks>
/// This class is only used from the FAMS Asset Master Integration.
/// </remarks>
class LK_FAMSAssetMasterIntegrationService extends SysOperationServiceBase
{
#LK_IntegrationConstant
/// <summary>
/// This is method is used to process
/// </summary>
public void process()
{
AssetTable assetTable;
AssetParameters assetParameters;
CLRObject sysException;
str messages;
select firstonly LK_FromDateAssetMasterIntegration, LK_ModifiedFromDateAssetMasterEditIntegration from assetParameters;
if (curExt() == "@LK_Label:LensKartIndiaLegalEntity" || curExt() == "@LK_Label:DealsKartLegalEntity")
{
while select assetTable
where assetTable.CreatedDateTime >= assetParameters.LK_FromDateAssetMasterIntegration
|| assetTable.ModifiedDateTime >= assetParameters.LK_ModifiedFromDateAssetMasterEditIntegration
{
try
{
if (this.validateAssets(assetTable))
{
if (assetTable.LK_FAMSAssetCode && assetTable.LK_ToBeSyncInFAMS == NoYes::Yes)
{
this.AssetEditAPI(assetTable.AssetId);
}
else if (!assetTable.LK_FAMSAssetCode)
{
this.assetMasterAPI(assetTable.AssetId);
}
}
}
catch
{
sysException = CLRInterop::getLastException();
while(sysException)
{
messages += sysException.get_Message();
sysException = sysException.get_innerexception();
}
continue;
}
}
}
}
/// <summary>
/// This method is used to validate Assets
/// </summary>
/// <param name = "_assetTable">AssetTable</param>
/// <returns>Boolean value if validate success</returns>
public boolean validateAssets(AssetTable _assetTable)
{
AssetBook assetBook;
assetBook = _assetTable.assetBookCurrent();
AssetParameters assetParameters;
boolean ok = true;
select firstonly LK_ValidationSkipForFAMS, RecId from assetParameters
where assetParameters.LK_ValidationSkipForFAMS == NoYes::No;
if (assetParameters.RecId && assetBook.Status == AssetStatus::Open)
{
if (ok && !AssetLocation::find(_assetTable.Location).Name)
{
ok = checkFailed(strFmt("@LK_Label:LK_Field", fieldPName(AssetLocation, Name), _assetTable.AssetId));
}
if (ok && !_assetTable.AssetGroup)
{
ok = checkFailed(strFmt("@LK_Label:LK_Field", fieldPName(AssetTable, AssetGroup),_assetTable.AssetId));
}
if (ok && !assetBook.AcquisitionPrice)
{
ok = checkFailed(strFmt("@LK_Label:LK_Field",fieldPName(AssetBook, AcquisitionPrice), _assetTable.AssetId));
}
if (ok && !_assetTable.SerialNum)
{
ok = checkFailed(strFmt("@LK_Label:LK_Field",fieldPName(AssetTable, SerialNum), _assetTable.AssetId));
}
}
return Ok;
}
/// <summary>
/// This Method is used to retrive the Access Token to establish connection between Asset Master Integration
/// </summary>
/// <param name = "lk_OutwardIntegration">It contains Setup related to LK outbound integration</param>
/// <returns>Access Token</returns>
public str getToken(LK_OutwardIntegration lk_OutwardIntegration)
{
str url;
str jsonString, tokenstr;
System.Net.HttpWebRequest request;
System.Net.HttpWebResponse response;
System.IO.Stream dataStream;
System.IO.StreamReader streamRead;
System.Net.ServicePoint servicePoint;
CLRObject clrObj;
System.Text.Encoding utf8;
Map serialMap;
System.Byte[] byteArrayBody;
str token;
MapEnumerator mapEnumerator;
container tokenContainer, tokenContainer1;
int i;
int intOffset = 0;
System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection();
new InteropPermission(InteropKind::ClrInterop).assert();
str byteStr = strfmt('{ \"%1\": \"%2\", \"%3\": \"%4\"}', "@LK_Label:LKusername", lk_OutwardIntegration.Merchant_Key, "@LK_Label:LKpassword", lk_OutwardIntegration.Merchant_Pass);
headers = new System.Net.WebHeaderCollection();
url = lk_OutwardIntegration.AuthorizationUrl;
clrObj = System.Net.WebRequest::Create(url);
request = clrObj;
request.set_Method("@LK_Label:Post");
request.set_KeepAlive(true);
request.Accept = #ContentType;
utf8 = System.Text.Encoding::get_UTF8();
byteArrayBody = utf8.GetBytes(byteStr);
request.set_Headers(headers);
request.ContentType = #ContentType;
var stream = request.GetRequestStream();
if (stream)
{
stream.Write(byteArrayBody, intOffset, byteArrayBody.Length);
}
servicePoint = request.get_ServicePoint();
System.Net.ServicePointManager::set_Expect100Continue(false);
System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);
response = request.GetResponse();
dataStream = response.GetResponseStream();
streamRead = new System.IO.StreamReader(dataStream);
jsonString = streamRead.ReadToEnd();
serialMap = RetailCommonWebAPI::getMapFromJsonString(jsonString);
//start
mapEnumerator = serialMap.getEnumerator();
while (mapEnumerator.moveNext())
{
switch (mapEnumerator.currentKey())
{
case "@LK_Label:AccessToken":
tokenContainer = mapEnumerator.currentValue();
for (i=1; i<= conLen(tokenContainer);i++)
{
tokenContainer1 = conPeek(tokenContainer,i);
tokenstr = conPeek(tokenContainer1,1);
}
break;
}
}
dataStream.Close();
response.Close();
token = tokenstr;
return token;
}
/// <summary>
/// This Method is used for Asset Master Export
/// </summary>
/// <param name = "_assetId">Asset</param>
public void assetMasterAPI(AssetId _assetId)
{
str destinationUrl;
str requestJson, responseJson;
System.Net.HttpWebRequest request;
System.Net.HttpWebResponse response = new System.Net.HttpWebResponse();
System.Byte[] bytes;
System.Text.Encoding utf8;
System.IO.Stream requestStream, responseStream;
System.IO.StreamReader streamReader;
System.Net.WebException webException;
System.Net.WebHeaderCollection httpHeader;
AssetTable assetTable;
AssetBook assetBook;
LK_OutwardIntegration lk_OutwardIntegration;
LK_FAMS_AssetMaster_Log lk_FAMS_AssetMaster_ErrorLog;
PurchTable purchTable;
VendInvoiceJour vendInvoiceJour;
str token;
str companyName,companyLocation;
str assetCategory2;
assetTable = AssetTable::find(_assetId, true);
assetBook = assetTable.assetBookCurrent();
AssetLocation assetLocationLocal = AssetLocation::find(assetTable.Location);
select firstonly AccountingDate from purchTable
where purchTable.PurchId == assetBook.PurchId;
if ((assetBook.BookId == "@LK_Label:OffEqpm") || (assetBook.BookId == "@LK_Label:StrOfEqp"))
{
assetCategory2 = assetBook.BookId;
}
select firstonly InvoiceDate from vendInvoiceJour
where vendInvoiceJour.InvoiceId == assetBook.VendInvoiceId;
if(assetBook.Status == AssetStatus::Open)
{
if(curExt() == "@LK_Label:LensKartIndiaLegalEntity")
{
companyLocation = "@LK_Label:LensKartSymbol" + assetTable.Location;
companyName = companyLocation + '-' + assetLocationLocal.Name;
}
if(curExt() == "@LK_Label:DealsKartLegalEntity")
{
companyLocation = "@LK_Label:DealsKartSymbol" + assetTable.Location;
companyName = companyLocation + '-' + assetLocationLocal.Name;
}
requestJson = strfmt('[{ \"%1\": \"%2\", \"%3\": \"%4\", \"%5\": \"%6\", \"%7\": \"%8\", \"%9\": \"%10\", \"%11\": \"%12\", \"%13\": \"%14\", \"%15\": \"%16\",'+
'\"%17\": \"%18\", \"%19\" : \"%20\", \"%21\": \"%22\", \"%23\": \"%24\", \"%25\": \"%26\", \"%27\": \"%28\", \"%29\": \"%30\", \"%31\": \"%32\",'+
' \"%33\": \"%34\" , \"%35\": \"%36\", \"%37\": \"%38\", \"%39\": \"%40\", \"%41\": \"%42\", \"%43\": \"%44\", \"%45\": \"%46\", \"%47\": \"%48\", \"%49\": \"%50\"}]',
#AssetAcquireType, "@LK_Label:Purchased",
#BranchName, companyName,
#InStore, enum2Str(NoYes::Yes),
#IsMultipleEntries, enum2Str(NoYes::No),
#Quantity, real2int(assetTable.Quantity),
#PhysicalVerification, enum2Str(NoYes::Yes),
#AssetAcquireSubType, "@LK_Label:Independent",
#GroupQty, 1,
#DepartmentName, assetTable.Department,
#AssetType, "@LK_Label:Owned",
#PurchaseDate, assetBook.AcquisitionDate,
#AssetDesc, assetTable.Name,
#IsClosingBalanceYearAsset, enum2Str(NoYes::No),
#AssetCost, assetBook.AcquisitionPrice,
#PurchaseOrderNo, strReplace(assetBook.PurchId, '\\', '\\\\'),
#VendorCode, assetBook.VendAccount,
#AssetCategoryLevel1, assetTable.AssetGroup,
#AssetCategoryLevel2, assetCategory2,
#VendInvoiceNo, assetBook.VendInvoiceId,
#VendorName, assetBook.vendName(),
#PurchaseOrderDate, purchTable.AccountingDate,
#Remarks, assetTable.LK_TaggingStatus,
#VendorInvoiceDate, vendInvoiceJour.InvoiceDate,
#ItemCode, _assetId,
#MachineTagNo, assetTable.SerialNum
);
try
{
select firstonly lk_OutwardIntegration
where lk_OutwardIntegration.APIName == "@LK_Label:FixedAssetAPI";
token = this.getToken(lk_OutwardIntegration);
new InteropPermission(InteropKind::ClrInterop).assert();
httpHeader = new System.Net.WebHeaderCollection();
destinationUrl = lk_OutwardIntegration.API_URL;
request = System.Net.WebRequest::Create(destinationUrl);
utf8 = System.Text.Encoding::get_UTF8();
bytes = utf8.GetBytes(requestJson);
httpHeader.Add("@LK_Label:Authorization", "@LK_Label:LK_Bearer" + ' ' + token);
httpHeader.Add("@LK_Label:ApplicationId", lk_OutwardIntegration.API_Id);
request.set_Method("@LK_Label:Post");
request.set_Headers(httpHeader);
request.set_ContentType(#ContentType);
request.set_Accept(#ContentType);
request.set_KeepAlive(true);
request.set_ContentLength(bytes.get_Length());
requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.get_Length());
response = request.GetResponse();
responseStream = response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
LK_FAMS_AssetMasterIntegrationResponse_Contract xppObject = new LK_FAMS_AssetMasterIntegrationResponse_Contract();
xppObject = FormJsonSerializer::deserializeObject(
classNum(LK_FAMS_AssetMasterIntegrationResponse_Contract),
responseJson);
lk_FAMS_AssetMaster_ErrorLog.clear();
if(xppObject.parmSyncStatus() == 0)
{
lk_FAMS_AssetMaster_ErrorLog.AssetId = xppObject.parmAssetID();
lk_FAMS_AssetMaster_ErrorLog.RequestedPayload = requestJson;
lk_FAMS_AssetMaster_ErrorLog.ResponsePayload = responseJson;
lk_FAMS_AssetMaster_ErrorLog.AssetCode = xppObject.parmAssetCode();
lk_FAMS_AssetMaster_ErrorLog.ErrorLog = xppObject.parmSyncRemarks();
lk_FAMS_AssetMaster_ErrorLog.APIName = lk_OutwardIntegration.APIName;
lk_FAMS_AssetMaster_ErrorLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_AssetMaster_ErrorLog.Status = LK_Success_Fail_Enum::Failed;
lk_FAMS_AssetMaster_ErrorLog.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_AssetMaster_ErrorLog.insert();
Error(strFmt("@LK_Label:LK_AssetId",xppObject.parmSyncRemarks(), assetTable.AssetId));
}
else
{
lk_FAMS_AssetMaster_ErrorLog.AssetId = xppObject.parmAssetID();
lk_FAMS_AssetMaster_ErrorLog.RequestedPayload = requestJson;
lk_FAMS_AssetMaster_ErrorLog.ResponsePayload = responseJson;
lk_FAMS_AssetMaster_ErrorLog.AssetCode = xppObject.parmAssetCode();
lk_FAMS_AssetMaster_ErrorLog.ErrorLog = xppObject.parmSyncRemarks();
lk_FAMS_AssetMaster_ErrorLog.APIName = lk_OutwardIntegration.APIName;
lk_FAMS_AssetMaster_ErrorLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_AssetMaster_ErrorLog.Status = LK_Success_Fail_Enum::Success;
lk_FAMS_AssetMaster_ErrorLog.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_AssetMaster_ErrorLog.insert();
if(assetTable.RecId)
{
ttsbegin;
assetTable.LK_FAMSAssetCode = xppObject.parmAssetCode();
assetTable.doUpdate();
ttscommit;
}
info(strFmt("@LK_Label:LK_AssetId",xppObject.parmSyncRemarks(), assetTable.AssetId));
}
}
catch (webException)
{
responseStream = webException.Response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
// Insert error log into the table
lk_FAMS_AssetMaster_ErrorLog.AssetId = _assetId;
lk_FAMS_AssetMaster_ErrorLog.RequestedPayload = requestJson;
lk_FAMS_AssetMaster_ErrorLog.ResponsePayload = responseJson;
lk_FAMS_AssetMaster_ErrorLog.ErrorLog = webException.Message;
lk_FAMS_AssetMaster_ErrorLog.APIName = "@LK_Label:FixedAssetAPI";
lk_FAMS_AssetMaster_ErrorLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_AssetMaster_ErrorLog.Status = LK_Success_Fail_Enum::Failed;
lk_FAMS_AssetMaster_ErrorLog.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_AssetMaster_ErrorLog.insert();
}
requestStream.Close();
streamReader.Close();
responseStream.Close();
response.Close();
}
}
/// <summary>
/// This method is to update Asset master information
/// </summary>
/// <param name = "assetId">AssetId</param>
public void AssetEditAPI(AssetId assetId)
{
str destinationUrl;
str requestJson, responseJson;
System.Net.HttpWebRequest request;
System.Net.HttpWebResponse response = new System.Net.HttpWebResponse();
System.Byte[] bytes;
System.Text.Encoding utf8;
System.IO.Stream requestStream, responseStream;
System.IO.StreamReader streamReader;
System.Net.WebException webException;
System.Net.WebHeaderCollection httpHeader;
AssetTable assetTable;
AssetBook assetBook;
AssetLocation assetLocation;
LK_OutwardIntegration lk_OutwardIntegration;
LK_FAMS_AssetMaster_Log lk_FAMS_AssetMaster_ErrorLog;
str token;
str companyName,companyLocation;
assetTable = AssetTable::find(assetId, true);
assetBook = assetTable.assetBookCurrent();
assetLocation = AssetLocation::find(assetTable.Location);
#OCCRetryCount
#define.AssetSerialNo('AssetSerialNumber');
if(curExt() == "@LK_Label:LensKartIndiaLegalEntity")
{
companyLocation = "@LK_Label:LensKartSymbol" + assetTable.Location;
companyName = companyLocation + '-' + assetLocation.Name;
}
if(curExt() == "@LK_Label:DealsKartLegalEntity")
{
companyLocation = "@LK_Label:DealsKartSymbol" + assetTable.Location;
companyName = companyLocation + '-' + assetLocation.Name;
}
requestJson = strfmt('{ \"%1\": \"%2\", \"%3\": \"%4\", \"%5\": \"%6\", \"%7\": \"%8\", \"%9\": \"%10\", \"%11\": \"%12\", \"%13\": \"%14\", \"%15\": \"%16\",'+
'\"%17\": \"%18\", \"%19\" : \"%20\", \"%21\": \"%22\", \"%23\": \"%24\", \"%25\": \"%26\", \"%27\": \"%28\", \"%29\": \"%30\", \"%31\": \"%32\", \"%33\": \"%34\", \"%35\": \"%36\"}',
#AssetDesc, assetTable.Name,
#AssetCost, assetBook.AcquisitionPrice,
#DatePutUse, assetBook.DepreciationStartDate,
#SAPAssetCode, assetTable.AssetId,
#SAPAssetClass, assetTable.MajorType,
#AssetMakeModel, assetTable.Make,
#AssetSerialNo, assetTable.SerialNum,
#FamsAssetCode, strReplace(assetTable.LK_FAMSAssetCode, '\\', '\\\\'),
#BranchCode, companyLocation,
#Quantity, any2Int(1),
#AssetCustodian, '',
#Segment, '',
#PoQty, any2Int(1),
#CostCenter, '',
#Location, '',
#Vendor, '',
#Profitcenter, '',
#MachineTagNo, assetTable.SerialNum
);
try
{
select firstonly lk_OutwardIntegration
where lk_OutwardIntegration.APIName == "@LK_Label:UpdateAssetApi";
token = this.getToken(lk_OutwardIntegration);
new InteropPermission(InteropKind::ClrInterop).assert();
httpHeader = new System.Net.WebHeaderCollection();
destinationUrl = lk_OutwardIntegration.API_URL;
request = System.Net.WebRequest::Create(destinationUrl);
utf8 = System.Text.Encoding::get_UTF8();
bytes = utf8.GetBytes(requestJson);
httpHeader.Add("@LK_Label:Authorization", "@LK_Label:LK_Bearer" + ' '+ token);
httpHeader.Add("@LK_Label:ApplicationId",lk_OutwardIntegration.API_Id);
request.set_Method("@LK_Label:Post");
request.set_Headers(httpHeader);
request.set_ContentType(#ContentType);
request.set_Accept(#ContentType);
request.set_KeepAlive(true);
request.set_ContentLength(bytes.get_Length());
requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.get_Length());
response = request.GetResponse();
responseStream = response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
LK_FAMS_AssetUpdateIntegrationReponseContract xppObject = new LK_FAMS_AssetUpdateIntegrationReponseContract();
xppObject = FormJsonSerializer::deserializeObject(
classNum(LK_FAMS_AssetUpdateIntegrationReponseContract),
responseJson);
lk_FAMS_AssetMaster_ErrorLog.clear();
if (xppObject.parmMessage() == "@LK_Label:FAILED")
{
lk_FAMS_AssetMaster_ErrorLog.AssetId = xppObject.parmAssetId();
lk_FAMS_AssetMaster_ErrorLog.RequestedPayload = requestJson;
lk_FAMS_AssetMaster_ErrorLog.ResponsePayload = responseJson;
lk_FAMS_AssetMaster_ErrorLog.AssetCode = xppObject.parmFinalAssetCode();
lk_FAMS_AssetMaster_ErrorLog.ErrorLog = xppObject.parmValidationMessage();
lk_FAMS_AssetMaster_ErrorLog.APIName = lk_OutwardIntegration.APIName;
lk_FAMS_AssetMaster_ErrorLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_AssetMaster_ErrorLog.Status = LK_Success_Fail_Enum::Failed;
lk_FAMS_AssetMaster_ErrorLog.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_AssetMaster_ErrorLog.insert();
Error(strFmt("@LK_Label:LK_AssetId",responseJson, assetTable.AssetId));
}
else
{
lk_FAMS_AssetMaster_ErrorLog.AssetId = xppObject.parmAssetId();
lk_FAMS_AssetMaster_ErrorLog.RequestedPayload = requestJson;
lk_FAMS_AssetMaster_ErrorLog.ResponsePayload = responseJson;
lk_FAMS_AssetMaster_ErrorLog.AssetCode = xppObject.parmFinalAssetCode();
lk_FAMS_AssetMaster_ErrorLog.ErrorLog = xppObject.parmValidationMessage();
lk_FAMS_AssetMaster_ErrorLog.APIName = lk_OutwardIntegration.APIName;
lk_FAMS_AssetMaster_ErrorLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_AssetMaster_ErrorLog.Status = LK_Success_Fail_Enum::Success;
lk_FAMS_AssetMaster_ErrorLog.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_AssetMaster_ErrorLog.insert();
if (assetTable.RecId)
{
ttsbegin;
assetTable.LK_ToBeSyncInFAMS = NoYes::No;
assetTable.doUpdate();
ttscommit;
}
info(strFmt("@LK_Label:LK_AssetId",responseJson, assetTable.AssetId));
}
}
catch (webException)
{
responseStream = webException.Response.GetResponseStream();
streamReader = new System.IO.StreamReader(responseStream);
responseJson = streamReader.ReadToEnd();
// Insert error log into the table
lk_FAMS_AssetMaster_ErrorLog.AssetId = assetId;
lk_FAMS_AssetMaster_ErrorLog.RequestedPayload = requestJson;
lk_FAMS_AssetMaster_ErrorLog.ResponsePayload = responseJson;
lk_FAMS_AssetMaster_ErrorLog.ErrorLog = webException.Message;
lk_FAMS_AssetMaster_ErrorLog.APIName = "@LK_Label:UpdateAssetApi";
lk_FAMS_AssetMaster_ErrorLog.FromDateTime = DateTimeUtil::getSystemDateTime();
lk_FAMS_AssetMaster_ErrorLog.Status = LK_Success_Fail_Enum::Failed;
lk_FAMS_AssetMaster_ErrorLog.URL = lk_OutwardIntegration.API_URL;
lk_FAMS_AssetMaster_ErrorLog.insert();
}
requestStream.Close();
streamReader.Close();
responseStream.Close();
response.Close();
}
}
----------------------------------------------------------------------------------------------------------------------------
This is a service class where process CSV file from Blob service:
/// <summary>
/// this is service class
/// </summary>
class LK_ProcessCSVFileFromBlobService
{
/// <summary>
/// this method is use to create cus
/// </summary>
public void processBlobFiles()
{
LK_BlobStorageSetting blobStorageSetting;
LK_ReadAndArchiveFileFromBlob readAndArchiveFileFromBlob;
LK_CustPaymProccess custPaymProccess;
LK_SalesOrderProcess salesOrderProcess;
readAndArchiveFileFromBlob = new LK_ReadAndArchiveFileFromBlob();
custPaymProccess = new LK_CustPaymProccess();
salesOrderProcess = new LK_SalesOrderProcess();
while select blobStorageSetting where blobStorageSetting.EnableProcess == NoYes::Yes
{
switch(blobStorageSetting.ProcessType)
{
case LK_ProcessType::CustPaym :
readAndArchiveFileFromBlob.readAndArchive(blobStorageSetting);
custPaymProccess.parmJournalName(blobStorageSetting.JournalName);
custPaymProccess.parmFeeId(blobStorageSetting.FeeId);
custPaymProccess.parmPaymMode(blobStorageSetting.PaymMode);
custPaymProccess.createPayment();
break;
case LK_ProcessType::EDCTransaction:
readAndArchiveFileFromBlob.readAndArchive(blobStorageSetting);
salesOrderProcess.createSalesOrder();
break;
}
}
}
}
--------------------------------------------------------------------------------------------
this class is used to process the csv file:
/// <summary>
/// this class is used to process the csv file
/// </summary>
class LK_CustPaymProccess
{
real lineNum;
real greaterAmount, greaterAmountRefund, currAmountDr, currAmountCr;
CustInvoiceId invoiceId;
LedgerJournalId journalNum;
PaymReference paymentReference;
LedgerJournalName ledgerjournalname;
LedgerJournalACType ledgerJournalACType;
LedgerJournalNameId journalName;
CustVendPaymFeeId feeId;
PaymMode paymMode;
Str1260 errorStr;
LK_TID_MIDMasterTable tidMidMasterTable;
boolean isSettleDe, isSettleCr;
#LK_IntegrationConstant //M Vinodkumar
/// <summary>
/// get or set Journal Name
/// </summary>
/// <param name = "_journalName">LedgerJournalName</param>
/// <returns>LedgerJournalName</returns>
public LedgerJournalNameId parmJournalName(LedgerJournalNameId _journalName = journalName)
{
journalName = _journalName;
return journalName;
}
/// <summary>
/// get or set fee id
/// </summary>
/// <param name = "_feeId">CustVendPaymFeeId</param>
/// <returns>CustVendPaymFeeId</returns>
public CustVendPaymFeeId parmFeeId(CustVendPaymFeeId _feeId = feeId)
{
feeId = _feeId;
return feeId;
}
/// <summary>
/// get or set PaymMode
/// </summary>
/// <param name = "_paymMode">PaymMode</param>
/// <returns>PaymMode</returns>
public PaymMode parmPaymMode(PaymMode _paymMode = paymMode)
{
paymMode = _paymMode;
return paymMode;
}
/// <summary>
/// this method is used to create the payment journal
/// </summary>
public void createPayment()
{
str reponseStr;
Counter i;
SysInfologEnumerator enumerator;
SysInfologMessageStruct msgStruct;
Exception exception;
LK_ProcessBlobFileTable processBlobFileTable, processBlobFileTable_upd;
LK_ProcessBlobFileHeader processBlobFileHeader;
LedgerJournalTable journalTable;
while select FileName, LegalEntityName from processBlobFileTable
group by FileName, LegalEntityName
where processBlobFileTable.IsProcessed == NoYes::No
{
try
{
ttsbegin;
changecompany(processBlobFileTable.LegalEntityName)
{
greaterAmount = 0;
greaterAmountRefund = 0;
currAmountDr = 0;
currAmountCr = 0;
journalTable = this.createPayJournal(processBlobFileTable);
}
update_recordset processBlobFileTable_upd setting IsProcessed = NoYes::Yes, HasError = NoYes::No
where processBlobFileTable_upd.FileName == processBlobFileTable.FileName;
update_recordset processBlobFileHeader setting Processed = NoYes::Yes, LedgerJournalId = journalTable.JournalNum, ProcessedDate = DateTimeUtil::getSystemDateTime()
where processBlobFileHeader.FileName == processBlobFileTable.FileName;
ttscommit;
}
catch
{
i = 0;
++i;
enumerator = SysInfologEnumerator::newData(infolog.cut(i));
while (enumerator.moveNext())
{
msgStruct = new SysInfologMessageStruct(enumerator.currentMessage());
exception = enumerator.currentException();
reponseStr += msgStruct.message();
}
ttsbegin;
update_recordset processBlobFileTable_upd setting ErrorMessage = reponseStr, HasError = NoYes::Yes
where processBlobFileTable_upd.FileName == processBlobFileTable.FileName;
update_recordset processBlobFileHeader setting Processed = NoYes::No, HasErrors = NoYes::Yes
where processBlobFileHeader.FileName == processBlobFileTable.FileName;
ttscommit;
}
}
}
/// <summary>
/// this method is used to create payment
/// </summary>
/// <param name = "_processBlobFileTable">LK_ProcessBlobFileTable</param>
/// <returns>LedgerJournalTable</returns>
public LedgerJournalTable createPayJournal(LK_ProcessBlobFileTable _processBlobFileTable)
{
LedgerJournalTrans ledgerJournalTrans;
LedgerJournalTable ledgerJournalTable;
LK_ProcessBlobFileTable processBlobFileTableLocal;
str fileName, sequenceNumberstr;
lineNum = 1;
while select FileName, SequenceNumber from processBlobFileTableLocal
group by FileName, SequenceNumber
where processBlobFileTableLocal.FileName == _processBlobFileTable.FileName
{
ledgerJournalTable = this.createPayJournalBySeqNum(processBlobFileTableLocal, ledgerJournalTable);
fileName = processBlobFileTableLocal.FileName;
sequenceNumberstr = processBlobFileTableLocal.SequenceNumber;
}
if(ledgerJournalTable)
{
//create journal line if amount greater than settlement amount
if(greaterAmount > 0 || greaterAmountRefund > 0)
{
select firstonly processBlobFileTableLocal
where processBlobFileTableLocal.FileName == fileName
&& processBlobFileTableLocal.SequenceNumber == sequenceNumberstr;
if(processBlobFileTableLocal)
{
//create journal line if amount greater than positive amount
if(greaterAmount > 0)
{
ledgerJournalTrans = this.createJournalLine(processBlobFileTableLocal, ledgerJournalTable, lineNum, true);
lineNum++;
ttsbegin;
ledgerJournalTrans.selectForUpdate(true);
ledgerJournalTrans.AmountCurCredit = abs(greaterAmount);
ledgerJournalTrans.update();
ttscommit;
}
//create journal line if amount greater than negative amount
if(greaterAmountRefund > 0)
{
ledgerJournalTrans.clear();
ledgerJournalTrans = this.createJournalLine(processBlobFileTableLocal, ledgerJournalTable, lineNum, true);
lineNum++;
ttsbegin;
ledgerJournalTrans.selectForUpdate(true);
ledgerJournalTrans.AmountCurDebit = abs(greaterAmountRefund);
ledgerJournalTrans.update();
ttscommit;
}
}
}
}
return ledgerJournalTable;
}
/// <summary>
/// this method is used to create payment by sequence number
/// </summary>
/// <param name = "_processBlobFileTable">LK_ProcessBlobFileTable</param>
/// <param name = "_ledgerJournalTable">LedgerJournalTable</param>
/// <returns>LedgerJournalTable</returns>
public LedgerJournalTable createPayJournalBySeqNum(LK_ProcessBlobFileTable _processBlobFileTable, LedgerJournalTable _ledgerJournalTable)
{
LedgerJournalTable ledgerJournalTable;
LedgerJournalTrans ledgerJournalTrans, ledgerJournalTransRefund;
LK_ProcessBlobFileTable processBlobFileTableLocal;
real grossAmount, bankAmount;
str type;
boolean isAddAmount;
real localChargeAmount = 0;
str localSACCode = '';
LedgerJournalTrans feeLinkLine = null; // To link fee to a credit line
container dimValues; // M Vinodkumar - new variables defined. 25 Aug 2025
str brand = '', classification = '', cost = '', navChannel = '', sBRT = '', store = '';
ledgerJournalTable = _ledgerJournalTable;
isSettleCr = false;
isSettleDe = false;
currAmountCr = 0;
currAmountDr = 0;
while select processBlobFileTableLocal
where processBlobFileTableLocal.FileName == _processBlobFileTable.FileName
&& processBlobFileTableLocal.SequenceNumber == _processBlobFileTable.SequenceNumber
{
errorStr = this.validateData(processBlobFileTableLocal);
if(!errorStr)
{
isAddAmount = true;
if(!ledgerJournalTable)
{
ledgerJournalTable = this.createJournalHeader(processBlobFileTableLocal);
}
if(ledgerJournalTable)
{
grossAmount = str2Num(processBlobFileTableLocal.GrossAmount);
bankAmount = str2Num(processBlobFileTableLocal.BankAmount);
type = strUpr(processBlobFileTableLocal.Type);
if(grossAmount >= 0 && bankAmount > 0 && type != 'REFUND' && type != 'CHARGEBACK' && type != 'VAS DEDUCTION' && type != 'CHARGE BACK' && type != 'MERCHANT_FULFILLMENT_REVERSAL' && type != ' REFUND')
{
if(!ledgerJournalTrans)
{
// This method call is to create journal lines.
ledgerJournalTrans = this.createJournalLine(processBlobFileTableLocal, ledgerJournalTable, lineNum);
feeLinkLine = ledgerJournalTrans; // Set fee link for this group
brand = processBlobFileTableLocal.FD_Brand; //M Vinodkumar - to fetch some dimensions - 25 Aug 2025 - Start
classification = processBlobFileTableLocal.FD_ItemClassification;
cost = processBlobFileTableLocal.FD_Center;
navChannel = processBlobFileTableLocal.FD_SubChannel;
sBRT = processBlobFileTableLocal.FD_Unit;
store = processBlobFileTableLocal.FD_Store;
dimValues = [brand, classification, cost, navChannel, sBRT, store]; //M Vinodkumar - to fetch some dimensions - 25 Aug 2025 - End
lineNum++;
}
if(processBlobFileTableLocal.OrderNo || processBlobFileTableLocal.RefNo)
{
if(this.settleprePaymentNew(processBlobFileTableLocal, ledgerJournalTrans, false))
{
isSettleCr = true;
isAddAmount = false;
}
}
if(isAddAmount)
{
currAmountCr = currAmountCr + abs(grossAmount);
}
}
if(grossAmount < 0 || bankAmount <0 || type == 'REFUND' || type == 'CHARGEBACK' || type == 'VAS DEDUCTION' || type == 'CHARGE BACK' || type == 'MERCHANT_FULFILLMENT_REVERSAL' || type == ' REFUND')
{
if(!ledgerJournalTransRefund)
{
// This method call is to create journal lines.
ledgerJournalTransRefund = this.createJournalLine(processBlobFileTableLocal, ledgerJournalTable, lineNum);
lineNum++;
}
if(processBlobFileTableLocal.OrderNo || processBlobFileTableLocal.RefNo)
{
if(this.settleprePaymentNew(processBlobFileTableLocal, ledgerJournalTransRefund, true))
{
isSettleDe = true;
isAddAmount = false;
}
}
if(isAddAmount)
{
currAmountDr = currAmountDr + abs(grossAmount);
}
}
// Accumulate charges per group
localChargeAmount += str2Num(processBlobFileTableLocal.Charges) + str2Num(processBlobFileTableLocal.GST);
localSACCode = processBlobFileTableLocal.SACCode;
}
}
}
if(ledgerJournalTable)
{
if(ledgerJournalTrans)
{
ttsbegin;
ledgerJournalTrans.selectForUpdate(true);
ledgerJournalTrans.AmountCurCredit = abs(currAmountCr);
if(isSettleCr)
{
ledgerJournalTrans.SettleVoucher = SettlementType::SelectedTransact;
}
ledgerJournalTrans.update();
ttscommit;
}
if(ledgerJournalTransRefund)
{
ttsbegin;
ledgerJournalTransRefund.selectForUpdate(true);
ledgerJournalTransRefund.AmountCurDebit = abs(currAmountDr);
if(isSettleDe)
{
ledgerJournalTransRefund.SettleVoucher = SettlementType::SelectedTransact;
}
ledgerJournalTransRefund.update();
ttscommit;
}
}
// Create fee for this group if applicable
if (feeLinkLine && localChargeAmount != 0)
{
this.createJournalFee(ModuleCustVend::Cust, localChargeAmount, localSACCode, feeLinkLine, dimValues); //M Vinodkumar - Added new parameter to fetch dimensions - 25 Aug 2025
}
return ledgerJournalTable;
}
/// <summary>
/// this method is uded to add fee
/// </summary>
/// <param name = "_module">ModuleCustVend</param>
/// <param name = "_feeAmount">real</param>
/// <param name = "_SACCode">str</param>
/// <param name = "_ledgerJournalTransLink">LedgerJournalTrans</param>
/// <param name = "_dimContainer">container</param>
public void createJournalFee(
ModuleCustVend _module,
real _feeAmount,
str _SACCode,
LedgerJournalTrans _ledgerJournalTransLink,
Container _dimContainer
)
{
CustVendPaymJournalFee custVendPaymJournalFee;
CustVendPaymModeFeeMap custVendPaymModeFee;
TransTaxInformation transTaxInformationLocal;
ServiceAccountingCodeTable_IN serviceAccountingCodeTable_INFind;
CustPaymFee custPaymFee;
LedgerjournalTrans ledgerjournalTrans;
DimensionAttributeValueCombination dimAttributeValueCombination;//M Vinodkumar - new variables defined. 25 Aug 2025
RefRecId accountDefaultDimension;
LedgerDimensionAccount ledgerDimensionAccount ;
LedgerDimensionDefaultAccount ledgerDimDefaultAccount;
MainAccount mainAccount;
DimensionDisplayValue diplayValue;
select firstonly custPaymFee
where custPaymFee.FeeId == this.parmFeeId();
if(_ledgerJournalTransLink && custPaymFee)
{
custVendPaymModeFee.initFromModule(_module);
custVendPaymJournalFee.clear();
custVendPaymJournalFee.RefRecId = _ledgerJournalTransLink.RecId;
custVendPaymJournalFee.initValue();
custVendPaymJournalFee.Module = _module;
custVendPaymJournalFee.FeeId = this.parmFeeId();
custVendPaymJournalFee.FeeCurrency = _ledgerJournalTransLink.CurrencyCode;
custVendPaymJournalFee.FeeValue = _feeAmount;
if (custPaymFee.FeePosting == PaymFeePostingCust::Cost)
{
custVendPaymJournalFee.LedgerJournalACType = LedgerJournalACType::Ledger;
// M Vinodkumar - Commented below line of code due to fetching some more dimensions - 25 Aug 2025 - Start
/*custVendPaymJournalFee.LedgerDimension = _ledgerJournalTransLink.getLedgerDimensionForLedgerType(
custPaymFee.LedgerDimension,
curext());*/
diplayValue = DimensionAttributeValueCombination::find(custPaymFee.LedgerDimension).DisplayValue;
select firstonly RecId from dimAttributeValueCombination
where dimAttributeValueCombination.DisplayValue == diplayValue + #PipeSymbol + conPeek(_dimContainer,1) + #PipeSymbol + conPeek(_dimContainer,2) + #PipeSymbol + conPeek(_dimContainer,3) + #PipeSymbol + conPeek(_dimContainer,4) + #PipeSymbol + conPeek(_dimContainer,5) + #PipeSymbol + conPeek(_dimContainer,6);
custVendPaymJournalFee.LedgerDimension = dimAttributeValueCombination.RecId;
if (!dimAttributeValueCombination.RecId)
{
accountDefaultDimension = LK_FinancialDimensionHelper::getDimensionNew('', //Item dimension
'', // Master dimension
'', //_siteDimension
conPeek(_dimContainer,1), //_brand
conPeek(_dimContainer,2), //_classification
conPeek(_dimContainer,3), // _costCenter
conPeek(_dimContainer,4), //_NavChannel
conPeek(_dimContainer,5), // _SBRT
conPeek(_dimContainer,6)); //_Store
select firstonly MainAccountId,LedgerChartOfAccounts from mainAccount
where mainAccount.MainAccountId == diplayValue;
ledgerDimDefaultAccount = LedgerDefaultAccountHelper::getDefaultAccountFromMainAccountIdAndCOA(mainAccount.MainAccountId, mainAccount.LedgerChartOfAccounts);
ledgerDimensionAccount = LedgerDimensionFacade::serviceCreateLedgerDimension(ledgerDimDefaultAccount,accountDefaultDimension );
custVendPaymJournalFee.LedgerDimension = ledgerDimensionAccount;
}
// M Vinodkumar - Commented below line of code due to fetching some more dimensions - 25 Aug 2025 - End
}
else
{
custVendPaymJournalFee.parmCustVendAccount(_ledgerJournalTransLink.parmAccount(), LedgerJournalACType::Cust);
}
custVendPaymJournalFee.insert();
if(_SACCode)
{
select firstonly ledgerjournalTrans
where ledgerjournalTrans.RecId == custVendPaymJournalFee.feeTransRecId;
transTaxInformationLocal = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(ledgerjournalTrans, true);
if(transTaxInformationLocal)
{
select firstonly RecId
from serviceAccountingCodeTable_INFind
where serviceAccountingCodeTable_INFind.SAC == _SACCode;
if(serviceAccountingCodeTable_INFind.RecId)
{
transTaxInformationLocal.ServiceAccountingCodeTable = serviceAccountingCodeTable_INFind.RecId;
}
transTaxInformationLocal.doUpdate();
}
}
}
}
/// <summary>
/// this method is used to journal header
/// </summary>
/// <param name = "_processBlobFileTable">LK_ProcessBlobFileTable</param>
/// <returns>LedgerJournalTable</returns>
private LedgerJournalTable createJournalHeader(LK_ProcessBlobFileTable _processBlobFileTable)
{
LedgerJournalTable ledgerJournalTable;
ledgerJournalTable.clear();
select firstonly ledgerjournalname
where ledgerjournalname.JournalName == this.parmJournalName();
ledgerJournalTable.initFromLedgerJournalName(ledgerjournalname.JournalName);
ledgerJournalTable.JournalNum = JournalTableData::newTable(ledgerJournalTable).nextJournalId();
ledgerJournalTable.OffsetLedgerDimension = ledgerjournalname.OffsetLedgerDimension;
ledgerJournalTable.OffsetAccountType = ledgerjournalname.OffsetAccountType;
ledgerJournalTable.DefaultDimension = ledgerjournalname.DefaultDimension;
//ledgerJournalTable.DocumentNum = _processBlobFileTable.DocumentNo;
ledgerJournalTable.Name = strFmt('%1-%2',ledgerJournalTable.Name, _processBlobFileTable.FileName);
ledgerJournalTable.insert();
journalNum = ledgerJournalTable.JournalNum;
return ledgerJournalTable;
}
private LedgerJournalTrans createJournalLine(LK_ProcessBlobFileTable _processBlobFileTable, LedgerJournalTable _ledgerJournalTable, real _lineNum, boolean isRefAmount = false)
{
NumberSeq numberSeq;
LedgerJournalTrans ledgerJournalTrans;
DimensionDynamicAccount ledgerDim;
CustPaymModeTable custPaymModeTable;
container dimContainer;
select firstonly Customer from tidMidMasterTable
where tidMidMasterTable.TIDNumber == strRem(_processBlobFileTable.TIDNo, ' ')
&& tidMidMasterTable.MIDNumber == strRem(_processBlobFileTable.MIDNo, ' ');
ledgerJournalTrans.clear();
ledgerJournalTrans.initValue();
numberSeq = NumberSeq::newGetVoucherFromId((ledgerJournalname.NumberSequenceTable));
ledgerJournalTrans.Voucher = numberSeq.voucher();
ledgerJournalTrans.JournalNum = _ledgerJournalTable.JournalNum;
ledgerJournalTrans.LineNum = _lineNum;
select firstonly PaymMode,Name
from custPaymModeTable
where custPaymModeTable.PaymMode == this.parmPaymMode()
|| custPaymModeTable.Name == this.parmPaymMode();
ledgerJournalTrans.PaymMode = custPaymModeTable.PaymMode;
ledgerJournalTrans.Prepayment = NoYes::No;
ledgerJournalTrans.PaymentStatus = CustVendPaymStatus::None;
ledgerJournalTrans.AccountType = LedgerJournalACType::Cust;
ledgerJournalTrans.Company = curext();
ledgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(tidMidMasterTable.Customer, LedgerJournalACType::Cust);
ledgerJournalTrans.LedgerDimension = ledgerDim;
ledgerJournalTrans.OffsetAccountType = ledgerjournalname.OffsetAccountType;
ledgerJournalTrans.OffsetLedgerDimension = ledgerjournalname.OffsetLedgerDimension;
ledgerJournalTrans.Txt = _processBlobFileTable.PaymentGateway;
ledgerJournalTrans.CurrencyCode = Ledger::accountingCurrency(CompanyInfo::current());
ledgerJournalTrans.TransDate = str2Date(_processBlobFileTable.DocumentDate, 123);
ledgerJournalTrans.TransactionType = LedgerTransType::Payment;
dimContainer = LK_FinancialDimensionHelper::getDimensionValueContainer(DimensionSetEntity::find(ledgerjournalname.DefaultDimension).DisplayValue);
//Start Date 27/07/25 SN 1534_Financial Dimension
ledgerJournalTrans.OffsetDefaultDimension = LK_FinancialDimensionHelper::getDimensionNew('',
DimensionSetEntity::find(CustTable::find(tidMidMasterTable.Customer).DefaultDimension).DisplayValue,
'', //_siteDimension
conPeek(dimContainer, 1), //_brand
conPeek(dimContainer, 2), //_classification
conPeek(dimContainer, 3), //_costCenter
conPeek(dimContainer, 4), //_navChannel
conPeek(dimContainer, 5), // _SBRT
conPeek(dimContainer, 6)); //Store
ledgerJournalTrans.DefaultDimension = LK_FinancialDimensionHelper::getDimensionNew('',
DimensionSetEntity::find(CustTable::find(tidMidMasterTable.Customer).DefaultDimension).DisplayValue,
'',
conPeek(dimContainer, 1), //_brand
conPeek(dimContainer, 2), //_classification
conPeek(dimContainer, 3), //_costCenter
conPeek(dimContainer, 4), //_navChannel
conPeek(dimContainer, 5), // _SBRT
conPeek(dimContainer, 6)); //Store
/*LK_FinancialDimensionHelper::getDimension('',
DimensionSetEntity::find(CustTable::find(tidMidMasterTable.Customer).DefaultDimension).DisplayValue,
'', //_siteDimension
conPeek(dimContainer, 9), //_brand
conPeek(dimContainer, 3), //_costCenter
conPeek(dimContainer, 10), // _employee
conPeek(dimContainer, 8), //_itemClassification
conPeek(dimContainer, 5), //_salesChannel
conPeek(dimContainer, 1), //_site
conPeek(dimContainer, 4), // _stores
conPeek(dimContainer, 6), //_subChannel
conPeek(dimContainer, 2), //_units
conPeek(dimContainer, 7)); //_vendorType
ledgerJournalTrans.DefaultDimension = LK_FinancialDimensionHelper::getDimension('',
DimensionSetEntity::find(CustTable::find(tidMidMasterTable.Customer).DefaultDimension).DisplayValue,
'',
conPeek(dimContainer, 9), //_brand
conPeek(dimContainer, 3), //_costCenter
conPeek(dimContainer, 10), // _employee
conPeek(dimContainer, 8), //_itemClassification
conPeek(dimContainer, 5), //_salesChannel
conPeek(dimContainer, 1), //_site
conPeek(dimContainer, 4), // _stores
conPeek(dimContainer, 6), //_subChannel
conPeek(dimContainer, 2), //_units
conPeek(dimContainer, 7)); //_vendorType */
//Date 27/07/25 SN 1534_Financial Dimension End
ledgerJournalTrans.PostingProfile = CustParameters::find().PostingProfile;
ledgerjournalTrans.SettleVoucher = SettlementType::None;
ledgerjournalTrans.Approved = NoYes::Yes;
if(!isRefAmount)
{
ledgerJournalTrans.PaymReference = _processBlobFileTable.SequenceNumber;
}
ledgerJournalTrans.LK_ArnNum = _processBlobFileTable.ArnNo;
ledgerJournalTrans.LK_BankAmount = str2Num(_processBlobFileTable.BankAmount);
ledgerJournalTrans.LK_CardType = _processBlobFileTable.CardType;
ledgerJournalTrans.LK_Charges = str2Num(_processBlobFileTable.Charges);
ledgerJournalTrans.LK_Type = _processBlobFileTable.Type;
ledgerJournalTrans.LK_EntryNo = _processBlobFileTable.RecId;
ledgerJournalTrans.LK_GstAmount = str2Num(_processBlobFileTable.GST);
ledgerJournalTrans.LK_GstnTransactionId = _processBlobFileTable.GSTNTransactionId;
ledgerJournalTrans.LK_InternationalDomestic = _processBlobFileTable.International_Domestic;
ledgerJournalTrans.LK_MidNum = _processBlobFileTable.MIDNo;
ledgerJournalTrans.LK_Mode = _processBlobFileTable.Mode;
ledgerJournalTrans.LK_OrderNum = _processBlobFileTable.OrderNo;
ledgerJournalTrans.LK_PaymentGateway = _processBlobFileTable.PaymentGateway;
ledgerJournalTrans.LK_PaymentType = _processBlobFileTable.PaymentType;
ledgerJournalTrans.LK_RefNo = _processBlobFileTable.RefNo;
ledgerJournalTrans.LK_SequenceNumber = _processBlobFileTable.SequenceNumber;
ledgerJournalTrans.LK_TidNo = _processBlobFileTable.TIDNo;
ledgerJournalTrans.LK_WebOrderNo = _processBlobFileTable.OrderNo;
ledgerJournalTrans.LK_CreatedOn = str2Date(_processBlobFileTable.CreatedDate, 123);
ledgerJournalTrans.LK_Status = _processBlobFileTable.Status;
ledgerJournalTrans.LK_ErrorText = _processBlobFileTable.PaymentGateway;
ledgerJournalTrans.LK_BankDate = _processBlobFileTable.AcceptedDate;
ledgerJournalTrans.DocumentDate = str2Date(_processBlobFileTable.DocumentDate, 123);
ledgerJournalTrans.insert();
return ledgerJournalTrans;
}
/// <summary>
/// This method is to post the payment journal.
/// </summary>
public void postpayment()
{
LedgerJournalCheckPost journalCheckPost;
LedgerJournalTable ledgerJournalTable;
ledgerJournalTable = LedgerJournalTable::find(journalNum, true);
if(ledgerJournalTable)
{
journalCheckPost = LedgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable, NoYes::Yes);
journalCheckPost.runOperation();
}
}
public boolean settleprePaymentNew(LK_ProcessBlobFileTable _processBlobFileTable, LedgerJournaltrans _ledgerjournalTrans, boolean isRefund)
{
CustTrans custtrans;
CustTransOpen custTransOpen;
specTransManager specTransManager;
AmountCur currentSettlement;
SpecTrans specTrans;
boolean isSettel = false;
if(isRefund)
{
if(_processBlobFileTable.OrderNo)
{
select firstonly custTransOpen
join custTrans
where custTransOpen.AccountNum == custTrans.AccountNum
&& custTransOpen.RefRecId == custTrans.RecId
&& custtrans.AccountNum == tidMidMasterTable.Customer
&& custTrans.DocumentNum == _processBlobFileTable.OrderNo
&& custTransOpen.AmountCur < 0;
}
if(!custTransOpen && _processBlobFileTable.RefNo)
{
select firstonly custTransOpen
join custTrans
where custTransOpen.AccountNum == custTrans.AccountNum
&& custTransOpen.RefRecId == custTrans.RecId
&& custtrans.AccountNum == tidMidMasterTable.Customer
&& custTrans.PaymReference == _processBlobFileTable.RefNo
&& custTransOpen.AmountCur < 0;
}
}
if(!isRefund)
{
if(_processBlobFileTable.OrderNo)
{
select firstonly custTransOpen
join custTrans
where custTransOpen.AccountNum == custTrans.AccountNum
&& custTransOpen.RefRecId == custTrans.RecId
&& custtrans.AccountNum == tidMidMasterTable.Customer
&& custTrans.DocumentNum == _processBlobFileTable.OrderNo
&& custTransOpen.AmountCur > 0;
}
if(!custTransOpen && _processBlobFileTable.RefNo)
{
select firstonly custTransOpen
join custTrans
where custTransOpen.AccountNum == custTrans.AccountNum
&& custTransOpen.RefRecId == custTrans.RecId
&& custtrans.AccountNum == tidMidMasterTable.Customer
&& custTrans.PaymReference == _processBlobFileTable.RefNo
&& custTransOpen.AmountCur > 0;
}
}
if(custTransOpen)
{
specTransManager = SpecTransManager::newFromSpec(_ledgerjournalTrans);
currentSettlement = abs(str2Num(_processBlobFileTable.GrossAmount));
specTrans = specTransManager.findByRef(custTransOpen.company(), custTransOpen.TableId, custTransOpen.RecId);
if(specTrans)
{
if(abs(specTrans.Balance01) >= abs(custTransOpen.AmountCur))
{
if(isRefund)
{
greaterAmountRefund = greaterAmountRefund + abs(currentSettlement);
}
else
{
greaterAmount = greaterAmount + abs(currentSettlement);
}
isSettel = true;
}
else
{
if(abs(currentSettlement) <= (abs(custTransOpen.AmountCur) - abs(specTrans.Balance01)))
{
if(isRefund)
{
currAmountDr = currAmountDr + abs(currentSettlement);
}
else
{
currAmountCr = currAmountCr + abs(currentSettlement);
}
currentSettlement = currentSettlement + specTrans.Balance01;
}
else
{
if(isRefund)
{
greaterAmountRefund = greaterAmountRefund + (abs(currentSettlement) - (abs(custTransOpen.AmountCur) - abs(specTrans.Balance01)));
currentSettlement = (abs(custTransOpen.AmountCur) - abs(specTrans.Balance01));
currAmountDr = currAmountDr + abs(currentSettlement);
currentSettlement = currentSettlement + abs(specTrans.Balance01);
}
else
{
greaterAmount = greaterAmount + (abs(currentSettlement) - (abs(custTransOpen.AmountCur) - abs(specTrans.Balance01)));
currentSettlement = (abs(custTransOpen.AmountCur) - abs(specTrans.Balance01));
currAmountCr = currAmountCr + abs(currentSettlement);
currentSettlement = currentSettlement + abs(specTrans.Balance01);
}
}
specTransManager.updateSettleAmount(
custTransOpen.company(),
custTransOpen.TableId,
custTransOpen.RecId,
currentSettlement);
isSettel = true;
}
}
else
{
if(abs(currentSettlement) > abs(custTransOpen.AmountCur))
{
if(isRefund)
{
greaterAmountRefund = greaterAmountRefund + (abs(currentSettlement) - abs(custTransOpen.AmountCur));
currAmountDr = currAmountDr + abs(custTransOpen.AmountCur);
}
else
{
greaterAmount = greaterAmount + (abs(currentSettlement) - abs(custTransOpen.AmountCur));
currAmountCr = currAmountCr + abs(custTransOpen.AmountCur);
}
currentSettlement = custTransOpen.AmountCur;
}
else
{
if(isRefund)
{
currAmountDr = currAmountDr + abs(currentSettlement);
}
else
{
currAmountCr = currAmountCr + abs(currentSettlement);
}
}
specTransManager.insert(
custTransOpen.company(),
custTransOpen.TableId,
custTransOpen.RecId,
currentSettlement,
_ledgerjournalTrans.CurrencyCode);
isSettel = true;
}
}
return isSettel;
}
/// <summary>
/// This method is to perform prepayment settlement.
/// </summary>
/// <param name = "_processBlobFileTable">LK_ProcessBlobFileTable</param>
public void settleprePayment(LK_ProcessBlobFileTable _processBlobFileTable)
{
LedgerJournalTable ledgerjournalTable;
CustTrans custtrans;
CustTransOpen custTransOpen;
LedgerJournaltrans ledgerjournalTrans;
specTransManager specTransManager;
AmountCur totalSettlement, currentSettlement;
SpecTrans specTrans;
ledgerjournalTable = ledgerjournalTable::find(journalNum);
select firstonly ledgerjournalTrans
where ledgerjournalTrans.JournalNum == ledgerjournalTable.JournalNum;
specTransManager = SpecTransManager::newFromSpec(ledgerjournalTrans);
if(_processBlobFileTable.OrderNo)
{
select firstonly custTransOpen
join custTrans
where custTransOpen.AccountNum == custTrans.AccountNum
&& custTransOpen.RefRecId == custTrans.RecId
&& custtrans.AccountNum == tidMidMasterTable.Customer
&& custTrans.DocumentNum == _processBlobFileTable.OrderNo;
}
if(!custTransOpen && _processBlobFileTable.RefNo)
{
select firstonly custTransOpen
join custTrans
where custTransOpen.AccountNum == custTrans.AccountNum
&& custTransOpen.RefRecId == custTrans.RecId
&& custtrans.AccountNum == tidMidMasterTable.Customer
&& custTrans.PaymReference == _processBlobFileTable.RefNo;
}
if(custTransOpen)
{
currentSettlement = str2Num(_processBlobFileTable.GrossAmount);
specTrans = specTransManager.findByRef(custTransOpen.company(), custTransOpen.TableId, custTransOpen.RecId);
if(specTrans)
{
currentSettlement = currentSettlement + specTrans.Balance01;
specTransManager.updateSettleAmount(
custTransOpen.company(),
custTransOpen.TableId,
custTransOpen.RecId,
currentSettlement);
}
else
{
specTransManager.insert(
custTransOpen.company(),
custTransOpen.TableId,
custTransOpen.RecId,
currentSettlement,
ledgerjournalTrans.CurrencyCode);
}
ExchangeRateHelper exchangeRateHelper = ExchangeRateHelper::newCurrency(Ledger::primaryLedger(CompanyInfo::findDataArea(ledgerjournalTrans.Company).RecId), ledgerjournalTrans.CurrencyCode);
totalSettlement = SpecTransManager::getTotalSettleAmountForSpecReference(
ledgerjournalTrans.company(),
ledgerjournalTrans.TableId,
ledgerjournalTrans.RecId,
ledgerjournalTrans.CurrencyCode,
ledgerjournalTrans.Company,
ledgerjournalTrans.TransDate,
exchangeRateHelper.prepareExchangeRateForStorage(ledgerjournalTrans.crossrate()));
ttsbegin;
ledgerJournalTrans.selectForUpdate(true);
if (ledgerJournalTrans.LK_Type == 'Refund')
{
ledgerJournalTrans.AmountCurDebit = abs(totalSettlement);
}
else
{
ledgerJournalTrans.AmountCurCredit = abs(totalSettlement);
}
ledgerJournalTrans.SettleVoucher = SettlementType::SelectedTransact;
ledgerJournalTrans.update();
ttscommit;
}
}
/// <summary>
/// this method is used to validate the csv data
/// </summary>
/// <param name = "_processBlobFileTable">LK_ProcessBlobFileTable</param>
/// <returns>str</returns>
private str validateData(LK_ProcessBlobFileTable _processBlobFileTable)
{
str ret;
return ret;
}
}
-----------------------------------------------------------------------------------------------
The blob reader class:
using Microsoft.WindowsAzure.Storage;
Using Microsoft.WindowsAzure.Storage.Blob;
/// <summary>
/// this is the blob reader class
/// </summary>
class LK_ReadAndArchiveFileFromBlob
{
int i = 0,j=0;
/// <summary>
/// this method is used to read the blob file and archive the file
/// </summary>
/// <param name = "_blobStorageSetting">LK_BlobStorageSetting</param>
public void readAndArchive(LK_BlobStorageSetting _blobStorageSetting)
{
//CloudBlobDirectory cloudBlobDirectory;
CloudBlobClient cloudBlobClient;
CloudBlobContainer cloudBlobContainer;
CloudStorageAccount cloudStorageAccount;
cloudStorageAccount = CloudStorageAccount::Parse(_blobStorageSetting.BlobStorageConnectionString);
cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
cloudBlobContainer = cloudBlobClient.GetContainerReference(_blobStorageSetting.ReadBlobContainerName); //
System.Collections.IEnumerable lstEnumarable = cloudBlobContainer.ListBlobs(null, false, 0, null, null);
System.Collections.IEnumerator lstEnumarator = lstEnumarable.GetEnumerator();
ttsbegin;
while(lstEnumarator.MoveNext())
{
IListBlobItem item = lstEnumarator.Current;
if(item is CloudBlockBlob)
{
CloudBlockBlob blob = item;
this.addHeaderDetails(blob, _blobStorageSetting);
if(_blobStorageSetting.ProcessType == LK_ProcessType::CustPaym)
{
this.readCSVFileFromBlob(blob);
}
if(_blobStorageSetting.ProcessType == LK_ProcessType::EDCTransaction)
{
this.soReadCSVFileFromBlob(blob);
}
this.archiveBlob(cloudBlobClient, blob, _blobStorageSetting);
}
}
ttscommit;
}
/// <summary>
/// this method is used to add header details
/// </summary>
/// <param name = "_blob">CloudBlockBlob</param>
/// <param name = "_blobStorageSetting">LK_BlobStorageSetting</param>
private void addHeaderDetails(CloudBlockBlob _blob, LK_BlobStorageSetting _blobStorageSetting)
{
LK_ProcessBlobFileHeader processBlobFileHeader;
processBlobFileHeader.clear();
if(_blobStorageSetting.ProcessType == LK_ProcessType::EDCTransaction)
{
if(i==0)
{
processBlobFileHeader.FileName = _blob.Name;
i = 1;
}
}
else
{
processBlobFileHeader.FileName = _blob.Name;
}
processBlobFileHeader.ProcessType = _blobStorageSetting.ProcessType;
processBlobFileHeader.Processed = NoYes::No;
processBlobFileHeader.insert();
}
/// <summary>
/// This method is used to read the file data
/// </summary>
/// <param name = "_blob">CloudBlockBlob</param>
public void readCSVFileFromBlob(CloudBlockBlob _blob)
{
var text = "@LK_Label:LK_BlankSpace";
RecordInsertList recordInsertList = null;
List data = new List(Types::String);
boolean isHeader;
if (_blob)
{
using (var sr = new System.IO.StreamReader(_blob.OpenRead(null, null, null), System.Text.Encoding::get_UTF8()))
{
recordInsertList = new RecordInsertList(tablenum(LK_ProcessBlobFileTable));
text = sr.ReadLine();
isHeader = true;
While(!System.String::IsNullOrEmpty(text))
{
data = strSplit(text, ','); //Split the lines based on ‘,’ it’s return type is List.
if(!isHeader)
{
recordInsertList.add(this.getDataTable(data, _blob.Name));
}
else
{
isHeader = false;
}
//To read next line
text = sr.ReadLine();
}
recordInsertList.insertDatabase();
}
}
}
public void soReadCSVFileFromBlob(CloudBlockBlob _blob)
{
var text = "@LK_Label:LK_BlankSpace";
RecordInsertList recordInsertList = null;
List data = new List(Types::String);
boolean isHeader;
if (_blob)
{
using (var sr = new System.IO.StreamReader(_blob.OpenRead(null, null, null), System.Text.Encoding::get_UTF8()))
{
recordInsertList = new RecordInsertList(tablenum(LK_ProcessBlobFileTable_SO));
text = sr.ReadLine();
isHeader = true;
While(!System.String::IsNullOrEmpty(text))
{
data = strSplit(text, ','); //Split the lines based on ‘,’ it’s return type is List.
if(!isHeader)
{
recordInsertList.add(this.getSODataTable(data, _blob.Name));
}
else
{
isHeader = false;
}
//To read next line
text = sr.ReadLine();
}
recordInsertList.insertDatabase();
}
}
}
/// <summary>
/// this method is used to get the table records
/// </summary>
/// <param name = "_data">List</param>
/// <param name = "_fileName">str</param>
/// <returns>LK_ProcessBlobFileTable</returns>
private LK_ProcessBlobFileTable getDataTable(List _data, str _fileName)
{
LK_ProcessBlobFileTable processBlobFileTable;
container dataContainer;
dataContainer = conNull();
dataContainer = _data.pack();
processBlobFileTable.FileName = _fileName;
processBlobFileTable.TIDNo = conPeek(dataContainer, 4);
processBlobFileTable.MIDNo = conPeek(dataContainer, 5);
processBlobFileTable.RefNo = conPeek(dataContainer, 6);
processBlobFileTable.OrderNo = conPeek(dataContainer, 7);
processBlobFileTable.GrossAmount = conPeek(dataContainer, 8);
processBlobFileTable.Charges = conPeek(dataContainer, 9);
processBlobFileTable.GST = conPeek(dataContainer, 10);
processBlobFileTable.BankAmount = conPeek(dataContainer, 11);
processBlobFileTable.Type = conPeek(dataContainer, 12);
processBlobFileTable.FacilityCode = conPeek(dataContainer, 13);
processBlobFileTable.LocationCode = conPeek(dataContainer, 14);
processBlobFileTable.Department = conPeek(dataContainer, 15);
processBlobFileTable.CustomerNo = conPeek(dataContainer, 16);
processBlobFileTable.GLCode = conPeek(dataContainer, 17);
processBlobFileTable.CreatedDate = conPeek(dataContainer, 18);
processBlobFileTable.CreatedTime = conPeek(dataContainer, 19);
processBlobFileTable.Status = conPeek(dataContainer, 20);
processBlobFileTable.AcceptedDate = conPeek(dataContainer, 21);
processBlobFileTable.AcceptedTime = conPeek(dataContainer, 22);
processBlobFileTable.BankCode = conPeek(dataContainer, 23);
processBlobFileTable.DocumentDate = conPeek(dataContainer, 24);
processBlobFileTable.ProfitCenter = conPeek(dataContainer, 25);
processBlobFileTable.Division = conPeek(dataContainer, 26);
processBlobFileTable.DocumentNo = conPeek(dataContainer, 27);
processBlobFileTable.GSTGLCode = conPeek(dataContainer, 28);
processBlobFileTable.BankName = conPeek(dataContainer, 29);
processBlobFileTable.PaymentGateway = conPeek(dataContainer, 30);
processBlobFileTable.PaymentType = conPeek(dataContainer, 31);
processBlobFileTable.International_Domestic = conPeek(dataContainer, 32);
processBlobFileTable.Mode = conPeek(dataContainer, 33);
processBlobFileTable.TransDate = conPeek(dataContainer, 34);
processBlobFileTable.CardType = conPeek(dataContainer, 35);
processBlobFileTable.SequenceNumber = conPeek(dataContainer, 36);
processBlobFileTable.ArnNo = conPeek(dataContainer, 37);
processBlobFileTable.GSTNTransactionId = conPeek(dataContainer, 38);
processBlobFileTable.IsProcessed = NoYes::No;
processBlobFileTable.LegalEntityName = conPeek(dataContainer, 39);
processBlobFileTable.SACCode = conPeek(dataContainer, 40);
// M Vinodkumar - assigned values to fetch dimensions - 25 Aug 2025 - Start
processBlobFileTable.FD_Brand = conPeek(dataContainer, 41);
processBlobFileTable.FD_ItemClassification = conPeek(dataContainer, 42);
processBlobFileTable.FD_Center = conPeek(dataContainer, 43);
processBlobFileTable.FD_SubChannel = conPeek(dataContainer, 44);
processBlobFileTable.FD_Unit = conPeek(dataContainer, 45);
processBlobFileTable.FD_Store = conPeek(dataContainer, 46);
// M Vinodkumar - assigned values to fetch dimensions - 25 Aug 2025 - End
return processBlobFileTable;
}
private LK_ProcessBlobFileTable_SO getSODataTable(List _data, str _fileName)
{
LK_ProcessBlobFileTable_SO processBlobFileTable_SO;
container dataContainer;
dataContainer = conNull();
dataContainer = _data.pack();
processBlobFileTable_SO.FileName = _fileName;
processBlobFileTable_SO.LegalEntityName = conPeek(dataContainer,4);
processBlobFileTable_SO.SalesType = conPeek(dataContainer, 5);
processBlobFileTable_SO.InterCompanyOrder = conPeek(dataContainer,6);
processBlobFileTable_SO.TransDate = conPeek(dataContainer,7);
processBlobFileTable_SO.CustomerNo = conPeek(dataContainer,8);
processBlobFileTable_SO.Warehouse = conPeek(dataContainer,9);
processBlobFileTable_SO.CurrencyCode = conPeek(dataContainer,10);
processBlobFileTable_SO.ItemId = conPeek(dataContainer,11);
processBlobFileTable_SO.SalesQty = conPeek(dataContainer,12);
processBlobFileTable_SO.SalesPrice = conPeek(dataContainer,13);
processBlobFileTable_SO.FD_Site = conPeek(dataContainer,14);
processBlobFileTable_SO.FD_Unit = conPeek(dataContainer,15);
processBlobFileTable_SO.FD_Center = conPeek(dataContainer,16);
processBlobFileTable_SO.FD_Store = conPeek(dataContainer,17);
processBlobFileTable_SO.FD_SalesChannel = conPeek(dataContainer,18);
processBlobFileTable_SO.FD_SubChannel = conPeek(dataContainer,19);
processBlobFileTable_SO.FD_PartnerType = conPeek(dataContainer,20);
processBlobFileTable_SO.FD_ItemClassification = conPeek(dataContainer,21);
processBlobFileTable_SO.FD_Brand = conPeek(dataContainer,22);
processBlobFileTable_SO.FD_Employee = conPeek(dataContainer,23);
processBlobFileTable_SO.LK_ApprovalCode = conPeek(dataContainer,24);
processBlobFileTable_SO.LK_BankAmount = conPeek(dataContainer,25);
processBlobFileTable_SO.LK_CardNetwork = conPeek(dataContainer,26);
processBlobFileTable_SO.LK_CardNo = conPeek(dataContainer,27);
processBlobFileTable_SO.LK_Invoice = conPeek(dataContainer,28);
processBlobFileTable_SO.LK_Type = conPeek(dataContainer,29);
processBlobFileTable_SO.MIDNo = conPeek(dataContainer,30);
processBlobFileTable_SO.TIDNo = conPeek(dataContainer,31);
processBlobFileTable_SO.LK_POSID = conPeek(dataContainer,32);
processBlobFileTable_SO.LK_Source = conPeek(dataContainer,33);
processBlobFileTable_SO.LK_TransactionPer = conPeek(dataContainer,34);
processBlobFileTable_SO.LK_TxnId = conPeek(dataContainer,35);
processBlobFileTable_SO.TCS = conPeek(dataContainer,36);
processBlobFileTable_SO.TDS = conPeek(dataContainer,37);
processBlobFileTable_SO.HSN = conPeek(dataContainer,38);
processBlobFileTable_SO.SAC = conPeek(dataContainer,39);
processBlobFileTable_SO.FacilityCode = conPeek(dataContainer,40);
processBlobFileTable_SO.Remarks = conPeek(dataContainer,41);
return processBlobFileTable_SO;
}
/// <summary>
/// this method is used to archive the file
/// </summary>
/// <param name = "_cloudBlobClient">CloudBlobClient</param>
/// <param name = "_sourceBlob">CloudBlockBlob</param>
/// <param name = "_blobStorageSetting">LK_BlobStorageSetting</param>
public void archiveBlob(CloudBlobClient _cloudBlobClient,
CloudBlockBlob _sourceBlob,
LK_BlobStorageSetting _blobStorageSetting)
{
CloudBlobContainer cloudBlobContainer;
CloudBlockBlob distinationBlob;
cloudBlobContainer = _cloudBlobClient.GetContainerReference(_blobStorageSetting.ArchiveBlobContainerName);
distinationBlob = cloudBlobContainer.GetBlockBlobReference(_sourceBlob.Name);
distinationBlob.UploadFromStream(_sourceBlob.OpenRead(null, null, null),null,null,null);
_sourceBlob.DeleteIfExists(DeleteSnapshotsOption::None, null, null, null);
}
}
---------------------------------------------------------------------------------------------------
To fix costcenter which to validate on particular costcenter while creating SalesOrder
In SMMParameters form level to provide only costcenter lookup code
/// <summary>
/// Event handler for lookup costcenter
/// </summary>
internal final class LK_SmmParameters_Eventhandler
{
/// <summary>
/// Event handler for lookup costcenter
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">eventargs</param>
[FormControlEventHandler(formControlStr(smmParameters, smmParametersTable_CostCenter), FormControlEventType::Lookup)]
public static void smmParametersTable_CostCenter_OnLookup(FormControl sender, FormControlEventArgs e)
{
//M Vinodkumar - added this code to fetch costcenter in lookup - 29 Aug 2025 - Start
// Declare variables
Query query = new Query();
QueryBuildDataSource qbds;
SysTableLookup sysTableLookup;
// Create the SysTableLookup instance for OMOperatingUnit
sysTableLookup = sysTableLookup::newParameters(tableNum(OMOperatingUnit), sender);
// Add the fields you want to display in the lookup grid
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit,OMOperatingUnitNumber));
sysTableLookup.addLookupfield(fieldNum(OMOperatingUnit,Name));
// Add a query to filter for Cost Center types only
qbds = query.addDataSource(tableNum(OMOperatingUnit));
qbds.addRange(fieldNum(OMOperatingUnit,OMOperatingUnitType)).value(queryValue(OMOperatingUnitType::OMCostCenter));
// Sort the lookup by the cost center number
qbds.addSortField(fieldNum(OMOperatingUnit,OMOperatingUnitNumber));
// Apply the query to the lookup
sysTableLookup.parmQuery(query);
// Perform the lookup
sysTableLookup.performFormLookup();
//M Vinodkumar - added this code to fetch costcenter in lookup - 29 Aug 2025 - End
}
}
---------------------------------------------------------------------------------------------------------------------------
In SalesLine validatewrite method taken extension and given validation on costcenter
[ExtensionOf(tablestr(SalesLine))]
internal final class LK_Salesline_Extension
{
public boolean validateWrite(boolean _skipCreditLimitCheck)
{
//M Vinodkumar - added this code to compare manual costcenter - 29 Aug 2025 - Start
DimensionAttributeValueSetStorage dimStorage;
smmParametersTable smmParameters = smmParametersTable::find(false);
str ccValue;
boolean ok = next validateWrite(_skipCreditLimitCheck);
SalesTable salesTable = SalesTable::find(this.SalesId);
if (!ok)
return ok;
dimStorage = DimensionAttributeValueSetStorage::find(this.DefaultDimension);
ccValue = dimStorage.getDisplayValueByDimensionAttribute(DimensionAttribute::findByName('@SYS343410').RecId);
// Single value block
if (ccValue == smmParameters.CostCenter && salesTable.LK_Integration == NoYes::No)
{
error(strFmt("@LK_Label:LK_CostCentermanual", ccValue));
ok = false;
}
return ok;
//M Vinodkumar - added this code to compare manual costcenter - 29 Aug 2025 - End
}
}
----------------------------------------------------------------------------------------------------------------------------
Financial dimension helper class
/// <summary>
/// this class used to create sales order and required data
/// </summary>
Public class LK_SalesOrderIntegrationEntityHelper
{
/// <summary>
/// This method is used create customer
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTableV1">_lk_SalesOrderIntergationTableV1</param>
/// <param name = "_lk_SalesOrderIntegrationEntityHelper">_lk_SalesOrderIntegrationEntityHelper</param>
public void CreateCustForSO(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTableV1,LK_SalesOrderIntegrationEntityHelper _lk_SalesOrderIntegrationEntityHelper)
{
CustTable custTable;
NumberSeq numberSeq;
Str60 name;
DirPersonName dirPersonName;
DirPartyType dirPartyType;
container conAttribute;
container conAttributeValue;
DirPerson dirPerson;
DirPartyTable dirPartyTable;
TaxInformationCustTable_IN taxInformationCustTable_IN;
#define.B2Cdom('B2Cdom')
#define.Brand('Brand')
#define.CostCentre('CostCenter')
#define.Classification('Classification')
#define.NavChannel('NavChannel')
#define.SBRT('SBRT')
#define.Store('Store')
custTable.initValue();
numberSeq = NumberSeq::newGetNum(CustParameters::numRefCustAccount());
custTable.AccountNum = _lk_SalesOrderIntergationTableV1.CustomerAccount;
custTable.CustGroup = #B2Cdom;
custTable.Currency = _lk_SalesOrderIntergationTableV1.CurrencyCode;
conAttribute = [#Brand,#CostCentre,#Classification,#NavChannel,#SBRT,#Store];
conAttributeValue = [_lk_SalesOrderIntergationTableV1.Brand,
_lk_SalesOrderIntergationTableV1.CostCenter,
_LK_SalesOrderIntergationTableV1.Classification,
_LK_SalesOrderIntergationTableV1.NavChannel,
_lk_SalesOrderIntergationTableV1.SBRT,
_lk_SalesOrderIntergationTableV1.Store];
dirPartyType = DirPartyType::Person;
if (dirPartyType == DirPartyType::Person)
{
dirpersonname.FirstName = _lk_SalesOrderIntergationTableV1.FirstName;
dirpersonname.MiddleName = _lk_SalesOrderIntergationTableV1.MiddleName;
dirpersonname.LastName = _lk_SalesOrderIntergationTableV1.LastName;
name = strFmt("@LK_Label:LK_ContactNameFormat",dirpersonname.FirstName, dirpersonname.MiddleName, dirpersonname.LastName);
}
if (custTable.validateWrite())
{
custTable.DefaultDimension = LK_DefaultDimesnionHelper::createDefaultDimension(conAttribute,conAttributeValue);
custTable.insert(dirPartyType, name);
dirPartyTable = DirPartyTable::findRec(custTable.Party, true);
dirPartyTable.update();
dirPerson = DirPerson::findByNum(dirPartyTable.PartyNumber, true);
if (dirPartyType == DirPartyType::Person && dirPerson)
{
dirPerson.Gender = _lk_SalesOrderIntergationTableV1.Gender;
dirPerson.update();
}
if (custTable)
{
_LK_SalesOrderIntegrationEntityHelper.createAddress(_lk_SalesOrderIntergationTableV1, custTable);
}
taxInformationCustTable_IN.clear();
taxInformationCustTable_IN.CustTable = custTable.AccountNum;
if (_lk_SalesOrderIntergationTableV1.TCSGroup)
{
taxInformationCustTable_IN.TCSGroup = _lk_SalesOrderIntergationTableV1.TCSGroup;
}
}
else
{
throw Exception::Error;
}
}
/// <summary>
/// This method is used to create Address
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">_lk_SalesOrderIntergationTable</param>
/// <param name = "_custTable">_custTable</param>
public void createAddress(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable, CustTable _custTable)
{
DirParty dirParty;
DirPartyPostalAddressView dirPartyPostalAddressView;
TaxInformation_IN taxInformation_IN;
LogisticsLocation logisticsLocation;
DirPartyTable dirPartyTable;
dirParty = DirParty::constructFromCommon(_custTable);
dirPartyPostalAddressView.clear();
dirPartyPostalAddressView.LocationName = _lk_SalesOrderIntergationTable.DeliveryName;
dirPartyPostalAddressView.City = _lk_SalesOrderIntergationTable.AddressCity;
dirPartyPostalAddressView.Street = _lk_SalesOrderIntergationTable.AddressStreet;
dirPartyPostalAddressView.CountryRegionId = _lk_SalesOrderIntergationTable.AddressCountryRegionId;
dirPartyPostalAddressView.ZipCode = _lk_SalesOrderIntergationTable.AddressZipCode;
dirPartyPostalAddressView.State = _lk_SalesOrderIntergationTable.AddressState;
dirPartyPostalAddressView.IsPrimary = NoYes::Yes;
dirPartyPostalAddressView = dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);
Select firstonly dirPartyTable
where dirPartyTable.RecId == _custTable.Party
join logisticsLocation
where logisticsLocation.RecId == dirPartyPostalAddressView.Location;
taxInformation_IN.clear();
taxInformation_IN.RegistrationLocation = logisticsLocation.RecId;
taxInformation_IN.Name = logisticsLocation.LocationId;
taxInformation_IN.IsPrimary = NoYes::Yes;
}
/// <summary>
/// this method is used to create the postal address of the SO
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <returns>RecId</returns>
public RecId setDeliveryAddress(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
DirPartyPostalAddressView addressView, ret;
DirPartyRecId partyRecId;
DirParty dirParty;
LogisticsPostalAddress postalAddress;
;
//Create new Name
partyRecId = DirPartyTable::createNew(DirPartyType::None, _lk_SalesOrderIntergationTable.DeliveryName).RecId;
addressView.CountryRegionId = _lk_SalesOrderIntergationTable.AddressCountryRegionId;
addressView.State = _lk_SalesOrderIntergationTable.AddressState;
addressView.ZipCode = _lk_SalesOrderIntergationTable.AddressZipCode;
addressView.Street = _lk_SalesOrderIntergationTable.AddressStreet;
addressView.Party = partyRecId;
//Handel errors for addresses
if (!LogisticsAddressCountryRegion::exist(addressView.CountryRegionId))
{
throw error(strFmt("@SYS9347",addressView.CountryRegionId));
}
if (addressView.County && !LogisticsAddressCounty::exist(addressView.CountryRegionId, addressView.State, addressView.County))
{
throw error(strFmt("@SYS72719",addressView.County));
}
if (addressView.State && !LogisticsAddressState::exist(addressView.CountryRegionId, addressView.State))
{
throw error(strFmt("@SYS72786",addressView.State));
}
if (!LogisticsAddressZipCode::exist(addressView.ZipCode))
{
throw error(strFmt("@SYS24626",addressView.ZipCode));
}
if ( addressView.Street || addressView.ZipCode || addressView.City || addressView.State || addressView.CountryRegionId)
{
DirParty = DirParty::constructFromPartyRecId(addressView.Party);
ret = DirParty.createOrUpdatePostalAddress(addressView);
postalAddress = LogisticsPostalAddress::findByLocation(ret.Location, true);
postalAddress.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
postalAddress.update();
}
return postalAddress.RecId;
}
/// <summary>
/// this method is used to create sales order line
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">salesTable</param>
[SuppressBPWarning('BPCheckInsertMethodInLoop', 'To avoid time complexity from separate processing, insert() is preferred over recordInsertList.')]
public void createSalesOrderLine(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable, SalesTable _salesTable)
{
InventDim inventDimLines, inventDimfind;
SalesLine salesLine;
InventTable inventTable;
InventSite inventSite;
Inventlocation inventlocation;
LK_SalesOrderIntergationTableV1 lk_SalesOrderIntergationTableline;
#isoCountryRegionCodes
#define.Pcs('Pcs')
while select lk_SalesOrderIntergationTableline
where lk_SalesOrderIntergationTableline.SalesOrderNumber ==_lk_SalesOrderIntergationTable.SalesOrderNumber
&& lk_SalesOrderIntergationTableline.EntityName == LK_SalesProcessEntityName::SalesOrderLine
{
select firstonly ItemId, DefaultDimension
from inventTable
where inventTable.ItemId == lk_SalesOrderIntergationTableline.ItemNumber;
if (!inventTable.ItemId)
{
this.createReleasedItem(lk_SalesOrderIntergationTableline);
this.updateInventTable(lk_SalesOrderIntergationTableline);
}
salesLine.clear();
salesLine.SalesId = _salesTable.SalesId;
salesLine.initValue(_salesTable.SalesType);
salesLine.initFromSalesTable(_salesTable);
salesLine.ItemId = lk_SalesOrderIntergationTableline.ItemNumber;
salesLine.initFromInventTable(InventTable::find(salesLine.ItemId));
inventDimfind.InventSiteId = lk_SalesOrderIntergationTableline.InventSiteId;
if (!lk_SalesOrderIntergationTableline.InventSiteId)
{
select firstonly InventSiteId
from inventlocation
where inventlocation.InventLocationId == lk_SalesOrderIntergationTableline.InventLocationId;
inventDimfind.InventSiteId = inventlocation.InventSiteId;
}
inventDimfind.InventLocationId = lk_SalesOrderIntergationTableline.InventLocationId;
inventDimLines = InventDim::findOrCreate(inventDimfind);
salesLine.LineNum = lk_SalesOrderIntergationTableline.LineNumber;
salesLine.InventDimId = inventDimLines.inventDimId;
salesLine.LK_CardNo = lk_SalesOrderIntergationTableline.CardNo;
salesLine.LK_TxnId = lk_SalesOrderIntergationTableline.TxnId;
if (lk_SalesOrderIntergationTableline.SalesUnitSymbol == '')
{
salesLine.SalesUnit = #Pcs;
}
else
{
salesLine.SalesUnit = lk_SalesOrderIntergationTableline.SalesUnitSymbol;
}
if (_salesTable.LKSalesType == SalesType::ReturnItem)
{
salesLine.LKSalesType = _salesTable.LKSalesType;
salesLine.SalesQty = abs(lk_SalesOrderIntergationTableline.QtyOrdered) * (-1);
}
else
{
salesLine.SalesQty = lk_SalesOrderIntergationTableline.QtyOrdered;
}
salesLine.RemainSalesPhysical = salesLine.SalesQty;
salesLine.QtyOrdered = salesLine.calcQtyOrdered();
salesLine.RemainInventPhysical = salesLine.QtyOrdered;
salesLine.DlvMode = _salesTable.DlvMode;
salesLine.SalesPrice = lk_SalesOrderIntergationTableline.SalesPrice;
salesLine.LineDisc = str2Num(lk_SalesOrderIntergationTableline.LineDiscountAmount);
salesLine.InvoiceDate = lk_SalesOrderIntergationTableline.InvoiceDate;
salesLine.CustomerInvoiceDate = lk_SalesOrderIntergationTableline.CustomerInvoiceDate;
salesLine.VendorInvoiceDate = lk_SalesOrderIntergationTableline.VendorInvoiceDate;
salesLine.CostPriceWithTax = lk_SalesOrderIntergationTableline.CostPriceWithTax;
salesLine.CostPricewithouttax = lk_SalesOrderIntergationTableline.CostPricewithouttax;
salesLine.SellingPricewithTax = lk_SalesOrderIntergationTableline.SellingPricewithTax;
if (lk_SalesOrderIntergationTableline.ConfirmedShipDate == dateNull())
{
salesLine.ShippingDateConfirmed = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
salesLine.ShippingDateRequested = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
}
else
{
salesLine.ShippingDateConfirmed = lk_SalesOrderIntergationTableline.ConfirmedShipDate;
salesLine.ShippingDateRequested = lk_SalesOrderIntergationTableline.ConfirmedShipDate;
}
if (lk_SalesOrderIntergationTableline.ConfirmedReceiptDate == dateNull())
{
salesLine.ReceiptDateConfirmed = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
salesLine.ReceiptDateRequested = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
}
else
{
salesLine.ReceiptDateConfirmed = lk_SalesOrderIntergationTableline.ConfirmedReceiptDate;
salesLine.ReceiptDateRequested =lk_SalesOrderIntergationTableline.ConfirmedReceiptDate;
}
salesLine.LinePercent = lk_SalesOrderIntergationTableline.LineDiscountPercentage;
if (lk_SalesOrderIntergationTableline.Text)
{
salesLine.Name = lk_SalesOrderIntergationTableline.Text;
}
else
{
salesLine.Name = salesLine.itemName();
}
if (SalesLine.SalesQty < 0)
{
salesLine.LineAmount = abs(salesLine.calcLineAmount()) * -1;
}
else
{
salesLine.LineAmount = salesLine.calcLineAmount();
}
salesLine.CostPrice = lk_SalesOrderIntergationTableline.ReturnCostPrice;
salesLine.LKMagentoItemId = lk_SalesOrderIntergationTableline.MagentoItemId;
salesLine.LKOrgSalesOrderNo = lk_SalesOrderIntergationTableline.SalesOrderNumber;
salesLine.LKOrgSalesOrderLineNo = lk_SalesOrderIntergationTableline.LineNumber;
salesLine.LKSalesOrderItemCode = lk_SalesOrderIntergationTableline.SalesOrderItemCode;
salesLine.LK_GiftVoucher = lk_SalesOrderIntergationTableline.GiftVoucher;
salesLine.LK_CategoryOfProducts = lk_SalesOrderIntergationTableline.CategoryOfProducts;
salesLine.LK_Coverage = lk_SalesOrderIntergationTableline.Coverage;
salesLine.LK_InsuranceProduct = lk_SalesOrderIntergationTableline.InsuranceProduct;
salesLine.LK_WarrantyProduct = lk_SalesOrderIntergationTableline.WarrantyProduct;
salesLine.LK_IssuanceFromDate = lk_SalesOrderIntergationTableline.IssuanceFromDate;
salesLine.LK_IssuanceToDate = lk_SalesOrderIntergationTableline.IssuanceToDate;
salesLine.LK_GoldMembershipNumber = lk_SalesOrderIntergationTableline.GoldMembershipNumber;
salesLine.LK_GoldMembershipType = lk_SalesOrderIntergationTableline.GoldMembershipType;
salesLine.LK_GoldMembershipEndDate = lk_SalesOrderIntergationTableline.GoldMembershipEndDate;
salesLine.LK_GoldMembershipStartDate = lk_SalesOrderIntergationTableline.GoldMembershipStartDate;
salesLine.LK_PurchasePrice = lk_SalesOrderIntergationTableline.PurchasePrice;
if (!SysCountryRegionCode::isLegalEntityInCountryRegion([#isoIN]))
{
salesLine.TaxItemGroup = lk_SalesOrderIntergationTableline.Itemsalestaxgrp;
salesLine.TaxGroup = lk_SalesOrderIntergationTableline.Salestaxgrp;
}
select firstonly SiteId
from inventSite
where inventSite.SiteId == inventDimfind.InventSiteId;
salesLine.DefaultDimension = LK_FinancialDimensionHelper::getDimensionNew(DimensionSetEntity::find(inventTable.DefaultDimension).DisplayValue,
DimensionSetEntity::find(_salesTable.DefaultDimension).DisplayValue,
DimensionSetEntity::find(inventSite.DefaultDimension).DisplayValue,
lk_SalesOrderIntergationTableline.Brand,
lk_SalesOrderIntergationTableline.Classification,
lk_SalesOrderIntergationTableline.CostCenter,
lk_SalesOrderIntergationTableline.NavChannel,
lk_SalesOrderIntergationTableline.SBRT,
lk_SalesOrderIntergationTableline.Store);
salesLine.insert();
if (salesLine)
{
this.updateSalesLine_IN(_salesTable,NoYes::Yes,salesLine.SalesId,lk_SalesOrderIntergationTableline);
this.updateHSNAndSACCode(lk_SalesOrderIntergationTableline,_salesTable);
}
}
}
/// <summary>
/// This method creates on-the-fly item if item does not exist.
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">_lk_SalesOrderIntergationTable</param>
public void createReleasedItem(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
InventTable inventTable;
EcoResProduct ecoResProduct;
EcoResDistinctProduct ecoResDistinctProduct;
EcoResProductTranslation ecoResProductTranslation;
InventItemSetupSupplyType inventItemSetupSupplyType;
ecoResProductIdentifier ecoResProductIdentifier;
#define.Pcs('Pcs')
select firstOnly ecoResProduct
where EcoResProduct.DisplayProductNumber == _lk_SalesOrderIntergationTable.ItemNumber;
if (!ecoResProduct)
{
ecoResDistinctProduct.initValue();
ecoResDistinctProduct.DisplayProductNumber = _lk_SalesOrderIntergationTable.ItemNumber;
ecoResDistinctProduct.SearchName = _lk_SalesOrderIntergationTable.ItemNumber;
if (_lk_SalesOrderIntergationTable.ItemTemplateName == EcoResProductType::Service)
{
ecoResDistinctProduct.ProductType = EcoResProductType::Service;
}
else
{
ecoResDistinctProduct.ProductType = EcoResProductType::Item;
}
if (ecoResDistinctProduct.validateWrite())
{
ecoResDistinctProduct.insert();
ecoResProduct= ecoResDistinctProduct;
ecoResProductIdentifier.clear();
ecoResProductIdentifier.initValue();
ecoResProductIdentifier.ProductNumber = _lk_SalesOrderIntergationTable.ItemNumber;
ecoResProductIdentifier.Product = ecoResDistinctProduct.RecId;
ecoResProductIdentifier.insert();
ecoResProductTranslation.Product = ecoResDistinctProduct.RecId;
ecoResProductTranslation.Name = _lk_SalesOrderIntergationTable.ItemNumber;
EcoResProductTranslation.Description = _lk_SalesOrderIntergationTable.ItemNumber;
ecoResProductTranslation.setDefaultLanguage();
ecoResProductTranslation.insert();
inventTable.clear();
inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProduct);
inventTable.ItemId = _lk_SalesOrderIntergationTable.ItemNumber;
inventTable.NameAlias = ecoResProduct.SearchName;
inventTable.insert(true);
this.inventTableModule(inventTable.ItemId);
//Create inventItemLocation
InventItemLocation::createDefault(inventTable.ItemId);
// Creates a new item default order type for the product that is released.
inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.ItemId = inventTable.ItemId;
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
inventItemSetupSupplyType.insert();
this.applyTemplate(inventTable, _lk_SalesOrderIntergationTable.ItemTemplateNameStr);
}
}
else
{
inventTable.clear();
inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProduct);
inventTable.ItemId = _lk_SalesOrderIntergationTable.ItemNumber;
inventTable.NameAlias = ecoResProduct.SearchName;
inventTable.insert(true);
this.inventTableModule(inventTable.ItemId);
//Create inventItemLocation
InventItemLocation::createDefault(inventTable.ItemId);
// Creates a new item default order type for the product that is released.
inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.ItemId = inventTable.ItemId;
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
inventItemSetupSupplyType.insert();
this.applyTemplate(inventTable, _lk_SalesOrderIntergationTable.ItemTemplateNameStr);
}
}
/// <summary>
/// invent table module
/// </summary>
/// <param name = "_itemid">_itemid</param>
public void inventTableModule(ItemId _itemid)
{
#define.Pcs('Pcs')
inventTableModule inventTableModule;
inventTableModule.initValue();
inventTableModule.ItemId = _itemid;
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
InventTableModule.UnitId = #Pcs;
InventTableModule.Price = 0.0;
inventTableModule.insert();
inventTableModule.initValue();
inventTableModule.ItemId = _itemid;
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
InventTableModule.UnitId = #Pcs;
InventTableModule.Price = 0.0;
inventTableModule.insert();
inventTableModule.initValue();
inventTableModule.ItemId = _itemid;
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
InventTableModule.UnitId = #Pcs;
InventTableModule.Price = 0.0;
inventTableModule.insert();
}
/// <summary>
/// This method is used to apply template for item
/// </summary>
/// <param name = "_inventTable">_inventTable</param>
/// <param name = "_templateName">_templateName</param>
public void applyTemplate(InventTable _inventTable, str _templateName)
{
EcoResProductTemplateApplyManagerUtils utils;
container recordTmpValues;
recordTmpValues = this.getTemplateData(_templateName);
utils = EcoResProductTemplateApplyManagerUtils::newDefault();
utils.applyTemplate(recordTmpValues, _inventTable.ItemId);
}
/// <summary>
/// This is to update HSN, SAC, Financial diemsnions for the item.
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">_lk_SalesOrderIntergationTable</param>
public void updateInventTable(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
InventTable inventTableUpdate;
select firstonly forupdate inventTableUpdate
where inventTableUpdate.ItemId == _lk_SalesOrderIntergationTable.ItemNumber;
if (inventTableUpdate)
{
inventTableUpdate.DefaultDimension = LK_FinancialDimensionHelper::getDimensionForSOItemCreateNew(DimensionSetEntity::find(inventTableUpdate.DefaultDimension).DisplayValue,
'',
'',
_LK_SalesOrderIntergationTable.Brand,
_LK_SalesOrderIntergationTable.Classification,
_LK_SalesOrderIntergationTable.CostCenter,
_LK_SalesOrderIntergationTable.NavChannel,
_LK_SalesOrderIntergationTable.SBRT,
_LK_SalesOrderIntergationTable.Store);
inventTableUpdate.update();
}
}
/// <summary>
/// Template data
/// </summary>
/// <param name = "_templateName">_templateName</param>
/// <returns>container</returns>
public container getTemplateData(str _templateName)
{
SysRecordTemplateTable templateTable;
SysRecordTmpTemplate tmp;
container dataContainer, RecordTmplateData;
int i;
select firstonly templateTable
where templateTable.table == tableNum(inventTable);
dataContainer = templateTable.Data;
for (i=conlen(dataContainer); i; i--)
{
[tmp.Description, tmp.DefaultRecord, tmp.Data, tmp.Details] = conpeek(dataContainer, i);
if (tmp.Description == _templateName)
{
tmp.OrgDescription = tmp.Description;
tmp.insert();
RecordTmplateData=tmp.data;
}
}
return RecordTmplateData;
}
/// <summary>
/// create drop ship
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTableV1">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">salesTable</param>
/// <returns>PurchTable</returns>
//public PurchTable createDropshipPO(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTableV1, SalesTable _salesTable)
//{
// SalesLine salesLine;
// LK_POCreationFromSO purchCreateFromSalesOrder = new LK_POCreationFromSO();
// PurchTable purchTable;
// select firstonly forupdate salesLine
// where salesLine.SalesId == _salesTable.SalesId
// && salesLine.LineNum == _LK_SalesOrderIntergationTableV1.LineNumber;
// if (_LK_SalesOrderIntergationTableV1.DeliveryType == TradeLineDlvType::DropShip && _LK_SalesOrderIntergationTableV1.SourcingVendor && _LK_SalesOrderIntergationTableV1.PurchPriceStr)
// {
// purchTable = purchCreateFromSalesOrder.createPurchOrderFromSalesLine(salesLine, _LK_SalesOrderIntergationTableV1.SourcingVendor, '', _LK_SalesOrderIntergationTableV1.PurchPriceStr);
// salesLine.reread();
// salesLine.DeliveryType = TradeLineDlvType::DropShip;
// salesLine.SourcingVendAccount = _LK_SalesOrderIntergationTableV1.SourcingVendor;
// salesLine.SourcingOrigin = VendTable::find(salesLine.SourcingVendAccount).interCompanyTradingRelationActive() ? SalesSourcingOrigin::Intercompany : SalesSourcingOrigin::ExternalVendor;
// salesLine.update();
// this.updatePurchLine_IN(_salesTable, purchTable);
// if (_salesTable.Fulfillment_WH)
// {
// this.updateVendLocationOnPurchLine(purchTable, _salesTable);
// }
// }
// return purchTable;
//}
/// <summary>
/// This method is to update tcs and tds group of the purch table.
/// </summary>
/// <param name = "_salesTable">SalesTable</param>
/// <param name = "_purchTable">PurchTable</param>
/* public void updatePurchLine_IN(SalesTable _salesTable, PurchTable _purchTable)
{
PurchLine purchLineLoc;
PurchLine_IN purchLine_IN;
while select purchLineLoc
where purchLineLoc.PurchId == _purchTable.PurchId // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
purchLine_IN = purchLineLoc.purchLine_IN();
ttsbegin;
purchLine_IN.selectForUpdate(true);
purchLine_IN.TCSGroup = _salesTable.TCSGroup_IN;
purchLine_IN.TDSGroup = _salesTable.TDSGroup_IN;
purchLine_IN.update();
ttscommit;
}
}*/
/// <summary>
/// update vendor location on back to back order
/// </summary>
/// <param name = "purchTable">purchTable</param>
/// <param name = "_salesTable">_salesTable</param>
/* public void updateVendLocationOnPurchLine(PurchTable purchTable, SalesTable _salesTable)
{
PurchLine purchLine;
LogisticsLocation logisticsLocation;
TransTaxInformation transTaxInformationLocal;
TaxInformation_IN taxInformation_IN;
VendTable vendTable;
DirPartyPostalAddressView addressViewLoc;
while select purchline
where purchline.purchId == purchTable.purchId
{
if (purchline)
{
transTaxInformationLocal = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(purchline, true);
select firstonly Party from vendTable
where vendTable.AccountNum == purchline.VendAccount
join addressViewLoc
where addressViewLoc.Party == vendTable.Party
&& addressViewLoc.LocationName == _salesTable.Fulfillment_WH;
transTaxInformationLocal.VendorLocation = addressViewLoc.Location;
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == addressViewLoc.Location
&& taxInformation_IN.IsPrimary == NoYes::Yes
join logisticsLocation where logisticsLocation.RecId == addressViewLoc.Location;
transTaxInformationLocal.VendorTaxInformation = taxInformation_IN.RecId;
transTaxInformationLocal.update();
}
}
} */
/// <summary>
/// This method is used to create misc. charges for sales order line
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTable">_LK_SalesOrderIntergationTable</param>
/// <param name = "_salesId">_salesId</param>
public void createMiscChargesLinesByList(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTable,SalesId _salesId)
{
SalesLine salesLine;
MarkupTable markupTableLine;
MarkupTrans markupTrans;
LK_SalesOrderIntergationTableV1 lk_SalesOrderIntergationTableMarkUpLines;
RecordInsertList markupTransInsertList = new RecordInsertList(tableNum(markupTrans));
while select lk_SalesOrderIntergationTableMarkUpLines
where lk_SalesOrderIntergationTableMarkUpLines.EntityName == LK_SalesProcessEntityName::MarkupLines
&& lk_SalesOrderIntergationTableMarkUpLines.SalesOrderNumber == _LK_SalesOrderIntergationTable.SalesOrderNumber
join salesLine where salesLine.SalesId == _salesId
&& salesLine.LineNum == lk_SalesOrderIntergationTableMarkUpLines.LineNumber
{
if (salesLine)
{
markupTableLine = MarkupTable::find(MarkupModuleType::Cust, lk_SalesOrderIntergationTableMarkUpLines.SalesChargeCode);
markupTrans.clear();
markupTrans.MarkupCode = markupTableLine.MarkupCode;
markupTrans.initFromSalesLine(salesLine);
markupTrans.initFromMarkupTable(markupTableLine);
markupTrans.initValue();
markupTrans.LineNum = lk_SalesOrderIntergationTableMarkUpLines.ChargeLineNumber;
markupTrans.MarkupCategory = lk_SalesOrderIntergationTableMarkUpLines.ChargeCategory;
markupTrans.CurrencyCode = lk_SalesOrderIntergationTableMarkUpLines.CurrencyCode ? lk_SalesOrderIntergationTableMarkUpLines.CurrencyCode : "@LK_Label:CurrencyUSD"; // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
markupTrans.Value = lk_SalesOrderIntergationTableMarkUpLines.FixedChargeAmount;
markupTrans.Keep = NoYes::Yes;
markupTrans.TaxGroup = lk_SalesOrderIntergationTableMarkUpLines.SalesTaxGroupCode;
markupTrans.TaxItemGroup = lk_SalesOrderIntergationTableMarkUpLines.SalesTaxItemGroupCode;
markupTransInsertList.add(markupTrans);
}
}
markupTransInsertList.insertDatabase();
}
/// <summary>
/// This method is used for Misc. Charges on header level.
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTable">_LK_SalesOrderIntergationTable</param>
/// <param name = "_salesTable">_salesTable</param>
/// <param name = "_allocateAfter">MarkupAllocateAfter</param>
public void createMiscChargesHeaderByList(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTable, SalesTable _salesTable, MarkupAllocateAfter _allocateAfter = MarkupAllocateAfter::NetAmount)
{
MarkupTable markupTable;
MarkupTrans markupTrans;
LK_SalesOrderIntergationTableV1 lk_SalesOrderIntergationTableMarkupHeader;
RecordInsertList markupTransInsertListHeader = new RecordInsertList(tableNum(markupTrans));
while select lk_SalesOrderIntergationTableMarkupHeader
where lk_SalesOrderIntergationTableMarkupHeader.SalesOrderNumber == _LK_SalesOrderIntergationTable.SalesOrderNumber
&& lk_SalesOrderIntergationTableMarkupHeader.EntityName == LK_SalesProcessEntityName::MarkupHeader
{
if (_salesTable && lk_SalesOrderIntergationTableMarkupHeader)
{
markupTable = MarkupTable::find(MarkupModuleType::Cust, lk_SalesOrderIntergationTableMarkupHeader.SalesChargeCode);
markupTrans.clear();
markupTrans.MarkupCode = markupTable.MarkupCode;
markupTrans.initFromSalesTable(_salesTable);
markupTrans.initFromMarkupTable(markupTable);
markupTrans.initValue();
markupTrans.LineNum = lk_SalesOrderIntergationTableMarkupHeader.ChargeLineNumber;
markupTrans.MarkupCategory = lk_SalesOrderIntergationTableMarkupHeader.ChargeCategory;
markupTrans.CurrencyCode = lk_SalesOrderIntergationTableMarkupHeader.CurrencyCode ? lk_SalesOrderIntergationTableMarkupHeader.CurrencyCode : "@LK_Label:CurrencyUSD";
markupTrans.Value = lk_SalesOrderIntergationTableMarkupHeader.FixedChargeAmount;
markupTrans.Keep = NoYes::Yes;
markupTrans.TaxGroup = lk_SalesOrderIntergationTableMarkupHeader.SalesTaxGroupCode;
markupTrans.TaxItemGroup = lk_SalesOrderIntergationTableMarkupHeader.SalesTaxItemGroupCode;
markupTransInsertListHeader.add(markupTrans);
}
}
markupTransInsertListHeader.insertDatabase();
}
/* public void updateTDSandTCSGroupOrigSO(SalesTable _salesTable)
{
SalesTable salesTableOrg;
SalesLine salesLineOrg;
SalesLine_IN salesLine_IN;
select forupdate firstonly salesTableOrg
where salesTableOrg.SalesId == _salesTable.InterCompanyOriginalSalesId
&& salesTableOrg.DataAreaId == _salesTable.InterCompanyCompanyId;
if (salesTableOrg)
{
salesTableOrg.TDSGroup_IN = _salesTable.TDSGroup_IN;
salesTableOrg.TCSGroup_IN = _salesTable.TCSGroup_IN;
salesTableOrg.update();
while select salesLineOrg
where salesLineOrg.DataAreaId == _salesTable.InterCompanyCompanyId
&& salesLineOrg.SalesId == _salesTable.SalesId
{
salesLine_IN = salesLineOrg.salesLine_IN();
salesLine_IN.selectForUpdate(true);
salesLine_IN.TCSGroup = _salesTable.TCSGroup_IN;
salesLine_IN.TDSGroup = _salesTable.TDSGroup_IN;
salesLine_IN.update();
}
}
} */
public void settleprePaymentMarking(str _salesId)
{
LedgerJournalTable ledgerjournalTable;
CustTrans custtrans;
CustTransOpen custTransOpen;
LedgerJournaltrans ledgerjournalTrans;
specTransManager specTransManager;
SalesTable salesTable;
DimensionDynamicAccount dimensionDynamicAccount;
select firstonly salesTable
where salesTable.CustomerRef == _salesId;
if (salesTable && salesTable.CustomerRef)
{
dimensionDynamicAccount = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(salesTable.CustAccount, LedgerJournalACType::Cust);
select firstonly JournalNum from ledgerjournalTrans
where ledgerjournalTrans.DocumentNum == salesTable.CustomerRef
&& ledgerjournalTrans.LedgerDimension == dimensionDynamicAccount
&& ledgerjournalTrans.Prepayment == NoYes::Yes;
ledgerjournalTable = ledgerjournalTable::find(ledgerjournalTrans.JournalNum);
if (ledgerjournalTrans && ledgerjournalTable.Posted == NoYes::Yes)
{
specTransManager = SpecTransManager::newFromSpec(salesTable);
select firstonly custTransOpen
join custTrans
where custTransOpen.AccountNum == custTrans.AccountNum
&& custTransOpen.RefRecId == custTrans.RecId
&& custtrans.RecId == ledgerjournalTrans.CustTransId;
if (custTransOpen)
{
specTransManager.insert(
custTransOpen.company(),
custTransOpen.TableId,
custTransOpen.RecId,
custTransOpen.AmountCur,
ledgerjournalTrans.CurrencyCode);
ttsBegin;
salesTable.selectForUpdate(true);
salesTable.SettleVoucher = SettlementType::SelectedTransact;
salesTable.update();
ttscommit;
}
}
}
}
/// <summary>
/// this method use to ettle Exchange Marking
/// </summary>
/// <param name = "_salesId">_salesId</param>
public void settleExchangeMarking(str _salesId)
{
CustTrans custtrans;
CustTransOpen custTransOpen;
CustInvoiceJour custInvoiceJour;
specTransManager specTransManager;
SalesTable salesTable;
select firstonly salesTable
where salesTable.CustomerRef == _salesId;
if (salesTable && salesTable.LK_RefInvoiceNo)
{
select firstonly InvoiceId,InvoiceAccount,InvoiceDate,LedgerVoucher from custInvoiceJour
where custInvoiceJour.LK_SalesInvoiceNo == salesTable.LK_RefInvoiceNo
&& custInvoiceJour.InvoiceAccount == salesTable.CustAccount;
if (custInvoiceJour)
{
select firstonly AccountNum,RecId from custtrans
where custtrans.Invoice == custInvoiceJour.InvoiceId
&& custtrans.AccountNum == custInvoiceJour.InvoiceAccount
&& custtrans.TransDate == custInvoiceJour.InvoiceDate
&& custtrans.Voucher == custInvoiceJour.LedgerVoucher;
specTransManager = SpecTransManager::newFromSpec(salesTable);
select firstonly custTransOpen
where custTransOpen.AccountNum == custTrans.AccountNum
&& custTransOpen.RefRecId == custTrans.RecId;
if (custTransOpen)
{
specTransManager.insert(
custTransOpen.company(),
custTransOpen.TableId,
custTransOpen.RecId,
custTransOpen.AmountCur,
custInvoiceJour.CurrencyCode);
ttsBegin;
salesTable.selectForUpdate(true);
salesTable.SettleVoucher = SettlementType::SelectedTransact;
salesTable.update();
ttscommit;
}
}
}
}
/// <summary>
/// Updaet interCompany Sales Line
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTableV1">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">salesTable</param>
/* public void updateIntercompanySalesLine(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTableV1, SalesTable _salesTable)
{
SalesLine salesLine;
InventDim inventDimLines, inventDimfind;
InventLocation inventLocation;
int linenum = 1;
TransTaxInformation transTaxInformationSale;
TaxRateType taxRateType;
LogisticsLocation logisticsLocation;
LogisticsEntityPostalAddressView postalAddressView;
TaxInformation_IN taxInformation_IN;
select firstonly forupdate salesLine
where salesLine.SalesId == _salesTable.SalesId
&& salesLine.LineNum == _LK_SalesOrderIntergationTableV1.LineNumber;
if (salesLine)
{
transTaxInformationSale = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine,true);
if (transTaxInformationSale)
{
inventLocation = inventLocation::find(_salesTable.Fulfillment_WH);
if (inventLocation)
{
select firstonly Location from postalAddressView
where postalAddressView.Entity == inventLocation.RecId
&& postalAddressView.EntityType == LogisticsLocationEntityType::Warehouse
&& postalAddressView.isPrimary == NoYes::Yes
join RecId from logisticsLocation where logisticsLocation.RecId == postalAddressView.Location;
if (logisticsLocation.RecId)
{
transTaxInformationSale.CompanyLocation = logisticsLocation.RecId;
}
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == logisticsLocation.RecId
&& taxInformation_IN.IsPrimary == NoYes::Yes;
if (taxInformation_IN.RecId)
{
transTaxInformationSale.TaxInformation = taxInformation_IN.RecId;
transTaxInformationSale.GSTIN = taxInformation_IN.GSTIN;
}
//// END
select firstonly RecId from taxRateType
where taxRateType.Name == _LK_SalesOrderIntergationTableV1.TaxRateType;
transTaxInformationSale.TaxRateType = taxRateType.RecId;
transTaxInformationSale.update();
}
}
salesLine.LKSalesType = _salesTable.LKSalesType;
salesLine.LKMagentoItemId = _LK_SalesOrderIntergationTableV1.MagentoItemId;
salesLine.LKOrgSalesOrderNo = _LK_SalesOrderIntergationTableV1.SalesOrderNumber;
salesLine.LKOrgSalesOrderLineNo = _LK_SalesOrderIntergationTableV1.LineNumber;
salesLine.LKSalesOrderItemCode = _LK_SalesOrderIntergationTableV1.ItemNumber;
if (_salesTable.LKSalesType == SalesType::ReturnItem)
{
salesLine.LK_Refrence_WH = _LK_SalesOrderIntergationTableV1.ReferenceWH;
}
// code added by PAnkaj - 12-10-2023- Start
if (_salesTable.Fulfillment_WH)
{
inventDimfind.InventSiteId = _salesTable.InventSiteId;
inventDimfind.InventLocationId = _salesTable.InventLocationId;
inventDimLines = InventDim::findOrCreate(inventDimfind);
salesLine.InventDimId = inventDimLines.inventDimId;
}
//END
salesLine.LK_CardNo = _LK_SalesOrderIntergationTableV1.CardNo;
salesLine.LK_TxnId = _LK_SalesOrderIntergationTableV1.TxnId;
salesLine.update();
linenum++;
}
}*/
/// <summary>
/// updateIntecompanySalesOrder
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTableV1">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">salesTable</param>
//public void updateIntecompanySalesOrder(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTableV1,SalesTable _salesTable)
//{
// SalesTable locSalesTable;
// ttsbegin;
// select firstonly forupdate locSalesTable
// where locSalesTable.InterCompanyOriginalSalesId == _salesTable.SalesId;
// if (locSalesTable)
// {
// locSalesTable.LKSalesType = _salesTable.LKSalesType;
// locSalesTable.LKCourierCode = _salesTable.LKCourierCode;
// locSalesTable.LKModeOfPayment = _salesTable.LKModeOfPayment;
// locSalesTable.LKOrderCreationDate = _salesTable.LKOrderCreationDate;
// locSalesTable.LKWebOrderNo = _salesTable.LKWebOrderNo;
// locSalesTable.Fulfillment_WH = _LK_SalesOrderIntergationTableV1.Fulfillment_WH; // code added by PAnkaj on 19-10-2023
// if (locSalesTable.Fulfillment_WH)
// {
// locSalesTable.InventLocationId = _LK_SalesOrderIntergationTableV1.Fulfillment_WH;
// locSalesTable.InventSiteId = InventLocation::find(_LK_SalesOrderIntergationTableV1.Fulfillment_WH).InventSiteId;
// }
// locSalesTable.update();
// this.updateIntercompanySalesLine(_LK_SalesOrderIntergationTableV1, locSalesTable);
// }
// ttscommit;
//}
/// <summary>
/// Intercompany location has update by Rutika 2/8/2022
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTableV1">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">SalesTable</param>
/* public void purchline_TaxLocationUpdate(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTableV1,SalesTable _salesTable)
{
PurchLine purchline;
int linenum = 1;
TransTaxInformation transTaxInformationLocal;
TransTaxInformation transTaxInformationSales;
LogisticsLocation logisticsLocation;
LogisticsEntityPostalAddressView postalAddressView;
PurchTable purchTable;
boolean updateIntegration = false;
TaxRateType taxRateType;
ServiceAccountingCodeTable_IN sacTable;
SalesLine salesLine;
TaxInformation_IN taxInformation_IN;
InventDim inventDimLines, inventDimfind;
DirPartyPostalAddressView addressView1;
VendTable vendTable;
str store;
CustTable custable;
HSNCodeTable_IN hsnCode_In;
PurchTable_W purchTable_w;
PurchLine_IN purchLine_IN;
InventLocation inventLocation;
//update integration yes in case of intercompany purchase order
if (_salesTable.InterCompanyCompanyId && !_salesTable.InterCompanyOriginalSalesId && _salesTable.InterCompanyPurchId) // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
updateIntegration = true;
}
if (!_salesTable.InterCompanyCompanyId) // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
return;
}
changecompany (_salesTable.InterCompanyCompanyId) // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
// code added for intercomany connection.
purchtable = null;
select firstonly crosscompany purchTable
where purchTable.DataAreaId == _salesTable.InterCompanyCompanyId
&& purchTable.PurchId == _salesTable.InterCompanyPurchId;
if (purchTable)
{
//update integration yes in case of intercompany purchase order
if (updateIntegration)
{
purchTable.selectForUpdate(true);
purchTable.LK_Integration = NoYes::Yes;
// Codded added by Pankaj - 12-10-2023 - Start
purchTable.InventLocationId = _salesTable.InventLocationId;
purchTable.InventSiteId = _salesTable.InventSiteId;
//End
//Code added by vinay start on 2/4/2024
purchTable.doUpdate();
select firstonly forupdate purchTable_w
where purchTable_w.PurchTable == purchTable.RecId;
if (purchTable_w && _LK_SalesOrderIntergationTableV1.TDSgroup != '' )
{
purchTable_w.TDSGroup_IN = _salesTable.TDSGroup_IN;
}
else if (purchTable_w && _LK_SalesOrderIntergationTableV1.TCSgroup != '')
{
purchTable_w.TCSGroup_IN = _salesTable.TCSGroup_IN;
}
purchTable_w.update();
///Code end by vinay on 2/4/2024
}
select firstonly forupdate purchline
where purchline.purchId == purchTable.purchId
&& purchline.LineNumber == real2int(linenum);
if (purchline)
{
// Codded added by Pankaj - 12-10-2023 - Start
inventDimfind.InventSiteId = InventLocation::find(_LK_SalesOrderIntergationTableV1.Store).InventSiteId;
if (!_LK_SalesOrderIntergationTableV1.store)
{
inventDimfind.InventSiteId = InventLocation::find(_LK_SalesOrderIntergationTableV1.InventSiteId).InventSiteId;
}
inventDimfind.InventLocationId = _LK_SalesOrderIntergationTableV1.InventLocationId;
inventDimLines = InventDim::findOrCreate(inventDimfind);
purchline.LineNumber = real2int(_LK_SalesOrderIntergationTableV1.LineNumber);
purchline.InventDimId = inventDimLines.inventDimId;
purchline.update();
// End
transTaxInformationLocal = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(purchline, true);
select firstonly taxRateType where taxRateType.Name == _LK_SalesOrderIntergationTableV1.TaxRateType;
transTaxInformationLocal.TaxRateType = taxRateType.RecId;
if (_LK_SalesOrderIntergationTableV1.HSNCode)
{
select firstonly RecId from hsnCode_In
where hsncode_in.Code == _LK_SalesOrderIntergationTableV1.HSNCode;
if (hsnCode_In.RecId)
{
transTaxInformationLocal.HSNCodeTable = hsnCode_In.RecId;
}
}
if (_LK_SalesOrderIntergationTableV1.SACCode)
{
select firstonly RecId from sacTable
where sacTable.SAC == _LK_SalesOrderIntergationTableV1.SACCode;
if (sacTable.RecId)
{
transTaxInformationLocal.ServiceAccountingCodeTable = sacTable.RecId;
}
}
///Code end by vinay on 2/4/2024 for purchline hsn
if (_LK_SalesOrderIntergationTableV1.Store)
{
inventLocation = inventLocation::find(_LK_SalesOrderIntergationTableV1.Store);
if (inventLocation)
{
select firstonly Location from postalAddressView
where postalAddressView.Entity == inventLocation.RecId
&& postalAddressView.LocationName == _LK_SalesOrderIntergationTableV1.InventLocationId
&& postalAddressView.EntityType == LogisticsLocationEntityType::Warehouse
&& postalAddressView.isPrimary == NoYes::Yes;
transTaxInformationLocal.CompanyLocation = postalAddressView.Location;
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == postalAddressView.Location
&& taxInformation_IN.IsPrimary == NoYes::Yes
join logisticsLocation where logisticsLocation.RecId == postalAddressView.Location;
transTaxInformationLocal.TaxInformation = taxInformation_IN.RecId;
}
select firstonly Party from vendTable
where vendTable.AccountNum == purchline.VendAccount;
select firstonly Location from addressView1
where addressView1.Party == vendTable.Party
&& addressView1.LocationName == _LK_SalesOrderIntergationTableV1.InventLocationId;
transTaxInformationLocal.VendorLocation = addressView1.Location;
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == addressView1.Location
&& taxInformation_IN.IsPrimary == NoYes::Yes
join logisticsLocation where logisticsLocation.RecId == addressView1.Location;
transTaxInformationLocal.VendorTaxInformation = taxInformation_IN.RecId;
store = _LK_SalesOrderIntergationTableV1.store;
}
//code added by vinay on 2/4/2024
while select purchline
where purchline.PurchId == purchTable.PurchId
{
purchLine_IN = purchline.purchLine_IN();
ttsbegin;
purchLine_IN.selectForUpdate(true);
purchLine_IN.TCSGroup = purchTable_w.TCSGroup_IN;
purchLine_IN.TDSGroup = purchTable_w.TDSGroup_IN;
purchLine_IN.update();
ttscommit;
}
addressView1.clear();
taxInformation_IN.clear();
logisticsLocation.clear();
salesLine = purchline.interCompanySalesLine();
if (salesLine)
{
changecompany (salesLine.DataAreaId)
{
transTaxInformationSales = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine, true);
if (store)
{
select firstonly Party from custable
where custable.AccountNum == salesLine.CustAccount;
select firstonly Location from addressView1
where addressView1.Party == custable.Party
&& addressView1.LocationName == store;
transTaxInformationSales.CustomerLocation = addressView1.Location;
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == addressView1.Location
&& taxInformation_IN.IsPrimary == NoYes::Yes
join logisticsLocation where logisticsLocation.RecId == addressView1.Location;
transTaxInformationSales.CustomerTaxInformation = taxInformation_IN.RecId;
transTaxInformationSales.update();
}
}
store = '';
}
transTaxInformationLocal.update();
linenum++;
}
}
}
} */
/// <summary>
/// update sales order
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesId">_salesId</param>
/* public void updateSalesOrder(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTable,SalesIdBase _salesId)
{
InventDim inventDimLines, inventDimfind;
SalesLine salesLine;
TransTaxInformation transTaxInformationSales;
LogisticsLocation logisticsLocation;
str store;
CustTable custable;
TaxInformation_IN taxInformation_IN;
DirPartyPostalAddressView addressView1;
select firstonly forupdate salesLine
where salesLine.SalesId == _salesId
&& salesLine.ItemId == _LK_SalesOrderIntergationTable.ItemNumber
&& salesLine.LineNum == _LK_SalesOrderIntergationTable.LineNumber;
if (salesLine)
{
inventDimfind.InventSiteId = _LK_SalesOrderIntergationTable.InventSiteId;
if (!_LK_SalesOrderIntergationTable.InventSiteId)
{
inventDimfind.InventSiteId = InventLocation::find(_LK_SalesOrderIntergationTable.InventLocationId).InventSiteId;
}
inventDimfind.InventLocationId = _LK_SalesOrderIntergationTable.InventLocationId;
inventDimLines = InventDim::findOrCreate(inventDimfind);
salesLine.InventDimId = inventDimLines.inventDimId;
salesLine.update();
store = _LK_SalesOrderIntergationTable.store;
transTaxInformationSales = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine, true);
if (store)
{
select firstonly Party from custable
where custable.AccountNum == salesLine.CustAccount
join Location from addressView1
where addressView1.Party == custable.Party
&& addressView1.LocationName == store;
transTaxInformationSales.CustomerLocation = addressView1.Location;
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == addressView1.Location
&& taxInformation_IN.IsPrimary == NoYes::Yes
join logisticsLocation where logisticsLocation.RecId == addressView1.Location;
transTaxInformationSales.CustomerTaxInformation = taxInformation_IN.RecId;
transTaxInformationSales.update();
}
}
} */
/// <summary>
/// This method is used to update HSN and SAC code
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">lk_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">SalesTable</param>
public void updateHSNAndSACCode(lk_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable, SalesTable _salesTable)
{
SalesLine salesLine;
TransTaxInformation transTaxInformationLocal;
HSNCodeTable_IN hSNCodeTable_INFind;
ServiceAccountingCodeTable_IN serviceAccountingCodeTable_INFind;
TaxRateType taxRateType;
InventTable inventTable;
EcoResProduct ecoResProduct;
select firstonly salesLine
where salesLine.SalesId == _salesTable.SalesId
&& salesLine.LineNum == _lk_SalesOrderIntergationTable.LineNumber;
if (salesLine)
{
transTaxInformationLocal = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine, true);
if (transTaxInformationLocal)
{
select firstonly ProductType from ecoResProduct
join inventTable where ecoResProduct.RecId == inventTable.Product
&& inventTable.ItemId == salesLine.ItemId;
if (ecoResProduct.ProductType == EcoResProductType::Service)
{
select firstonly RecId
from serviceAccountingCodeTable_INFind
where serviceAccountingCodeTable_INFind.SAC == _lk_SalesOrderIntergationTable.SACCode;
if (serviceAccountingCodeTable_INFind.RecId)
{
transTaxInformationLocal.ServiceAccountingCodeTable = serviceAccountingCodeTable_INFind.RecId;
}
}
else
{
select firstonly RecId
from hSNCodeTable_INFind
where hSNCodeTable_INFind.Code == _lk_SalesOrderIntergationTable.HSNCode;
transTaxInformationLocal.HSNCodeTable = hSNCodeTable_INFind.RecId;
}
select firstonly RecId
from taxRateType
where taxRateType.Name == _lk_SalesOrderIntergationTable.TaxRateType;
if (taxRateType.RecId)
{
transTaxInformationLocal.TaxRateType = taxRateType.RecId;
}
transTaxInformationLocal.doUpdate();
}
}
}
/// <summary>
/// Validating Record
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <returns>str</returns>
public str validatedata(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
str retStr;
Currency currency;
CustPaymModeTable custPaymModeTable;
TaxWithholdGroupHeading taxWithholdGroupHeading;
InventLocation inventLocationFind;//inventLocationFind1;
/* InterCompanyTradingPartner interCompanyTradingPartner,interCompanyTradingPartner1;
InterCompanyTradingRelation interCompanyTradingRelation;
VendTable vendTable;*/
SalesType salesType;
PaymTerm paymTerm;
DlvMode dlvMode;
LK_SalesOrderIntergationTableV1 lk_SalesOrderIntergationTable;
salesTable salesTable;
while select lk_SalesOrderIntergationTable
where lk_SalesOrderIntergationTable.SalesOrderNumber == _lk_SalesOrderIntergationTable.SalesOrderNumber
{
select firstonly CustomerRef from salesTable
where salesTable.CustomerRef == lk_SalesOrderIntergationTable.SalesOrderNumber;
if (salesTable.CustomerRef)
{
throw Error(strFmt("@LK_Label:LKSOCustRefErr", salesTable.CustomerRef, lk_SalesOrderIntergationTable.SalesOrderNumber));
}
if (lk_SalesOrderIntergationTable.InventLocationId!= '')
{
select firstonly InventLocationId
from inventLocationFind
where inventLocationFind.InventLocationId == lk_SalesOrderIntergationTable.InventLocationId;
if (!inventLocationFind)
{
retStr += "@LK_Label:LK_WarehouseNotExist";
}
}
if (!lk_SalesOrderIntergationTable.EntityName)
{
retStr += "@LK_Label:LK_EntityNameNotFound" + ';';
}
if (lk_SalesOrderIntergationTable.TCSgroup)
{
select firstonly TaxWithholdGroupName, TaxWithholdGroup
from taxWithholdGroupHeading
where (taxWithholdGroupHeading.TaxWithholdGroupName == lk_SalesOrderIntergationTable.TCSGroup
|| taxWithholdGroupHeading.TaxWithholdGroup == lk_SalesOrderIntergationTable.TCSGroup);
if (!taxWithholdGroupHeading.TaxWithholdGroupName || !taxWithholdGroupHeading.TaxWithholdGroup)
{
retStr += "@LK_Label:LK_TCSGrpError"+ ';';
}
}
if (lk_SalesOrderIntergationTable.TermsOfPayment)
{
select firstonly PaymTermId, Cash
from paymTerm
where paymTerm.PaymTermId == lk_SalesOrderIntergationTable.TermsOfPayment;
if (paymTerm.PaymTermId)
{
if (paymTerm.Cash == NoYes::Yes)
{
if (lk_SalesOrderIntergationTable.ModeOfDelivery)
{
select firstonly Code from dlvMode where dlvMode.Code == lk_SalesOrderIntergationTable.ModeOfDelivery;
if (!dlvMode.Code)
{
retStr += "@LK_Label:LK_ModeOfDeliveryDoesNotExist"+ ';';
}
}
else
{
//Mode of delivery not exist.
retStr += "@LK_Label:ModeOfDelivery"+ ';';
}
}
}
else
{
//Term of payment not exist.
retStr += "@LK_Label:LK_TermOfPaymentDoesNotExist"+ ';';
}
}
if (lk_SalesOrderIntergationTable.ModeOfPayment)
{
select firstonly Name, PaymMode
from custPaymModeTable
where (custPaymModeTable.Name == lk_SalesOrderIntergationTable.MethodOfPayment
|| custPaymModeTable.PaymMode == lk_SalesOrderIntergationTable.MethodOfPayment);
if (lk_SalesOrderIntergationTable.ModeOfPayment)
{
if (!custPaymModeTable.Name || !custPaymModeTable.PaymMode)
{
retStr += "@LK_Label:LK_ModeOfPaymentErrS"+ ';';
}
}
}
if (lk_SalesOrderIntergationTable.CurrencyCode)
{
select firstonly CurrencyCode
from currency
where currency.CurrencyCode == lk_SalesOrderIntergationTable.CurrencyCode;
if (!currency.CurrencyCode)
{
retStr += "@LK_Label:LK_SalesCurrencyErrors"+ ';';
}
}
if (!lk_SalesOrderIntergationTable.OrderType)
{
retStr += strFmt("@LK_Label:SalesTypedoesnotexist",lk_SalesOrderIntergationTable.OrderType) + ';';
}
else
{
if (lk_SalesOrderIntergationTable.OrderType != SalesType::Sales)
{
if( lk_SalesOrderIntergationTable.OrderType!= SalesType::ReturnItem )
{
retStr += strFmt("@LK_Label:SalesTypedoesnotexist",lk_SalesOrderIntergationTable.OrderType) + ';';
}
}
}
/* select firstonly AccountNum,DataAreaId,Party
from vendTable
where vendTable.AccountNum == _LK_SalesOrderIntergationTableV1Staging.SourcingVendor
join interCompanyTradingPartner
where interCompanyTradingPartner.VendorDataAreaId == vendTable.DataAreaId
&& interCompanyTradingPartner.VendorParty == vendTable.Party;
if (ret && vendTable)
{
select firstonly InterCompanyTradingVendor
from interCompanyTradingRelation
where interCompanyTradingRelation.InterCompanyTradingVendor == interCompanyTradingPartner.RecId;
select firstonly RecId
from interCompanyTradingPartner1
where interCompanyTradingPartner1.RecId == interCompanyTradingRelation.InterCompanyTradingCustomer;
if (interCompanyTradingPartner1)
{
changecompany (interCompanyTradingPartner1.CustomerDataAreaId)
{
select firstonly crosscompany inventLocationFind1
where inventLocationFind1.InventLocationId == this.InventLocationId
&& inventLocationFind1.DataAreaId == interCompanyTradingPartner1.CustomerDataAreaId;
if (!inventLocationFind1 && interCompanyTradingPartner1.CustomerDataAreaId != '')
{
ret = checkFailed(strFmt(literalStr("@LK_Label:WarehouseNotFoundinDataAreaId"), this.InventLocationId, inventLocationFind1.DataAreaId));
}
}
}
} */
}
return retStr;
}
/// <summary>
/// Creating sales order
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <returns>SalesTable</returns>
Public SalesTable CreateSalesOrder(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTable)
{
SalesTable salesTable;
custTable custTable;
SalesTable_W salesTable_W;
custPaymModeTable custPaymModeTable;
InventLocation inventLocation;
InventSite inventSite;
NumberSeq numberSeqSO;
LK_SalesOrderIntegrationEntityHelper lk_SalesOrderIntegrationEntityHelper = new LK_SalesOrderIntegrationEntityHelper();
select firstonly CustomerRef from salesTable
where salesTable.CustomerRef == _LK_SalesOrderIntergationTable.SalesOrderNumber;
if (salesTable.CustomerRef)
{
throw Error(strFmt("@LK_Label:LKSOCustRefErr", salesTable.CustomerRef, _LK_SalesOrderIntergationTable.SalesOrderNumber));
}
salesTable.clear();
custTable = CustTable::find(_LK_SalesOrderIntergationTable.CustomerAccount);
if (!custTable)
{
lk_SalesOrderIntegrationEntityHelper.CreateCustForSO(_LK_SalesOrderIntergationTable, lk_SalesOrderIntegrationEntityHelper);
}
salesTable.LK_E_Invoicing = _LK_SalesOrderIntergationTable.isIntegrated;
salesTable.CustomerRef = _LK_SalesOrderIntergationTable.SalesOrderNumber;
salesTable.LK_IRNCode = _LK_SalesOrderIntergationTable.IRNCode;
numberSeqSO = NumberSeq::newGetNum(SalesParameters::numRefSalesId(), true);
salesTable.SalesId = numberSeqSO.num();
salesTable.initValue();
salesTable.CustAccount = _LK_SalesOrderIntergationTable.CustomerAccount;
salesTable.initFromCustTable();
salesTable.TCSGroup_IN = _LK_SalesOrderIntergationTable.TCSGroup;
salesTable.LKSalesType = _LK_SalesOrderIntergationTable.OrderType;
if (salesTable.LKSalesType == SalesType::ReturnItem)
{
salesTable.ReturnItemNum = _LK_SalesOrderIntergationTable.RMANumber;
}
SalesTable.CustomsExportOrder_IN = _LK_SalesOrderIntergationTable.ExportOrder;
salesTable.ExportReason = _LK_SalesOrderIntergationTable.ExportReason;
salesTable.CurrencyCode = _LK_SalesOrderIntergationTable.CurrencyCode;
salesTable.TDSGroup_IN = _LK_SalesOrderIntergationTable.TDSGroup;
salesTable.DeliveryName = _LK_SalesOrderIntergationTable.DeliveryName;
salesTable.DlvMode = _LK_SalesOrderIntergationTable.DlvMode;
salesTable.Payment = _LK_SalesOrderIntergationTable.TermsOfPayment;
salesTable.LKWebOrderNo = _LK_SalesOrderIntergationTable.WebOrderNo;
salesTable.ContactPersonId = _LK_SalesOrderIntergationTable.ContactPersonId;
salesTable.LK_CustomerReference = _LK_SalesOrderIntergationTable.CustomerReference;
salesTable.Fulfillment_WH = _LK_SalesOrderIntergationTable.Fulfillment_WH;
salesTable.LK_ConsumableItem = _LK_SalesOrderIntergationTable.ConsumableItem;
select firstonly PaymMode from custPaymModeTable
where custPaymModeTable.Name == _LK_SalesOrderIntergationTable.MethodOfPayment;
if (custPaymModeTable)
{
salesTable.PaymMode = custPaymModeTable.PaymMode;
}
salesTable.InvoiceAccount = _LK_SalesOrderIntergationTable.InvoiceAccount;
salesTable.Phone = _LK_SalesOrderIntergationTable.Phone;
salesTable.Email = _LK_SalesOrderIntergationTable.Email;
salesTable.LKCourierCode = _LK_SalesOrderIntergationTable.CourierCode;
salesTable.LKModeOfPayment = _LK_SalesOrderIntergationTable.ModeOfPayment;
salesTable.InventLocationId = _LK_SalesOrderIntergationTable.InventLocationId;
select firstonly InventSiteId from inventLocation
where inventLocation.InventLocationId == _LK_SalesOrderIntergationTable.InventLocationId;
salesTable.InventSiteId = inventLocation.InventSiteId;
if (_LK_SalesOrderIntergationTable.OrderCreationDate == dateNull())
{
salesTable.LKOrderCreationDate = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
}
else
{
salesTable.LKOrderCreationDate = _LK_SalesOrderIntergationTable.OrderCreationDate;
}
if (_LK_SalesOrderIntergationTable.DeliveryName
&& _LK_SalesOrderIntergationTable.AddressCountryRegionId
&& _LK_SalesOrderIntergationTable.AddressStreet
&& _LK_SalesOrderIntergationTable.AddressState
&& _LK_SalesOrderIntergationTable.AddressCity
&& _LK_SalesOrderIntergationTable.AddressZipCode)
{
salesTable.DeliveryPostalAddress = lk_SalesOrderIntegrationEntityHelper.setDeliveryAddress(_LK_SalesOrderIntergationTable);
}
else
{
salesTable.DeliveryPostalAddress = custTable.postalAddressRecId();
}
salesTable.LK_RefInvoiceNo = _LK_SalesOrderIntergationTable.RefInvoiceNo;
select firstonly DefaultDimension from inventSite
where inventSite.SiteId == salesTable.InventSiteId;
salesTable.DefaultDimension = LK_FinancialDimensionHelper::getDimensionNew('',
DimensionSetEntity::find(custTable.DefaultDimension).DisplayValue,
DimensionSetEntity::find(inventSite.DefaultDimension).DisplayValue,
_LK_SalesOrderIntergationTable.Brand,
_LK_SalesOrderIntergationTable.Classification,
_LK_SalesOrderIntergationTable.CostCenter,
_LK_SalesOrderIntergationTable.NavChannel,
_LK_SalesOrderIntergationTable.SBRT,
_LK_SalesOrderIntergationTable.Store);
salesTable.LK_Integration = NoYes::Yes;
salesTable.insert();
if (SalesTable.CustomsExportOrder_IN == NoYes::Yes) // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
select firstonly forupdate WithIGSTPayment_IN from salesTable_W
where salesTable_W.SalesTable == salesTable.RecId;
if (salesTable_W.SalesTable) // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
salesTable_W.WithIGSTPayment_IN = _LK_SalesOrderIntergationTable.IsWithTax;
salesTable_W.update();
}
}
return salesTable;
}
/// <summary>
/// updateTaxInfoLocation
/// </summary>
/// <param name = "_salesTable">SalesTable</param>
/// <param name = "_purchTable">PurchTable</param>
/// <param name = "_dataAreaid">str</param>
/* public void updateTaxInfoLocation(SalesTable _salesTable, PurchTable _purchTable, str _dataAreaid)
{
TaxInformation_IN taxInformation_IN;
TransTaxInformation transTaxInformationSales, transTaxInformationPurch;
SalesLine salesLine;
PurchLine purchLine;
LogisticsLocation logisticsLocation;
str locationCode, hsnCode,sacCode;
HSNCodeTable_IN hsnCodeTable;
ServiceAccountingCodeTable_IN serviceAccountingCodeTable_IN;
TaxRateType taxrateType;
str taxrate;
changecompany (_dataAreaid)
{
while select purchLine
where purchLine.PurchId == _purchTable.PurchId
&& purchLine.DataAreaId == _dataAreaid
{
hsnCode = '';
locationCode = '';
transTaxInformationPurch = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(purchLine);
taxrate = TaxrateType::find(transTaxInformationPurch.TaxRateType).Name;
sacCode = '';
if (transTaxInformationPurch)
{
locationCode = LogisticsLocation::find(transTaxInformationPurch.CompanyLocation).Description;
if (transTaxInformationPurch.HSNCodeTable)
{
hsnCodeTable = HSNCodeTable_IN::find(transTaxInformationPurch.HSNCodeTable);
}
else
{
serviceAccountingCodeTable_IN = ServiceAccountingCodeTable_IN::find(transTaxInformationPurch.ServiceAccountingCodeTable);
}
if (hsnCodeTable)
{
hsnCode = hsnCodeTable.Code;
}
if (serviceAccountingCodeTable_IN)
{
sacCode = serviceAccountingCodeTable_IN.SAC;
}
salesLine = purchLine.interCompanySalesLine();
changecompany (salesLine.DataAreaId)
{
transTaxInformationSales = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine, true);
if(transTaxInformationSales)
{
// update sales line tax info exempt from sales line item.
transTaxInformationSales.Exempt = salesLine.inventTable().Exempt_IN;
if(locationCode)
{
select firstonly logisticsLocation
where logisticsLocation.RecId == transTaxInformationPurch.CompanyLocation
&& logisticsLocation.Description == locationCode
join RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == logisticsLocation.RecId
&& taxInformation_IN.IsPrimary == NoYes::Yes;
if (logisticsLocation)
{
transTaxInformationSales.CustomerLocation = logisticsLocation.RecId;
}
if (taxInformation_IN)
{
transTaxInformationSales.CustomerTaxInformation = taxInformation_IN.RecId;
}
}
if (hsnCode)
{
hsnCodeTable.clear();
select firstonly RecId from hsnCodeTable where hsnCodeTable.Code == hsnCode
&& hsnCodeTable.DataAreaId == transTaxInformationSales.DataAreaId;
if (hsnCodeTable.RecId)
{
transTaxInformationSales.HSNCodeTable = hsnCodeTable.RecId;
taxrateType.clear();
select firstonly taxrateType where taxrateType.Name == taxrate;
transTaxInformationSales.TaxRateType = taxrateType.RecId;
taxrate = '';
}
else
{
throw error(strFmt(literalStr("@LK_Label:HSNCodeNotFoundInDataAreaid"), hsnCode, transTaxInformationSales.DataAreaId));
}
}
if (sacCode)
{
serviceAccountingCodeTable_IN.clear();
select firstonly RecId from serviceAccountingCodeTable_IN where serviceAccountingCodeTable_IN.SAC == sacCode
&& serviceAccountingCodeTable_IN.DataAreaId == transTaxInformationSales.DataAreaId;
if (serviceAccountingCodeTable_IN.RecId)
{
transTaxInformationSales.ServiceAccountingCodeTable = serviceAccountingCodeTable_IN.RecId;
taxrateType.clear();
select firstonly taxrateType where taxrateType.Name == taxrate;
transTaxInformationSales.TaxRateType = taxrateType.RecId;
taxrate = '';
}
else
{
throw error(strFmt(literalStr("@LK_Label:SACNotFoundInDataAreaId"), sacCode, transTaxInformationSales.DataAreaId));
}
}
transTaxInformationSales.update();
}
}
}
}
}
} */
/// <summary>
/// This method is to update Assessable Value.
/// </summary>
/// <param name = "_salesTable">_salesTable</param>
/// <param name = "_custExportOrder">_custExportOrder</param>
/// <param name = "_salesId">_salesId</param>
/// <param name = "_lk_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
public void updateSalesLine_IN(SalesTable _salesTable,
NoYesId _custExportOrder,
SalesIdBase _salesId,
LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
TransTaxInformation transTaxInformationSales;
SalesLine salesLineLoc;
SalesLine_IN salesLine_IN;
CustomsExportAssessableValue_IN customsExportAssessableValue;
select firstonly forupdate salesLineLoc
where salesLineLoc.SalesId == _salesTable.SalesId;
salesLine_IN = salesLineLoc.salesLine_IN();
transTaxInformationSales = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLineLoc, true);
if (transTaxInformationSales)
{
if (_lk_SalesOrderIntergationTable.Exempt == NoYes::Yes)
{
transTaxInformationSales.Exempt = NoYes::Yes;
}
if (transTaxInformationSales.Exempt == NoYes::No)
{
// update sales line tax info exempt from sales line item.
transTaxInformationSales.Exempt = salesLineLoc.inventTable().Exempt_IN;
transTaxInformationSales.update();
}
}
salesLine_IN.selectForUpdate(true);
salesLine_IN.TCSGroup = _salesTable.TCSGroup_IN;
salesLine_IN.TDSGroup = _salesTable.TDSGroup_IN;
salesLine_IN.update();
if (_custExportOrder == NoYes::Yes)
{
customsExportAssessableValue = CustomsExportAssessableValue_IN::findInventTransId(salesLineLoc.InventTransId);
if (customsExportAssessableValue.RecId != 0)
{
customsExportAssessableValue.selectForUpdate(true);
customsExportAssessableValue.Amount = salesLineLoc.LineAmount;
customsExportAssessableValue.Value = CustomsExportAssessableValue_IN::getMarkupValue(salesLineLoc.TableId, salesLineLoc.RecId, salesLineLoc.InventTransId);
customsExportAssessableValue.update();
salesLine_IN.AssessableValueTransactionCurrency = CustomsExportAssessableValue_IN::findInventTransId(salesLineLoc.InventTransId).invoiceAssessableValue();
}
else
{
salesLine_IN.AssessableValueTransactionCurrency = salesLineLoc.LineAmount - CustomsExportAssessableValue_IN::getMarkupValue(salesLineLoc.TableId, salesLineLoc.RecId, salesLineLoc.InventTransId);
}
}
else
{
salesLine_IN.AssessableValueTransactionCurrency = salesLineLoc.getMiscChargesAmount_IN();
}
salesLineLoc.packSalesLine_IN(salesLine_IN);
salesLineLoc.update();
}
/// <summary>
/// creating Sales order with all the lines process.
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <returns>SalesId</returns>
public SalesId processSingleSO(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
SalesTable salesTable;
salesTable = this.CreateSalesOrder(_lk_SalesOrderIntergationTable);
if (salesTable)
{
this.createSalesOrderLine(_lk_SalesOrderIntergationTable,salesTable);
this.createMiscChargesLinesByList(_lk_SalesOrderIntergationTable,salesTable.SalesId);
this.createMiscChargesHeaderByList(_lk_SalesOrderIntergationTable,salesTable,MarkupAllocateAfter::NetAmount);
// settleprePaymentMarking, settleExchangeMarking method are not executing for sales order creation
/* this.settleprePaymentMarking(lk_SalesOrderIntergationTable.SalesOrderNumber);
this.settleExchangeMarking(lk_SalesOrderIntergationTable.SalesOrderNumber);*/
// commented for international SO not for indian SO - start
/* purchTable purchTable;
this.updateTDSandTCSGroupOrigSO(salesTable);
this.updateIntecompanySalesOrder(_lk_SalesOrderIntergationTable, salesTable);
this.purchline_TaxLocationUpdate(_lk_SalesOrderIntergationTable, salesTable);
purchTable = this.createDropshipPO(_lk_SalesOrderIntergationTable, salesTable);
if (purchTable && salesTable.RecId)
{
this.updateTaxInfoLocation(salesTable, purchTable, _lk_SalesOrderIntergationTable.LegalEntity);
}
salesTable.clear();
select firstonly forupdate salesTable
where salesTable.CustomerRef == _lk_SalesOrderIntergationTable.SalesOrderNumber
&& salesTable.InterCompanyOrder == NoYes::Yes;
if (salesTable.RecId)
{
salesTable.InventLocationId = _lk_SalesOrderIntergationTable.InventLocationId;
salesTable.InventSiteId = InventLocation::find(_lk_SalesOrderIntergationTable.InventLocationId).InventSiteId;
salesTable.update();
this.updateSalesOrder(_lk_SalesOrderIntergationTable, salesTable.SalesId);
} */
// commented for international SO not for indian SO - End
}
return salesTable.SalesId;
}
}/// <summary>
/// this class used to create sales order and required data
/// </summary>
Public class LK_SalesOrderIntegrationEntityHelper
{
/// <summary>
/// This method is used create customer
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTableV1">_lk_SalesOrderIntergationTableV1</param>
/// <param name = "_lk_SalesOrderIntegrationEntityHelper">_lk_SalesOrderIntegrationEntityHelper</param>
public void CreateCustForSO(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTableV1,LK_SalesOrderIntegrationEntityHelper _lk_SalesOrderIntegrationEntityHelper)
{
CustTable custTable;
NumberSeq numberSeq;
Str60 name;
DirPersonName dirPersonName;
DirPartyType dirPartyType;
container conAttribute;
container conAttributeValue;
DirPerson dirPerson;
DirPartyTable dirPartyTable;
TaxInformationCustTable_IN taxInformationCustTable_IN;
#define.B2Cdom('B2Cdom')
#define.Brand('Brand')
#define.CostCentre('CostCenter')
#define.Classification('Classification')
#define.NavChannel('NavChannel')
#define.SBRT('SBRT')
#define.Store('Store')
custTable.initValue();
numberSeq = NumberSeq::newGetNum(CustParameters::numRefCustAccount());
custTable.AccountNum = _lk_SalesOrderIntergationTableV1.CustomerAccount;
custTable.CustGroup = #B2Cdom;
custTable.Currency = _lk_SalesOrderIntergationTableV1.CurrencyCode;
conAttribute = [#Brand,#CostCentre,#Classification,#NavChannel,#SBRT,#Store];
conAttributeValue = [_lk_SalesOrderIntergationTableV1.Brand,
_lk_SalesOrderIntergationTableV1.CostCenter,
_LK_SalesOrderIntergationTableV1.Classification,
_LK_SalesOrderIntergationTableV1.NavChannel,
_lk_SalesOrderIntergationTableV1.SBRT,
_lk_SalesOrderIntergationTableV1.Store];
dirPartyType = DirPartyType::Person;
if (dirPartyType == DirPartyType::Person)
{
dirpersonname.FirstName = _lk_SalesOrderIntergationTableV1.FirstName;
dirpersonname.MiddleName = _lk_SalesOrderIntergationTableV1.MiddleName;
dirpersonname.LastName = _lk_SalesOrderIntergationTableV1.LastName;
name = strFmt("@LK_Label:LK_ContactNameFormat",dirpersonname.FirstName, dirpersonname.MiddleName, dirpersonname.LastName);
}
if (custTable.validateWrite())
{
custTable.DefaultDimension = LK_DefaultDimesnionHelper::createDefaultDimension(conAttribute,conAttributeValue);
custTable.insert(dirPartyType, name);
dirPartyTable = DirPartyTable::findRec(custTable.Party, true);
dirPartyTable.update();
dirPerson = DirPerson::findByNum(dirPartyTable.PartyNumber, true);
if (dirPartyType == DirPartyType::Person && dirPerson)
{
dirPerson.Gender = _lk_SalesOrderIntergationTableV1.Gender;
dirPerson.update();
}
if (custTable)
{
_LK_SalesOrderIntegrationEntityHelper.createAddress(_lk_SalesOrderIntergationTableV1, custTable);
}
taxInformationCustTable_IN.clear();
taxInformationCustTable_IN.CustTable = custTable.AccountNum;
if (_lk_SalesOrderIntergationTableV1.TCSGroup)
{
taxInformationCustTable_IN.TCSGroup = _lk_SalesOrderIntergationTableV1.TCSGroup;
}
}
else
{
throw Exception::Error;
}
}
/// <summary>
/// This method is used to create Address
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">_lk_SalesOrderIntergationTable</param>
/// <param name = "_custTable">_custTable</param>
public void createAddress(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable, CustTable _custTable)
{
DirParty dirParty;
DirPartyPostalAddressView dirPartyPostalAddressView;
TaxInformation_IN taxInformation_IN;
LogisticsLocation logisticsLocation;
DirPartyTable dirPartyTable;
dirParty = DirParty::constructFromCommon(_custTable);
dirPartyPostalAddressView.clear();
dirPartyPostalAddressView.LocationName = _lk_SalesOrderIntergationTable.DeliveryName;
dirPartyPostalAddressView.City = _lk_SalesOrderIntergationTable.AddressCity;
dirPartyPostalAddressView.Street = _lk_SalesOrderIntergationTable.AddressStreet;
dirPartyPostalAddressView.CountryRegionId = _lk_SalesOrderIntergationTable.AddressCountryRegionId;
dirPartyPostalAddressView.ZipCode = _lk_SalesOrderIntergationTable.AddressZipCode;
dirPartyPostalAddressView.State = _lk_SalesOrderIntergationTable.AddressState;
dirPartyPostalAddressView.IsPrimary = NoYes::Yes;
dirPartyPostalAddressView = dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);
Select firstonly dirPartyTable
where dirPartyTable.RecId == _custTable.Party
join logisticsLocation
where logisticsLocation.RecId == dirPartyPostalAddressView.Location;
taxInformation_IN.clear();
taxInformation_IN.RegistrationLocation = logisticsLocation.RecId;
taxInformation_IN.Name = logisticsLocation.LocationId;
taxInformation_IN.IsPrimary = NoYes::Yes;
}
/// <summary>
/// this method is used to create the postal address of the SO
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <returns>RecId</returns>
public RecId setDeliveryAddress(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
DirPartyPostalAddressView addressView, ret;
DirPartyRecId partyRecId;
DirParty dirParty;
LogisticsPostalAddress postalAddress;
;
//Create new Name
partyRecId = DirPartyTable::createNew(DirPartyType::None, _lk_SalesOrderIntergationTable.DeliveryName).RecId;
addressView.CountryRegionId = _lk_SalesOrderIntergationTable.AddressCountryRegionId;
addressView.State = _lk_SalesOrderIntergationTable.AddressState;
addressView.ZipCode = _lk_SalesOrderIntergationTable.AddressZipCode;
addressView.Street = _lk_SalesOrderIntergationTable.AddressStreet;
addressView.Party = partyRecId;
//Handel errors for addresses
if (!LogisticsAddressCountryRegion::exist(addressView.CountryRegionId))
{
throw error(strFmt("@SYS9347",addressView.CountryRegionId));
}
if (addressView.County && !LogisticsAddressCounty::exist(addressView.CountryRegionId, addressView.State, addressView.County))
{
throw error(strFmt("@SYS72719",addressView.County));
}
if (addressView.State && !LogisticsAddressState::exist(addressView.CountryRegionId, addressView.State))
{
throw error(strFmt("@SYS72786",addressView.State));
}
if (!LogisticsAddressZipCode::exist(addressView.ZipCode))
{
throw error(strFmt("@SYS24626",addressView.ZipCode));
}
if ( addressView.Street || addressView.ZipCode || addressView.City || addressView.State || addressView.CountryRegionId)
{
DirParty = DirParty::constructFromPartyRecId(addressView.Party);
ret = DirParty.createOrUpdatePostalAddress(addressView);
postalAddress = LogisticsPostalAddress::findByLocation(ret.Location, true);
postalAddress.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
postalAddress.update();
}
return postalAddress.RecId;
}
/// <summary>
/// this method is used to create sales order line
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">salesTable</param>
[SuppressBPWarning('BPCheckInsertMethodInLoop', 'To avoid time complexity from separate processing, insert() is preferred over recordInsertList.')]
public void createSalesOrderLine(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable, SalesTable _salesTable)
{
InventDim inventDimLines, inventDimfind;
SalesLine salesLine;
InventTable inventTable;
InventSite inventSite;
Inventlocation inventlocation;
LK_SalesOrderIntergationTableV1 lk_SalesOrderIntergationTableline;
#isoCountryRegionCodes
#define.Pcs('Pcs')
while select lk_SalesOrderIntergationTableline
where lk_SalesOrderIntergationTableline.SalesOrderNumber ==_lk_SalesOrderIntergationTable.SalesOrderNumber
&& lk_SalesOrderIntergationTableline.EntityName == LK_SalesProcessEntityName::SalesOrderLine
{
select firstonly ItemId, DefaultDimension
from inventTable
where inventTable.ItemId == lk_SalesOrderIntergationTableline.ItemNumber;
if (!inventTable.ItemId)
{
this.createReleasedItem(lk_SalesOrderIntergationTableline);
this.updateInventTable(lk_SalesOrderIntergationTableline);
}
salesLine.clear();
salesLine.SalesId = _salesTable.SalesId;
salesLine.initValue(_salesTable.SalesType);
salesLine.initFromSalesTable(_salesTable);
salesLine.ItemId = lk_SalesOrderIntergationTableline.ItemNumber;
salesLine.initFromInventTable(InventTable::find(salesLine.ItemId));
inventDimfind.InventSiteId = lk_SalesOrderIntergationTableline.InventSiteId;
if (!lk_SalesOrderIntergationTableline.InventSiteId)
{
select firstonly InventSiteId
from inventlocation
where inventlocation.InventLocationId == lk_SalesOrderIntergationTableline.InventLocationId;
inventDimfind.InventSiteId = inventlocation.InventSiteId;
}
inventDimfind.InventLocationId = lk_SalesOrderIntergationTableline.InventLocationId;
inventDimLines = InventDim::findOrCreate(inventDimfind);
salesLine.LineNum = lk_SalesOrderIntergationTableline.LineNumber;
salesLine.InventDimId = inventDimLines.inventDimId;
salesLine.LK_CardNo = lk_SalesOrderIntergationTableline.CardNo;
salesLine.LK_TxnId = lk_SalesOrderIntergationTableline.TxnId;
if (lk_SalesOrderIntergationTableline.SalesUnitSymbol == '')
{
salesLine.SalesUnit = #Pcs;
}
else
{
salesLine.SalesUnit = lk_SalesOrderIntergationTableline.SalesUnitSymbol;
}
if (_salesTable.LKSalesType == SalesType::ReturnItem)
{
salesLine.LKSalesType = _salesTable.LKSalesType;
salesLine.SalesQty = abs(lk_SalesOrderIntergationTableline.QtyOrdered) * (-1);
}
else
{
salesLine.SalesQty = lk_SalesOrderIntergationTableline.QtyOrdered;
}
salesLine.RemainSalesPhysical = salesLine.SalesQty;
salesLine.QtyOrdered = salesLine.calcQtyOrdered();
salesLine.RemainInventPhysical = salesLine.QtyOrdered;
salesLine.DlvMode = _salesTable.DlvMode;
salesLine.SalesPrice = lk_SalesOrderIntergationTableline.SalesPrice;
salesLine.LineDisc = str2Num(lk_SalesOrderIntergationTableline.LineDiscountAmount);
salesLine.InvoiceDate = lk_SalesOrderIntergationTableline.InvoiceDate;
salesLine.CustomerInvoiceDate = lk_SalesOrderIntergationTableline.CustomerInvoiceDate;
salesLine.VendorInvoiceDate = lk_SalesOrderIntergationTableline.VendorInvoiceDate;
salesLine.CostPriceWithTax = lk_SalesOrderIntergationTableline.CostPriceWithTax;
salesLine.CostPricewithouttax = lk_SalesOrderIntergationTableline.CostPricewithouttax;
salesLine.SellingPricewithTax = lk_SalesOrderIntergationTableline.SellingPricewithTax;
if (lk_SalesOrderIntergationTableline.ConfirmedShipDate == dateNull())
{
salesLine.ShippingDateConfirmed = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
salesLine.ShippingDateRequested = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
}
else
{
salesLine.ShippingDateConfirmed = lk_SalesOrderIntergationTableline.ConfirmedShipDate;
salesLine.ShippingDateRequested = lk_SalesOrderIntergationTableline.ConfirmedShipDate;
}
if (lk_SalesOrderIntergationTableline.ConfirmedReceiptDate == dateNull())
{
salesLine.ReceiptDateConfirmed = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
salesLine.ReceiptDateRequested = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
}
else
{
salesLine.ReceiptDateConfirmed = lk_SalesOrderIntergationTableline.ConfirmedReceiptDate;
salesLine.ReceiptDateRequested =lk_SalesOrderIntergationTableline.ConfirmedReceiptDate;
}
salesLine.LinePercent = lk_SalesOrderIntergationTableline.LineDiscountPercentage;
if (lk_SalesOrderIntergationTableline.Text)
{
salesLine.Name = lk_SalesOrderIntergationTableline.Text;
}
else
{
salesLine.Name = salesLine.itemName();
}
if (SalesLine.SalesQty < 0)
{
salesLine.LineAmount = abs(salesLine.calcLineAmount()) * -1;
}
else
{
salesLine.LineAmount = salesLine.calcLineAmount();
}
salesLine.CostPrice = lk_SalesOrderIntergationTableline.ReturnCostPrice;
salesLine.LKMagentoItemId = lk_SalesOrderIntergationTableline.MagentoItemId;
salesLine.LKOrgSalesOrderNo = lk_SalesOrderIntergationTableline.SalesOrderNumber;
salesLine.LKOrgSalesOrderLineNo = lk_SalesOrderIntergationTableline.LineNumber;
salesLine.LKSalesOrderItemCode = lk_SalesOrderIntergationTableline.SalesOrderItemCode;
salesLine.LK_GiftVoucher = lk_SalesOrderIntergationTableline.GiftVoucher;
salesLine.LK_CategoryOfProducts = lk_SalesOrderIntergationTableline.CategoryOfProducts;
salesLine.LK_Coverage = lk_SalesOrderIntergationTableline.Coverage;
salesLine.LK_InsuranceProduct = lk_SalesOrderIntergationTableline.InsuranceProduct;
salesLine.LK_WarrantyProduct = lk_SalesOrderIntergationTableline.WarrantyProduct;
salesLine.LK_IssuanceFromDate = lk_SalesOrderIntergationTableline.IssuanceFromDate;
salesLine.LK_IssuanceToDate = lk_SalesOrderIntergationTableline.IssuanceToDate;
salesLine.LK_GoldMembershipNumber = lk_SalesOrderIntergationTableline.GoldMembershipNumber;
salesLine.LK_GoldMembershipType = lk_SalesOrderIntergationTableline.GoldMembershipType;
salesLine.LK_GoldMembershipEndDate = lk_SalesOrderIntergationTableline.GoldMembershipEndDate;
salesLine.LK_GoldMembershipStartDate = lk_SalesOrderIntergationTableline.GoldMembershipStartDate;
salesLine.LK_PurchasePrice = lk_SalesOrderIntergationTableline.PurchasePrice;
if (!SysCountryRegionCode::isLegalEntityInCountryRegion([#isoIN]))
{
salesLine.TaxItemGroup = lk_SalesOrderIntergationTableline.Itemsalestaxgrp;
salesLine.TaxGroup = lk_SalesOrderIntergationTableline.Salestaxgrp;
}
select firstonly SiteId
from inventSite
where inventSite.SiteId == inventDimfind.InventSiteId;
salesLine.DefaultDimension = LK_FinancialDimensionHelper::getDimensionNew(DimensionSetEntity::find(inventTable.DefaultDimension).DisplayValue,
DimensionSetEntity::find(_salesTable.DefaultDimension).DisplayValue,
DimensionSetEntity::find(inventSite.DefaultDimension).DisplayValue,
lk_SalesOrderIntergationTableline.Brand,
lk_SalesOrderIntergationTableline.Classification,
lk_SalesOrderIntergationTableline.CostCenter,
lk_SalesOrderIntergationTableline.NavChannel,
lk_SalesOrderIntergationTableline.SBRT,
lk_SalesOrderIntergationTableline.Store);
salesLine.insert();
if (salesLine)
{
this.updateSalesLine_IN(_salesTable,NoYes::Yes,salesLine.SalesId,lk_SalesOrderIntergationTableline);
this.updateHSNAndSACCode(lk_SalesOrderIntergationTableline,_salesTable);
}
}
}
/// <summary>
/// This method creates on-the-fly item if item does not exist.
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">_lk_SalesOrderIntergationTable</param>
public void createReleasedItem(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
InventTable inventTable;
EcoResProduct ecoResProduct;
EcoResDistinctProduct ecoResDistinctProduct;
EcoResProductTranslation ecoResProductTranslation;
InventItemSetupSupplyType inventItemSetupSupplyType;
ecoResProductIdentifier ecoResProductIdentifier;
#define.Pcs('Pcs')
select firstOnly ecoResProduct
where EcoResProduct.DisplayProductNumber == _lk_SalesOrderIntergationTable.ItemNumber;
if (!ecoResProduct)
{
ecoResDistinctProduct.initValue();
ecoResDistinctProduct.DisplayProductNumber = _lk_SalesOrderIntergationTable.ItemNumber;
ecoResDistinctProduct.SearchName = _lk_SalesOrderIntergationTable.ItemNumber;
if (_lk_SalesOrderIntergationTable.ItemTemplateName == EcoResProductType::Service)
{
ecoResDistinctProduct.ProductType = EcoResProductType::Service;
}
else
{
ecoResDistinctProduct.ProductType = EcoResProductType::Item;
}
if (ecoResDistinctProduct.validateWrite())
{
ecoResDistinctProduct.insert();
ecoResProduct= ecoResDistinctProduct;
ecoResProductIdentifier.clear();
ecoResProductIdentifier.initValue();
ecoResProductIdentifier.ProductNumber = _lk_SalesOrderIntergationTable.ItemNumber;
ecoResProductIdentifier.Product = ecoResDistinctProduct.RecId;
ecoResProductIdentifier.insert();
ecoResProductTranslation.Product = ecoResDistinctProduct.RecId;
ecoResProductTranslation.Name = _lk_SalesOrderIntergationTable.ItemNumber;
EcoResProductTranslation.Description = _lk_SalesOrderIntergationTable.ItemNumber;
ecoResProductTranslation.setDefaultLanguage();
ecoResProductTranslation.insert();
inventTable.clear();
inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProduct);
inventTable.ItemId = _lk_SalesOrderIntergationTable.ItemNumber;
inventTable.NameAlias = ecoResProduct.SearchName;
inventTable.insert(true);
this.inventTableModule(inventTable.ItemId);
//Create inventItemLocation
InventItemLocation::createDefault(inventTable.ItemId);
// Creates a new item default order type for the product that is released.
inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.ItemId = inventTable.ItemId;
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
inventItemSetupSupplyType.insert();
this.applyTemplate(inventTable, _lk_SalesOrderIntergationTable.ItemTemplateNameStr);
}
}
else
{
inventTable.clear();
inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProduct);
inventTable.ItemId = _lk_SalesOrderIntergationTable.ItemNumber;
inventTable.NameAlias = ecoResProduct.SearchName;
inventTable.insert(true);
this.inventTableModule(inventTable.ItemId);
//Create inventItemLocation
InventItemLocation::createDefault(inventTable.ItemId);
// Creates a new item default order type for the product that is released.
inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.ItemId = inventTable.ItemId;
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
inventItemSetupSupplyType.insert();
this.applyTemplate(inventTable, _lk_SalesOrderIntergationTable.ItemTemplateNameStr);
}
}
/// <summary>
/// invent table module
/// </summary>
/// <param name = "_itemid">_itemid</param>
public void inventTableModule(ItemId _itemid)
{
#define.Pcs('Pcs')
inventTableModule inventTableModule;
inventTableModule.initValue();
inventTableModule.ItemId = _itemid;
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
InventTableModule.UnitId = #Pcs;
InventTableModule.Price = 0.0;
inventTableModule.insert();
inventTableModule.initValue();
inventTableModule.ItemId = _itemid;
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
InventTableModule.UnitId = #Pcs;
InventTableModule.Price = 0.0;
inventTableModule.insert();
inventTableModule.initValue();
inventTableModule.ItemId = _itemid;
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
InventTableModule.UnitId = #Pcs;
InventTableModule.Price = 0.0;
inventTableModule.insert();
}
/// <summary>
/// This method is used to apply template for item
/// </summary>
/// <param name = "_inventTable">_inventTable</param>
/// <param name = "_templateName">_templateName</param>
public void applyTemplate(InventTable _inventTable, str _templateName)
{
EcoResProductTemplateApplyManagerUtils utils;
container recordTmpValues;
recordTmpValues = this.getTemplateData(_templateName);
utils = EcoResProductTemplateApplyManagerUtils::newDefault();
utils.applyTemplate(recordTmpValues, _inventTable.ItemId);
}
/// <summary>
/// This is to update HSN, SAC, Financial diemsnions for the item.
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">_lk_SalesOrderIntergationTable</param>
public void updateInventTable(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
InventTable inventTableUpdate;
select firstonly forupdate inventTableUpdate
where inventTableUpdate.ItemId == _lk_SalesOrderIntergationTable.ItemNumber;
if (inventTableUpdate)
{
inventTableUpdate.DefaultDimension = LK_FinancialDimensionHelper::getDimensionForSOItemCreateNew(DimensionSetEntity::find(inventTableUpdate.DefaultDimension).DisplayValue,
'',
'',
_LK_SalesOrderIntergationTable.Brand,
_LK_SalesOrderIntergationTable.Classification,
_LK_SalesOrderIntergationTable.CostCenter,
_LK_SalesOrderIntergationTable.NavChannel,
_LK_SalesOrderIntergationTable.SBRT,
_LK_SalesOrderIntergationTable.Store);
inventTableUpdate.update();
}
}
/// <summary>
/// Template data
/// </summary>
/// <param name = "_templateName">_templateName</param>
/// <returns>container</returns>
public container getTemplateData(str _templateName)
{
SysRecordTemplateTable templateTable;
SysRecordTmpTemplate tmp;
container dataContainer, RecordTmplateData;
int i;
select firstonly templateTable
where templateTable.table == tableNum(inventTable);
dataContainer = templateTable.Data;
for (i=conlen(dataContainer); i; i--)
{
[tmp.Description, tmp.DefaultRecord, tmp.Data, tmp.Details] = conpeek(dataContainer, i);
if (tmp.Description == _templateName)
{
tmp.OrgDescription = tmp.Description;
tmp.insert();
RecordTmplateData=tmp.data;
}
}
return RecordTmplateData;
}
/// <summary>
/// create drop ship
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTableV1">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">salesTable</param>
/// <returns>PurchTable</returns>
//public PurchTable createDropshipPO(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTableV1, SalesTable _salesTable)
//{
// SalesLine salesLine;
// LK_POCreationFromSO purchCreateFromSalesOrder = new LK_POCreationFromSO();
// PurchTable purchTable;
// select firstonly forupdate salesLine
// where salesLine.SalesId == _salesTable.SalesId
// && salesLine.LineNum == _LK_SalesOrderIntergationTableV1.LineNumber;
// if (_LK_SalesOrderIntergationTableV1.DeliveryType == TradeLineDlvType::DropShip && _LK_SalesOrderIntergationTableV1.SourcingVendor && _LK_SalesOrderIntergationTableV1.PurchPriceStr)
// {
// purchTable = purchCreateFromSalesOrder.createPurchOrderFromSalesLine(salesLine, _LK_SalesOrderIntergationTableV1.SourcingVendor, '', _LK_SalesOrderIntergationTableV1.PurchPriceStr);
// salesLine.reread();
// salesLine.DeliveryType = TradeLineDlvType::DropShip;
// salesLine.SourcingVendAccount = _LK_SalesOrderIntergationTableV1.SourcingVendor;
// salesLine.SourcingOrigin = VendTable::find(salesLine.SourcingVendAccount).interCompanyTradingRelationActive() ? SalesSourcingOrigin::Intercompany : SalesSourcingOrigin::ExternalVendor;
// salesLine.update();
// this.updatePurchLine_IN(_salesTable, purchTable);
// if (_salesTable.Fulfillment_WH)
// {
// this.updateVendLocationOnPurchLine(purchTable, _salesTable);
// }
// }
// return purchTable;
//}
/// <summary>
/// This method is to update tcs and tds group of the purch table.
/// </summary>
/// <param name = "_salesTable">SalesTable</param>
/// <param name = "_purchTable">PurchTable</param>
/* public void updatePurchLine_IN(SalesTable _salesTable, PurchTable _purchTable)
{
PurchLine purchLineLoc;
PurchLine_IN purchLine_IN;
while select purchLineLoc
where purchLineLoc.PurchId == _purchTable.PurchId // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
purchLine_IN = purchLineLoc.purchLine_IN();
ttsbegin;
purchLine_IN.selectForUpdate(true);
purchLine_IN.TCSGroup = _salesTable.TCSGroup_IN;
purchLine_IN.TDSGroup = _salesTable.TDSGroup_IN;
purchLine_IN.update();
ttscommit;
}
}*/
/// <summary>
/// update vendor location on back to back order
/// </summary>
/// <param name = "purchTable">purchTable</param>
/// <param name = "_salesTable">_salesTable</param>
/* public void updateVendLocationOnPurchLine(PurchTable purchTable, SalesTable _salesTable)
{
PurchLine purchLine;
LogisticsLocation logisticsLocation;
TransTaxInformation transTaxInformationLocal;
TaxInformation_IN taxInformation_IN;
VendTable vendTable;
DirPartyPostalAddressView addressViewLoc;
while select purchline
where purchline.purchId == purchTable.purchId
{
if (purchline)
{
transTaxInformationLocal = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(purchline, true);
select firstonly Party from vendTable
where vendTable.AccountNum == purchline.VendAccount
join addressViewLoc
where addressViewLoc.Party == vendTable.Party
&& addressViewLoc.LocationName == _salesTable.Fulfillment_WH;
transTaxInformationLocal.VendorLocation = addressViewLoc.Location;
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == addressViewLoc.Location
&& taxInformation_IN.IsPrimary == NoYes::Yes
join logisticsLocation where logisticsLocation.RecId == addressViewLoc.Location;
transTaxInformationLocal.VendorTaxInformation = taxInformation_IN.RecId;
transTaxInformationLocal.update();
}
}
} */
/// <summary>
/// This method is used to create misc. charges for sales order line
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTable">_LK_SalesOrderIntergationTable</param>
/// <param name = "_salesId">_salesId</param>
public void createMiscChargesLinesByList(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTable,SalesId _salesId)
{
SalesLine salesLine;
MarkupTable markupTableLine;
MarkupTrans markupTrans;
LK_SalesOrderIntergationTableV1 lk_SalesOrderIntergationTableMarkUpLines;
RecordInsertList markupTransInsertList = new RecordInsertList(tableNum(markupTrans));
while select lk_SalesOrderIntergationTableMarkUpLines
where lk_SalesOrderIntergationTableMarkUpLines.EntityName == LK_SalesProcessEntityName::MarkupLines
&& lk_SalesOrderIntergationTableMarkUpLines.SalesOrderNumber == _LK_SalesOrderIntergationTable.SalesOrderNumber
join salesLine where salesLine.SalesId == _salesId
&& salesLine.LineNum == lk_SalesOrderIntergationTableMarkUpLines.LineNumber
{
if (salesLine)
{
markupTableLine = MarkupTable::find(MarkupModuleType::Cust, lk_SalesOrderIntergationTableMarkUpLines.SalesChargeCode);
markupTrans.clear();
markupTrans.MarkupCode = markupTableLine.MarkupCode;
markupTrans.initFromSalesLine(salesLine);
markupTrans.initFromMarkupTable(markupTableLine);
markupTrans.initValue();
markupTrans.LineNum = lk_SalesOrderIntergationTableMarkUpLines.ChargeLineNumber;
markupTrans.MarkupCategory = lk_SalesOrderIntergationTableMarkUpLines.ChargeCategory;
markupTrans.CurrencyCode = lk_SalesOrderIntergationTableMarkUpLines.CurrencyCode ? lk_SalesOrderIntergationTableMarkUpLines.CurrencyCode : "@LK_Label:CurrencyUSD"; // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
markupTrans.Value = lk_SalesOrderIntergationTableMarkUpLines.FixedChargeAmount;
markupTrans.Keep = NoYes::Yes;
markupTrans.TaxGroup = lk_SalesOrderIntergationTableMarkUpLines.SalesTaxGroupCode;
markupTrans.TaxItemGroup = lk_SalesOrderIntergationTableMarkUpLines.SalesTaxItemGroupCode;
markupTransInsertList.add(markupTrans);
}
}
markupTransInsertList.insertDatabase();
}
/// <summary>
/// This method is used for Misc. Charges on header level.
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTable">_LK_SalesOrderIntergationTable</param>
/// <param name = "_salesTable">_salesTable</param>
/// <param name = "_allocateAfter">MarkupAllocateAfter</param>
public void createMiscChargesHeaderByList(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTable, SalesTable _salesTable, MarkupAllocateAfter _allocateAfter = MarkupAllocateAfter::NetAmount)
{
MarkupTable markupTable;
MarkupTrans markupTrans;
LK_SalesOrderIntergationTableV1 lk_SalesOrderIntergationTableMarkupHeader;
RecordInsertList markupTransInsertListHeader = new RecordInsertList(tableNum(markupTrans));
while select lk_SalesOrderIntergationTableMarkupHeader
where lk_SalesOrderIntergationTableMarkupHeader.SalesOrderNumber == _LK_SalesOrderIntergationTable.SalesOrderNumber
&& lk_SalesOrderIntergationTableMarkupHeader.EntityName == LK_SalesProcessEntityName::MarkupHeader
{
if (_salesTable && lk_SalesOrderIntergationTableMarkupHeader)
{
markupTable = MarkupTable::find(MarkupModuleType::Cust, lk_SalesOrderIntergationTableMarkupHeader.SalesChargeCode);
markupTrans.clear();
markupTrans.MarkupCode = markupTable.MarkupCode;
markupTrans.initFromSalesTable(_salesTable);
markupTrans.initFromMarkupTable(markupTable);
markupTrans.initValue();
markupTrans.LineNum = lk_SalesOrderIntergationTableMarkupHeader.ChargeLineNumber;
markupTrans.MarkupCategory = lk_SalesOrderIntergationTableMarkupHeader.ChargeCategory;
markupTrans.CurrencyCode = lk_SalesOrderIntergationTableMarkupHeader.CurrencyCode ? lk_SalesOrderIntergationTableMarkupHeader.CurrencyCode : "@LK_Label:CurrencyUSD";
markupTrans.Value = lk_SalesOrderIntergationTableMarkupHeader.FixedChargeAmount;
markupTrans.Keep = NoYes::Yes;
markupTrans.TaxGroup = lk_SalesOrderIntergationTableMarkupHeader.SalesTaxGroupCode;
markupTrans.TaxItemGroup = lk_SalesOrderIntergationTableMarkupHeader.SalesTaxItemGroupCode;
markupTransInsertListHeader.add(markupTrans);
}
}
markupTransInsertListHeader.insertDatabase();
}
/* public void updateTDSandTCSGroupOrigSO(SalesTable _salesTable)
{
SalesTable salesTableOrg;
SalesLine salesLineOrg;
SalesLine_IN salesLine_IN;
select forupdate firstonly salesTableOrg
where salesTableOrg.SalesId == _salesTable.InterCompanyOriginalSalesId
&& salesTableOrg.DataAreaId == _salesTable.InterCompanyCompanyId;
if (salesTableOrg)
{
salesTableOrg.TDSGroup_IN = _salesTable.TDSGroup_IN;
salesTableOrg.TCSGroup_IN = _salesTable.TCSGroup_IN;
salesTableOrg.update();
while select salesLineOrg
where salesLineOrg.DataAreaId == _salesTable.InterCompanyCompanyId
&& salesLineOrg.SalesId == _salesTable.SalesId
{
salesLine_IN = salesLineOrg.salesLine_IN();
salesLine_IN.selectForUpdate(true);
salesLine_IN.TCSGroup = _salesTable.TCSGroup_IN;
salesLine_IN.TDSGroup = _salesTable.TDSGroup_IN;
salesLine_IN.update();
}
}
} */
public void settleprePaymentMarking(str _salesId)
{
LedgerJournalTable ledgerjournalTable;
CustTrans custtrans;
CustTransOpen custTransOpen;
LedgerJournaltrans ledgerjournalTrans;
specTransManager specTransManager;
SalesTable salesTable;
DimensionDynamicAccount dimensionDynamicAccount;
select firstonly salesTable
where salesTable.CustomerRef == _salesId;
if (salesTable && salesTable.CustomerRef)
{
dimensionDynamicAccount = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(salesTable.CustAccount, LedgerJournalACType::Cust);
select firstonly JournalNum from ledgerjournalTrans
where ledgerjournalTrans.DocumentNum == salesTable.CustomerRef
&& ledgerjournalTrans.LedgerDimension == dimensionDynamicAccount
&& ledgerjournalTrans.Prepayment == NoYes::Yes;
ledgerjournalTable = ledgerjournalTable::find(ledgerjournalTrans.JournalNum);
if (ledgerjournalTrans && ledgerjournalTable.Posted == NoYes::Yes)
{
specTransManager = SpecTransManager::newFromSpec(salesTable);
select firstonly custTransOpen
join custTrans
where custTransOpen.AccountNum == custTrans.AccountNum
&& custTransOpen.RefRecId == custTrans.RecId
&& custtrans.RecId == ledgerjournalTrans.CustTransId;
if (custTransOpen)
{
specTransManager.insert(
custTransOpen.company(),
custTransOpen.TableId,
custTransOpen.RecId,
custTransOpen.AmountCur,
ledgerjournalTrans.CurrencyCode);
ttsBegin;
salesTable.selectForUpdate(true);
salesTable.SettleVoucher = SettlementType::SelectedTransact;
salesTable.update();
ttscommit;
}
}
}
}
/// <summary>
/// this method use to ettle Exchange Marking
/// </summary>
/// <param name = "_salesId">_salesId</param>
public void settleExchangeMarking(str _salesId)
{
CustTrans custtrans;
CustTransOpen custTransOpen;
CustInvoiceJour custInvoiceJour;
specTransManager specTransManager;
SalesTable salesTable;
select firstonly salesTable
where salesTable.CustomerRef == _salesId;
if (salesTable && salesTable.LK_RefInvoiceNo)
{
select firstonly InvoiceId,InvoiceAccount,InvoiceDate,LedgerVoucher from custInvoiceJour
where custInvoiceJour.LK_SalesInvoiceNo == salesTable.LK_RefInvoiceNo
&& custInvoiceJour.InvoiceAccount == salesTable.CustAccount;
if (custInvoiceJour)
{
select firstonly AccountNum,RecId from custtrans
where custtrans.Invoice == custInvoiceJour.InvoiceId
&& custtrans.AccountNum == custInvoiceJour.InvoiceAccount
&& custtrans.TransDate == custInvoiceJour.InvoiceDate
&& custtrans.Voucher == custInvoiceJour.LedgerVoucher;
specTransManager = SpecTransManager::newFromSpec(salesTable);
select firstonly custTransOpen
where custTransOpen.AccountNum == custTrans.AccountNum
&& custTransOpen.RefRecId == custTrans.RecId;
if (custTransOpen)
{
specTransManager.insert(
custTransOpen.company(),
custTransOpen.TableId,
custTransOpen.RecId,
custTransOpen.AmountCur,
custInvoiceJour.CurrencyCode);
ttsBegin;
salesTable.selectForUpdate(true);
salesTable.SettleVoucher = SettlementType::SelectedTransact;
salesTable.update();
ttscommit;
}
}
}
}
/// <summary>
/// Updaet interCompany Sales Line
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTableV1">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">salesTable</param>
/* public void updateIntercompanySalesLine(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTableV1, SalesTable _salesTable)
{
SalesLine salesLine;
InventDim inventDimLines, inventDimfind;
InventLocation inventLocation;
int linenum = 1;
TransTaxInformation transTaxInformationSale;
TaxRateType taxRateType;
LogisticsLocation logisticsLocation;
LogisticsEntityPostalAddressView postalAddressView;
TaxInformation_IN taxInformation_IN;
select firstonly forupdate salesLine
where salesLine.SalesId == _salesTable.SalesId
&& salesLine.LineNum == _LK_SalesOrderIntergationTableV1.LineNumber;
if (salesLine)
{
transTaxInformationSale = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine,true);
if (transTaxInformationSale)
{
inventLocation = inventLocation::find(_salesTable.Fulfillment_WH);
if (inventLocation)
{
select firstonly Location from postalAddressView
where postalAddressView.Entity == inventLocation.RecId
&& postalAddressView.EntityType == LogisticsLocationEntityType::Warehouse
&& postalAddressView.isPrimary == NoYes::Yes
join RecId from logisticsLocation where logisticsLocation.RecId == postalAddressView.Location;
if (logisticsLocation.RecId)
{
transTaxInformationSale.CompanyLocation = logisticsLocation.RecId;
}
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == logisticsLocation.RecId
&& taxInformation_IN.IsPrimary == NoYes::Yes;
if (taxInformation_IN.RecId)
{
transTaxInformationSale.TaxInformation = taxInformation_IN.RecId;
transTaxInformationSale.GSTIN = taxInformation_IN.GSTIN;
}
//// END
select firstonly RecId from taxRateType
where taxRateType.Name == _LK_SalesOrderIntergationTableV1.TaxRateType;
transTaxInformationSale.TaxRateType = taxRateType.RecId;
transTaxInformationSale.update();
}
}
salesLine.LKSalesType = _salesTable.LKSalesType;
salesLine.LKMagentoItemId = _LK_SalesOrderIntergationTableV1.MagentoItemId;
salesLine.LKOrgSalesOrderNo = _LK_SalesOrderIntergationTableV1.SalesOrderNumber;
salesLine.LKOrgSalesOrderLineNo = _LK_SalesOrderIntergationTableV1.LineNumber;
salesLine.LKSalesOrderItemCode = _LK_SalesOrderIntergationTableV1.ItemNumber;
if (_salesTable.LKSalesType == SalesType::ReturnItem)
{
salesLine.LK_Refrence_WH = _LK_SalesOrderIntergationTableV1.ReferenceWH;
}
// code added by PAnkaj - 12-10-2023- Start
if (_salesTable.Fulfillment_WH)
{
inventDimfind.InventSiteId = _salesTable.InventSiteId;
inventDimfind.InventLocationId = _salesTable.InventLocationId;
inventDimLines = InventDim::findOrCreate(inventDimfind);
salesLine.InventDimId = inventDimLines.inventDimId;
}
//END
salesLine.LK_CardNo = _LK_SalesOrderIntergationTableV1.CardNo;
salesLine.LK_TxnId = _LK_SalesOrderIntergationTableV1.TxnId;
salesLine.update();
linenum++;
}
}*/
/// <summary>
/// updateIntecompanySalesOrder
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTableV1">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">salesTable</param>
//public void updateIntecompanySalesOrder(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTableV1,SalesTable _salesTable)
//{
// SalesTable locSalesTable;
// ttsbegin;
// select firstonly forupdate locSalesTable
// where locSalesTable.InterCompanyOriginalSalesId == _salesTable.SalesId;
// if (locSalesTable)
// {
// locSalesTable.LKSalesType = _salesTable.LKSalesType;
// locSalesTable.LKCourierCode = _salesTable.LKCourierCode;
// locSalesTable.LKModeOfPayment = _salesTable.LKModeOfPayment;
// locSalesTable.LKOrderCreationDate = _salesTable.LKOrderCreationDate;
// locSalesTable.LKWebOrderNo = _salesTable.LKWebOrderNo;
// locSalesTable.Fulfillment_WH = _LK_SalesOrderIntergationTableV1.Fulfillment_WH; // code added by PAnkaj on 19-10-2023
// if (locSalesTable.Fulfillment_WH)
// {
// locSalesTable.InventLocationId = _LK_SalesOrderIntergationTableV1.Fulfillment_WH;
// locSalesTable.InventSiteId = InventLocation::find(_LK_SalesOrderIntergationTableV1.Fulfillment_WH).InventSiteId;
// }
// locSalesTable.update();
// this.updateIntercompanySalesLine(_LK_SalesOrderIntergationTableV1, locSalesTable);
// }
// ttscommit;
//}
/// <summary>
/// Intercompany location has update by Rutika 2/8/2022
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTableV1">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">SalesTable</param>
/* public void purchline_TaxLocationUpdate(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTableV1,SalesTable _salesTable)
{
PurchLine purchline;
int linenum = 1;
TransTaxInformation transTaxInformationLocal;
TransTaxInformation transTaxInformationSales;
LogisticsLocation logisticsLocation;
LogisticsEntityPostalAddressView postalAddressView;
PurchTable purchTable;
boolean updateIntegration = false;
TaxRateType taxRateType;
ServiceAccountingCodeTable_IN sacTable;
SalesLine salesLine;
TaxInformation_IN taxInformation_IN;
InventDim inventDimLines, inventDimfind;
DirPartyPostalAddressView addressView1;
VendTable vendTable;
str store;
CustTable custable;
HSNCodeTable_IN hsnCode_In;
PurchTable_W purchTable_w;
PurchLine_IN purchLine_IN;
InventLocation inventLocation;
//update integration yes in case of intercompany purchase order
if (_salesTable.InterCompanyCompanyId && !_salesTable.InterCompanyOriginalSalesId && _salesTable.InterCompanyPurchId) // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
updateIntegration = true;
}
if (!_salesTable.InterCompanyCompanyId) // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
return;
}
changecompany (_salesTable.InterCompanyCompanyId) // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
// code added for intercomany connection.
purchtable = null;
select firstonly crosscompany purchTable
where purchTable.DataAreaId == _salesTable.InterCompanyCompanyId
&& purchTable.PurchId == _salesTable.InterCompanyPurchId;
if (purchTable)
{
//update integration yes in case of intercompany purchase order
if (updateIntegration)
{
purchTable.selectForUpdate(true);
purchTable.LK_Integration = NoYes::Yes;
// Codded added by Pankaj - 12-10-2023 - Start
purchTable.InventLocationId = _salesTable.InventLocationId;
purchTable.InventSiteId = _salesTable.InventSiteId;
//End
//Code added by vinay start on 2/4/2024
purchTable.doUpdate();
select firstonly forupdate purchTable_w
where purchTable_w.PurchTable == purchTable.RecId;
if (purchTable_w && _LK_SalesOrderIntergationTableV1.TDSgroup != '' )
{
purchTable_w.TDSGroup_IN = _salesTable.TDSGroup_IN;
}
else if (purchTable_w && _LK_SalesOrderIntergationTableV1.TCSgroup != '')
{
purchTable_w.TCSGroup_IN = _salesTable.TCSGroup_IN;
}
purchTable_w.update();
///Code end by vinay on 2/4/2024
}
select firstonly forupdate purchline
where purchline.purchId == purchTable.purchId
&& purchline.LineNumber == real2int(linenum);
if (purchline)
{
// Codded added by Pankaj - 12-10-2023 - Start
inventDimfind.InventSiteId = InventLocation::find(_LK_SalesOrderIntergationTableV1.Store).InventSiteId;
if (!_LK_SalesOrderIntergationTableV1.store)
{
inventDimfind.InventSiteId = InventLocation::find(_LK_SalesOrderIntergationTableV1.InventSiteId).InventSiteId;
}
inventDimfind.InventLocationId = _LK_SalesOrderIntergationTableV1.InventLocationId;
inventDimLines = InventDim::findOrCreate(inventDimfind);
purchline.LineNumber = real2int(_LK_SalesOrderIntergationTableV1.LineNumber);
purchline.InventDimId = inventDimLines.inventDimId;
purchline.update();
// End
transTaxInformationLocal = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(purchline, true);
select firstonly taxRateType where taxRateType.Name == _LK_SalesOrderIntergationTableV1.TaxRateType;
transTaxInformationLocal.TaxRateType = taxRateType.RecId;
if (_LK_SalesOrderIntergationTableV1.HSNCode)
{
select firstonly RecId from hsnCode_In
where hsncode_in.Code == _LK_SalesOrderIntergationTableV1.HSNCode;
if (hsnCode_In.RecId)
{
transTaxInformationLocal.HSNCodeTable = hsnCode_In.RecId;
}
}
if (_LK_SalesOrderIntergationTableV1.SACCode)
{
select firstonly RecId from sacTable
where sacTable.SAC == _LK_SalesOrderIntergationTableV1.SACCode;
if (sacTable.RecId)
{
transTaxInformationLocal.ServiceAccountingCodeTable = sacTable.RecId;
}
}
///Code end by vinay on 2/4/2024 for purchline hsn
if (_LK_SalesOrderIntergationTableV1.Store)
{
inventLocation = inventLocation::find(_LK_SalesOrderIntergationTableV1.Store);
if (inventLocation)
{
select firstonly Location from postalAddressView
where postalAddressView.Entity == inventLocation.RecId
&& postalAddressView.LocationName == _LK_SalesOrderIntergationTableV1.InventLocationId
&& postalAddressView.EntityType == LogisticsLocationEntityType::Warehouse
&& postalAddressView.isPrimary == NoYes::Yes;
transTaxInformationLocal.CompanyLocation = postalAddressView.Location;
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == postalAddressView.Location
&& taxInformation_IN.IsPrimary == NoYes::Yes
join logisticsLocation where logisticsLocation.RecId == postalAddressView.Location;
transTaxInformationLocal.TaxInformation = taxInformation_IN.RecId;
}
select firstonly Party from vendTable
where vendTable.AccountNum == purchline.VendAccount;
select firstonly Location from addressView1
where addressView1.Party == vendTable.Party
&& addressView1.LocationName == _LK_SalesOrderIntergationTableV1.InventLocationId;
transTaxInformationLocal.VendorLocation = addressView1.Location;
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == addressView1.Location
&& taxInformation_IN.IsPrimary == NoYes::Yes
join logisticsLocation where logisticsLocation.RecId == addressView1.Location;
transTaxInformationLocal.VendorTaxInformation = taxInformation_IN.RecId;
store = _LK_SalesOrderIntergationTableV1.store;
}
//code added by vinay on 2/4/2024
while select purchline
where purchline.PurchId == purchTable.PurchId
{
purchLine_IN = purchline.purchLine_IN();
ttsbegin;
purchLine_IN.selectForUpdate(true);
purchLine_IN.TCSGroup = purchTable_w.TCSGroup_IN;
purchLine_IN.TDSGroup = purchTable_w.TDSGroup_IN;
purchLine_IN.update();
ttscommit;
}
addressView1.clear();
taxInformation_IN.clear();
logisticsLocation.clear();
salesLine = purchline.interCompanySalesLine();
if (salesLine)
{
changecompany (salesLine.DataAreaId)
{
transTaxInformationSales = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine, true);
if (store)
{
select firstonly Party from custable
where custable.AccountNum == salesLine.CustAccount;
select firstonly Location from addressView1
where addressView1.Party == custable.Party
&& addressView1.LocationName == store;
transTaxInformationSales.CustomerLocation = addressView1.Location;
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == addressView1.Location
&& taxInformation_IN.IsPrimary == NoYes::Yes
join logisticsLocation where logisticsLocation.RecId == addressView1.Location;
transTaxInformationSales.CustomerTaxInformation = taxInformation_IN.RecId;
transTaxInformationSales.update();
}
}
store = '';
}
transTaxInformationLocal.update();
linenum++;
}
}
}
} */
/// <summary>
/// update sales order
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <param name = "_salesId">_salesId</param>
/* public void updateSalesOrder(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTable,SalesIdBase _salesId)
{
InventDim inventDimLines, inventDimfind;
SalesLine salesLine;
TransTaxInformation transTaxInformationSales;
LogisticsLocation logisticsLocation;
str store;
CustTable custable;
TaxInformation_IN taxInformation_IN;
DirPartyPostalAddressView addressView1;
select firstonly forupdate salesLine
where salesLine.SalesId == _salesId
&& salesLine.ItemId == _LK_SalesOrderIntergationTable.ItemNumber
&& salesLine.LineNum == _LK_SalesOrderIntergationTable.LineNumber;
if (salesLine)
{
inventDimfind.InventSiteId = _LK_SalesOrderIntergationTable.InventSiteId;
if (!_LK_SalesOrderIntergationTable.InventSiteId)
{
inventDimfind.InventSiteId = InventLocation::find(_LK_SalesOrderIntergationTable.InventLocationId).InventSiteId;
}
inventDimfind.InventLocationId = _LK_SalesOrderIntergationTable.InventLocationId;
inventDimLines = InventDim::findOrCreate(inventDimfind);
salesLine.InventDimId = inventDimLines.inventDimId;
salesLine.update();
store = _LK_SalesOrderIntergationTable.store;
transTaxInformationSales = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine, true);
if (store)
{
select firstonly Party from custable
where custable.AccountNum == salesLine.CustAccount
join Location from addressView1
where addressView1.Party == custable.Party
&& addressView1.LocationName == store;
transTaxInformationSales.CustomerLocation = addressView1.Location;
select firstonly RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == addressView1.Location
&& taxInformation_IN.IsPrimary == NoYes::Yes
join logisticsLocation where logisticsLocation.RecId == addressView1.Location;
transTaxInformationSales.CustomerTaxInformation = taxInformation_IN.RecId;
transTaxInformationSales.update();
}
}
} */
/// <summary>
/// This method is used to update HSN and SAC code
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">lk_SalesOrderIntergationTableV1</param>
/// <param name = "_salesTable">SalesTable</param>
public void updateHSNAndSACCode(lk_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable, SalesTable _salesTable)
{
SalesLine salesLine;
TransTaxInformation transTaxInformationLocal;
HSNCodeTable_IN hSNCodeTable_INFind;
ServiceAccountingCodeTable_IN serviceAccountingCodeTable_INFind;
TaxRateType taxRateType;
InventTable inventTable;
EcoResProduct ecoResProduct;
select firstonly salesLine
where salesLine.SalesId == _salesTable.SalesId
&& salesLine.LineNum == _lk_SalesOrderIntergationTable.LineNumber;
if (salesLine)
{
transTaxInformationLocal = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine, true);
if (transTaxInformationLocal)
{
select firstonly ProductType from ecoResProduct
join inventTable where ecoResProduct.RecId == inventTable.Product
&& inventTable.ItemId == salesLine.ItemId;
if (ecoResProduct.ProductType == EcoResProductType::Service)
{
select firstonly RecId
from serviceAccountingCodeTable_INFind
where serviceAccountingCodeTable_INFind.SAC == _lk_SalesOrderIntergationTable.SACCode;
if (serviceAccountingCodeTable_INFind.RecId)
{
transTaxInformationLocal.ServiceAccountingCodeTable = serviceAccountingCodeTable_INFind.RecId;
}
}
else
{
select firstonly RecId
from hSNCodeTable_INFind
where hSNCodeTable_INFind.Code == _lk_SalesOrderIntergationTable.HSNCode;
transTaxInformationLocal.HSNCodeTable = hSNCodeTable_INFind.RecId;
}
select firstonly RecId
from taxRateType
where taxRateType.Name == _lk_SalesOrderIntergationTable.TaxRateType;
if (taxRateType.RecId)
{
transTaxInformationLocal.TaxRateType = taxRateType.RecId;
}
transTaxInformationLocal.doUpdate();
}
}
}
/// <summary>
/// Validating Record
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <returns>str</returns>
public str validatedata(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
str retStr;
Currency currency;
CustPaymModeTable custPaymModeTable;
TaxWithholdGroupHeading taxWithholdGroupHeading;
InventLocation inventLocationFind;//inventLocationFind1;
/* InterCompanyTradingPartner interCompanyTradingPartner,interCompanyTradingPartner1;
InterCompanyTradingRelation interCompanyTradingRelation;
VendTable vendTable;*/
SalesType salesType;
PaymTerm paymTerm;
DlvMode dlvMode;
LK_SalesOrderIntergationTableV1 lk_SalesOrderIntergationTable;
salesTable salesTable;
while select lk_SalesOrderIntergationTable
where lk_SalesOrderIntergationTable.SalesOrderNumber == _lk_SalesOrderIntergationTable.SalesOrderNumber
{
select firstonly CustomerRef from salesTable
where salesTable.CustomerRef == lk_SalesOrderIntergationTable.SalesOrderNumber;
if (salesTable.CustomerRef)
{
throw Error(strFmt("@LK_Label:LKSOCustRefErr", salesTable.CustomerRef, lk_SalesOrderIntergationTable.SalesOrderNumber));
}
if (lk_SalesOrderIntergationTable.InventLocationId!= '')
{
select firstonly InventLocationId
from inventLocationFind
where inventLocationFind.InventLocationId == lk_SalesOrderIntergationTable.InventLocationId;
if (!inventLocationFind)
{
retStr += "@LK_Label:LK_WarehouseNotExist";
}
}
if (!lk_SalesOrderIntergationTable.EntityName)
{
retStr += "@LK_Label:LK_EntityNameNotFound" + ';';
}
if (lk_SalesOrderIntergationTable.TCSgroup)
{
select firstonly TaxWithholdGroupName, TaxWithholdGroup
from taxWithholdGroupHeading
where (taxWithholdGroupHeading.TaxWithholdGroupName == lk_SalesOrderIntergationTable.TCSGroup
|| taxWithholdGroupHeading.TaxWithholdGroup == lk_SalesOrderIntergationTable.TCSGroup);
if (!taxWithholdGroupHeading.TaxWithholdGroupName || !taxWithholdGroupHeading.TaxWithholdGroup)
{
retStr += "@LK_Label:LK_TCSGrpError"+ ';';
}
}
if (lk_SalesOrderIntergationTable.TermsOfPayment)
{
select firstonly PaymTermId, Cash
from paymTerm
where paymTerm.PaymTermId == lk_SalesOrderIntergationTable.TermsOfPayment;
if (paymTerm.PaymTermId)
{
if (paymTerm.Cash == NoYes::Yes)
{
if (lk_SalesOrderIntergationTable.ModeOfDelivery)
{
select firstonly Code from dlvMode where dlvMode.Code == lk_SalesOrderIntergationTable.ModeOfDelivery;
if (!dlvMode.Code)
{
retStr += "@LK_Label:LK_ModeOfDeliveryDoesNotExist"+ ';';
}
}
else
{
//Mode of delivery not exist.
retStr += "@LK_Label:ModeOfDelivery"+ ';';
}
}
}
else
{
//Term of payment not exist.
retStr += "@LK_Label:LK_TermOfPaymentDoesNotExist"+ ';';
}
}
if (lk_SalesOrderIntergationTable.ModeOfPayment)
{
select firstonly Name, PaymMode
from custPaymModeTable
where (custPaymModeTable.Name == lk_SalesOrderIntergationTable.MethodOfPayment
|| custPaymModeTable.PaymMode == lk_SalesOrderIntergationTable.MethodOfPayment);
if (lk_SalesOrderIntergationTable.ModeOfPayment)
{
if (!custPaymModeTable.Name || !custPaymModeTable.PaymMode)
{
retStr += "@LK_Label:LK_ModeOfPaymentErrS"+ ';';
}
}
}
if (lk_SalesOrderIntergationTable.CurrencyCode)
{
select firstonly CurrencyCode
from currency
where currency.CurrencyCode == lk_SalesOrderIntergationTable.CurrencyCode;
if (!currency.CurrencyCode)
{
retStr += "@LK_Label:LK_SalesCurrencyErrors"+ ';';
}
}
if (!lk_SalesOrderIntergationTable.OrderType)
{
retStr += strFmt("@LK_Label:SalesTypedoesnotexist",lk_SalesOrderIntergationTable.OrderType) + ';';
}
else
{
if (lk_SalesOrderIntergationTable.OrderType != SalesType::Sales)
{
if( lk_SalesOrderIntergationTable.OrderType!= SalesType::ReturnItem )
{
retStr += strFmt("@LK_Label:SalesTypedoesnotexist",lk_SalesOrderIntergationTable.OrderType) + ';';
}
}
}
/* select firstonly AccountNum,DataAreaId,Party
from vendTable
where vendTable.AccountNum == _LK_SalesOrderIntergationTableV1Staging.SourcingVendor
join interCompanyTradingPartner
where interCompanyTradingPartner.VendorDataAreaId == vendTable.DataAreaId
&& interCompanyTradingPartner.VendorParty == vendTable.Party;
if (ret && vendTable)
{
select firstonly InterCompanyTradingVendor
from interCompanyTradingRelation
where interCompanyTradingRelation.InterCompanyTradingVendor == interCompanyTradingPartner.RecId;
select firstonly RecId
from interCompanyTradingPartner1
where interCompanyTradingPartner1.RecId == interCompanyTradingRelation.InterCompanyTradingCustomer;
if (interCompanyTradingPartner1)
{
changecompany (interCompanyTradingPartner1.CustomerDataAreaId)
{
select firstonly crosscompany inventLocationFind1
where inventLocationFind1.InventLocationId == this.InventLocationId
&& inventLocationFind1.DataAreaId == interCompanyTradingPartner1.CustomerDataAreaId;
if (!inventLocationFind1 && interCompanyTradingPartner1.CustomerDataAreaId != '')
{
ret = checkFailed(strFmt(literalStr("@LK_Label:WarehouseNotFoundinDataAreaId"), this.InventLocationId, inventLocationFind1.DataAreaId));
}
}
}
} */
}
return retStr;
}
/// <summary>
/// Creating sales order
/// </summary>
/// <param name = "_LK_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <returns>SalesTable</returns>
Public SalesTable CreateSalesOrder(LK_SalesOrderIntergationTableV1 _LK_SalesOrderIntergationTable)
{
SalesTable salesTable;
custTable custTable;
SalesTable_W salesTable_W;
custPaymModeTable custPaymModeTable;
InventLocation inventLocation;
InventSite inventSite;
NumberSeq numberSeqSO;
LK_SalesOrderIntegrationEntityHelper lk_SalesOrderIntegrationEntityHelper = new LK_SalesOrderIntegrationEntityHelper();
select firstonly CustomerRef from salesTable
where salesTable.CustomerRef == _LK_SalesOrderIntergationTable.SalesOrderNumber;
if (salesTable.CustomerRef)
{
throw Error(strFmt("@LK_Label:LKSOCustRefErr", salesTable.CustomerRef, _LK_SalesOrderIntergationTable.SalesOrderNumber));
}
salesTable.clear();
custTable = CustTable::find(_LK_SalesOrderIntergationTable.CustomerAccount);
if (!custTable)
{
lk_SalesOrderIntegrationEntityHelper.CreateCustForSO(_LK_SalesOrderIntergationTable, lk_SalesOrderIntegrationEntityHelper);
}
salesTable.LK_E_Invoicing = _LK_SalesOrderIntergationTable.isIntegrated;
salesTable.CustomerRef = _LK_SalesOrderIntergationTable.SalesOrderNumber;
salesTable.LK_IRNCode = _LK_SalesOrderIntergationTable.IRNCode;
numberSeqSO = NumberSeq::newGetNum(SalesParameters::numRefSalesId(), true);
salesTable.SalesId = numberSeqSO.num();
salesTable.initValue();
salesTable.CustAccount = _LK_SalesOrderIntergationTable.CustomerAccount;
salesTable.initFromCustTable();
salesTable.TCSGroup_IN = _LK_SalesOrderIntergationTable.TCSGroup;
salesTable.LKSalesType = _LK_SalesOrderIntergationTable.OrderType;
if (salesTable.LKSalesType == SalesType::ReturnItem)
{
salesTable.ReturnItemNum = _LK_SalesOrderIntergationTable.RMANumber;
}
SalesTable.CustomsExportOrder_IN = _LK_SalesOrderIntergationTable.ExportOrder;
salesTable.ExportReason = _LK_SalesOrderIntergationTable.ExportReason;
salesTable.CurrencyCode = _LK_SalesOrderIntergationTable.CurrencyCode;
salesTable.TDSGroup_IN = _LK_SalesOrderIntergationTable.TDSGroup;
salesTable.DeliveryName = _LK_SalesOrderIntergationTable.DeliveryName;
salesTable.DlvMode = _LK_SalesOrderIntergationTable.DlvMode;
salesTable.Payment = _LK_SalesOrderIntergationTable.TermsOfPayment;
salesTable.LKWebOrderNo = _LK_SalesOrderIntergationTable.WebOrderNo;
salesTable.ContactPersonId = _LK_SalesOrderIntergationTable.ContactPersonId;
salesTable.LK_CustomerReference = _LK_SalesOrderIntergationTable.CustomerReference;
salesTable.Fulfillment_WH = _LK_SalesOrderIntergationTable.Fulfillment_WH;
salesTable.LK_ConsumableItem = _LK_SalesOrderIntergationTable.ConsumableItem;
select firstonly PaymMode from custPaymModeTable
where custPaymModeTable.Name == _LK_SalesOrderIntergationTable.MethodOfPayment;
if (custPaymModeTable)
{
salesTable.PaymMode = custPaymModeTable.PaymMode;
}
salesTable.InvoiceAccount = _LK_SalesOrderIntergationTable.InvoiceAccount;
salesTable.Phone = _LK_SalesOrderIntergationTable.Phone;
salesTable.Email = _LK_SalesOrderIntergationTable.Email;
salesTable.LKCourierCode = _LK_SalesOrderIntergationTable.CourierCode;
salesTable.LKModeOfPayment = _LK_SalesOrderIntergationTable.ModeOfPayment;
salesTable.InventLocationId = _LK_SalesOrderIntergationTable.InventLocationId;
select firstonly InventSiteId from inventLocation
where inventLocation.InventLocationId == _LK_SalesOrderIntergationTable.InventLocationId;
salesTable.InventSiteId = inventLocation.InventSiteId;
if (_LK_SalesOrderIntergationTable.OrderCreationDate == dateNull())
{
salesTable.LKOrderCreationDate = DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone());
}
else
{
salesTable.LKOrderCreationDate = _LK_SalesOrderIntergationTable.OrderCreationDate;
}
if (_LK_SalesOrderIntergationTable.DeliveryName
&& _LK_SalesOrderIntergationTable.AddressCountryRegionId
&& _LK_SalesOrderIntergationTable.AddressStreet
&& _LK_SalesOrderIntergationTable.AddressState
&& _LK_SalesOrderIntergationTable.AddressCity
&& _LK_SalesOrderIntergationTable.AddressZipCode)
{
salesTable.DeliveryPostalAddress = lk_SalesOrderIntegrationEntityHelper.setDeliveryAddress(_LK_SalesOrderIntergationTable);
}
else
{
salesTable.DeliveryPostalAddress = custTable.postalAddressRecId();
}
salesTable.LK_RefInvoiceNo = _LK_SalesOrderIntergationTable.RefInvoiceNo;
select firstonly DefaultDimension from inventSite
where inventSite.SiteId == salesTable.InventSiteId;
salesTable.DefaultDimension = LK_FinancialDimensionHelper::getDimensionNew('',
DimensionSetEntity::find(custTable.DefaultDimension).DisplayValue,
DimensionSetEntity::find(inventSite.DefaultDimension).DisplayValue,
_LK_SalesOrderIntergationTable.Brand,
_LK_SalesOrderIntergationTable.Classification,
_LK_SalesOrderIntergationTable.CostCenter,
_LK_SalesOrderIntergationTable.NavChannel,
_LK_SalesOrderIntergationTable.SBRT,
_LK_SalesOrderIntergationTable.Store);
salesTable.LK_Integration = NoYes::Yes;
salesTable.insert();
if (SalesTable.CustomsExportOrder_IN == NoYes::Yes) // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
select firstonly forupdate WithIGSTPayment_IN from salesTable_W
where salesTable_W.SalesTable == salesTable.RecId;
if (salesTable_W.SalesTable) // LK_IDD_020_021_030_036_SalesOrderService - Start 6-19-2025 - V.Srikanth
{
salesTable_W.WithIGSTPayment_IN = _LK_SalesOrderIntergationTable.IsWithTax;
salesTable_W.update();
}
}
return salesTable;
}
/// <summary>
/// updateTaxInfoLocation
/// </summary>
/// <param name = "_salesTable">SalesTable</param>
/// <param name = "_purchTable">PurchTable</param>
/// <param name = "_dataAreaid">str</param>
/* public void updateTaxInfoLocation(SalesTable _salesTable, PurchTable _purchTable, str _dataAreaid)
{
TaxInformation_IN taxInformation_IN;
TransTaxInformation transTaxInformationSales, transTaxInformationPurch;
SalesLine salesLine;
PurchLine purchLine;
LogisticsLocation logisticsLocation;
str locationCode, hsnCode,sacCode;
HSNCodeTable_IN hsnCodeTable;
ServiceAccountingCodeTable_IN serviceAccountingCodeTable_IN;
TaxRateType taxrateType;
str taxrate;
changecompany (_dataAreaid)
{
while select purchLine
where purchLine.PurchId == _purchTable.PurchId
&& purchLine.DataAreaId == _dataAreaid
{
hsnCode = '';
locationCode = '';
transTaxInformationPurch = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(purchLine);
taxrate = TaxrateType::find(transTaxInformationPurch.TaxRateType).Name;
sacCode = '';
if (transTaxInformationPurch)
{
locationCode = LogisticsLocation::find(transTaxInformationPurch.CompanyLocation).Description;
if (transTaxInformationPurch.HSNCodeTable)
{
hsnCodeTable = HSNCodeTable_IN::find(transTaxInformationPurch.HSNCodeTable);
}
else
{
serviceAccountingCodeTable_IN = ServiceAccountingCodeTable_IN::find(transTaxInformationPurch.ServiceAccountingCodeTable);
}
if (hsnCodeTable)
{
hsnCode = hsnCodeTable.Code;
}
if (serviceAccountingCodeTable_IN)
{
sacCode = serviceAccountingCodeTable_IN.SAC;
}
salesLine = purchLine.interCompanySalesLine();
changecompany (salesLine.DataAreaId)
{
transTaxInformationSales = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine, true);
if(transTaxInformationSales)
{
// update sales line tax info exempt from sales line item.
transTaxInformationSales.Exempt = salesLine.inventTable().Exempt_IN;
if(locationCode)
{
select firstonly logisticsLocation
where logisticsLocation.RecId == transTaxInformationPurch.CompanyLocation
&& logisticsLocation.Description == locationCode
join RecId from taxInformation_IN
where taxInformation_IN.RegistrationLocation == logisticsLocation.RecId
&& taxInformation_IN.IsPrimary == NoYes::Yes;
if (logisticsLocation)
{
transTaxInformationSales.CustomerLocation = logisticsLocation.RecId;
}
if (taxInformation_IN)
{
transTaxInformationSales.CustomerTaxInformation = taxInformation_IN.RecId;
}
}
if (hsnCode)
{
hsnCodeTable.clear();
select firstonly RecId from hsnCodeTable where hsnCodeTable.Code == hsnCode
&& hsnCodeTable.DataAreaId == transTaxInformationSales.DataAreaId;
if (hsnCodeTable.RecId)
{
transTaxInformationSales.HSNCodeTable = hsnCodeTable.RecId;
taxrateType.clear();
select firstonly taxrateType where taxrateType.Name == taxrate;
transTaxInformationSales.TaxRateType = taxrateType.RecId;
taxrate = '';
}
else
{
throw error(strFmt(literalStr("@LK_Label:HSNCodeNotFoundInDataAreaid"), hsnCode, transTaxInformationSales.DataAreaId));
}
}
if (sacCode)
{
serviceAccountingCodeTable_IN.clear();
select firstonly RecId from serviceAccountingCodeTable_IN where serviceAccountingCodeTable_IN.SAC == sacCode
&& serviceAccountingCodeTable_IN.DataAreaId == transTaxInformationSales.DataAreaId;
if (serviceAccountingCodeTable_IN.RecId)
{
transTaxInformationSales.ServiceAccountingCodeTable = serviceAccountingCodeTable_IN.RecId;
taxrateType.clear();
select firstonly taxrateType where taxrateType.Name == taxrate;
transTaxInformationSales.TaxRateType = taxrateType.RecId;
taxrate = '';
}
else
{
throw error(strFmt(literalStr("@LK_Label:SACNotFoundInDataAreaId"), sacCode, transTaxInformationSales.DataAreaId));
}
}
transTaxInformationSales.update();
}
}
}
}
}
} */
/// <summary>
/// This method is to update Assessable Value.
/// </summary>
/// <param name = "_salesTable">_salesTable</param>
/// <param name = "_custExportOrder">_custExportOrder</param>
/// <param name = "_salesId">_salesId</param>
/// <param name = "_lk_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
public void updateSalesLine_IN(SalesTable _salesTable,
NoYesId _custExportOrder,
SalesIdBase _salesId,
LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
TransTaxInformation transTaxInformationSales;
SalesLine salesLineLoc;
SalesLine_IN salesLine_IN;
CustomsExportAssessableValue_IN customsExportAssessableValue;
select firstonly forupdate salesLineLoc
where salesLineLoc.SalesId == _salesTable.SalesId;
salesLine_IN = salesLineLoc.salesLine_IN();
transTaxInformationSales = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLineLoc, true);
if (transTaxInformationSales)
{
if (_lk_SalesOrderIntergationTable.Exempt == NoYes::Yes)
{
transTaxInformationSales.Exempt = NoYes::Yes;
}
if (transTaxInformationSales.Exempt == NoYes::No)
{
// update sales line tax info exempt from sales line item.
transTaxInformationSales.Exempt = salesLineLoc.inventTable().Exempt_IN;
transTaxInformationSales.update();
}
}
salesLine_IN.selectForUpdate(true);
salesLine_IN.TCSGroup = _salesTable.TCSGroup_IN;
salesLine_IN.TDSGroup = _salesTable.TDSGroup_IN;
salesLine_IN.update();
if (_custExportOrder == NoYes::Yes)
{
customsExportAssessableValue = CustomsExportAssessableValue_IN::findInventTransId(salesLineLoc.InventTransId);
if (customsExportAssessableValue.RecId != 0)
{
customsExportAssessableValue.selectForUpdate(true);
customsExportAssessableValue.Amount = salesLineLoc.LineAmount;
customsExportAssessableValue.Value = CustomsExportAssessableValue_IN::getMarkupValue(salesLineLoc.TableId, salesLineLoc.RecId, salesLineLoc.InventTransId);
customsExportAssessableValue.update();
salesLine_IN.AssessableValueTransactionCurrency = CustomsExportAssessableValue_IN::findInventTransId(salesLineLoc.InventTransId).invoiceAssessableValue();
}
else
{
salesLine_IN.AssessableValueTransactionCurrency = salesLineLoc.LineAmount - CustomsExportAssessableValue_IN::getMarkupValue(salesLineLoc.TableId, salesLineLoc.RecId, salesLineLoc.InventTransId);
}
}
else
{
salesLine_IN.AssessableValueTransactionCurrency = salesLineLoc.getMiscChargesAmount_IN();
}
salesLineLoc.packSalesLine_IN(salesLine_IN);
salesLineLoc.update();
}
/// <summary>
/// creating Sales order with all the lines process.
/// </summary>
/// <param name = "_lk_SalesOrderIntergationTable">LK_SalesOrderIntergationTableV1</param>
/// <returns>SalesId</returns>
public SalesId processSingleSO(LK_SalesOrderIntergationTableV1 _lk_SalesOrderIntergationTable)
{
SalesTable salesTable;
salesTable = this.CreateSalesOrder(_lk_SalesOrderIntergationTable);
if (salesTable)
{
this.createSalesOrderLine(_lk_SalesOrderIntergationTable,salesTable);
this.createMiscChargesLinesByList(_lk_SalesOrderIntergationTable,salesTable.SalesId);
this.createMiscChargesHeaderByList(_lk_SalesOrderIntergationTable,salesTable,MarkupAllocateAfter::NetAmount);
// settleprePaymentMarking, settleExchangeMarking method are not executing for sales order creation
/* this.settleprePaymentMarking(lk_SalesOrderIntergationTable.SalesOrderNumber);
this.settleExchangeMarking(lk_SalesOrderIntergationTable.SalesOrderNumber);*/
// commented for international SO not for indian SO - start
/* purchTable purchTable;
this.updateTDSandTCSGroupOrigSO(salesTable);
this.updateIntecompanySalesOrder(_lk_SalesOrderIntergationTable, salesTable);
this.purchline_TaxLocationUpdate(_lk_SalesOrderIntergationTable, salesTable);
purchTable = this.createDropshipPO(_lk_SalesOrderIntergationTable, salesTable);
if (purchTable && salesTable.RecId)
{
this.updateTaxInfoLocation(salesTable, purchTable, _lk_SalesOrderIntergationTable.LegalEntity);
}
salesTable.clear();
select firstonly forupdate salesTable
where salesTable.CustomerRef == _lk_SalesOrderIntergationTable.SalesOrderNumber
&& salesTable.InterCompanyOrder == NoYes::Yes;
if (salesTable.RecId)
{
salesTable.InventLocationId = _lk_SalesOrderIntergationTable.InventLocationId;
salesTable.InventSiteId = InventLocation::find(_lk_SalesOrderIntergationTable.InventLocationId).InventSiteId;
salesTable.update();
this.updateSalesOrder(_lk_SalesOrderIntergationTable, salesTable.SalesId);
} */
// commented for international SO not for indian SO - End
}
return salesTable.SalesId;
}
}
-----------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment