class CICledgerJournalDetails
{
LedgerJournalTransTaxExtensionIN ledgerJournalTransTaxExtensionIN;
LedgerJournalTable ledgerJournalTable;
LedgerJournalTrans ledgerJournalTrans;
SalesParameters salesParameters;
ledgerParameters ledgerParameters;
LedgerJournalName ledgerJournalName;
NumberSeq numberSeq;
NumberSequenceTable numSeqTable,numberSequenceTable;
container ledgerDimension,offsetDimension;
RecId offsetledgerrecid;
DimensionDisplayValue dimensionDisplayValue;
CICLedgerJournalTableExt ledgerJournalTableExt;
CICLedgerJournalTransExt ledgerJournalTransExt;
int64 ledgerDim, OffsetledgerDim,DefDimension,LedgerOffsetAccountValue;
Name LedgerAccountValue,LedgerOffsetAcc;
RefRecId refRecId;
CICCreditCommittal creditCommittalDetails;
CICGBPDC gBPDCDetails;
CICPettyCashRequisition cicPettycshReq;
LedgerJournalACType LedgerJournalACTypepetty;
CICPettyCashReplenishment pettyCashRep;
CICPettyCashClaim pettyCashCla;
CICPettyCashAutoGLLog postingLogTable;
LedgerJournalCheckPost ledgerJournalValidate, ledgerJournalPost;
int counter;
NumberSeq numberSeqDetails;
purchParameters purchParameters;
CICInternalRequisitionTable internalRequisitionLocal;
CustPaymModeTable custPaymModeTable;
CompanyInfo companyInfo;
CustParameters custParameters;
#define.checkInvoiceAmount("Please check the invoice amount.")
}
---------------------------------------------------------------------------------------------------------------------
public RefRecId GBPDCCreateJournal(CICGBPDC gBPDC)
{
ttsBegin;
if (counter == 0 )
{
select firstOnly JournalName from SalesParameters;
ledgerJournalTable.JournalName = SalesParameters.JournalName;
ledgerJournalTable.initFromLedgerJournalName(ledgerJournalTable.JournalName);
ledgerJournalTable.insert();
select firstOnly LedgerJournalTable, RecId from ledgerJournalTableExt
where ledgerJournalTableExt.LedgerJournalTable == ledgerJournalTable.RecId;
if(!ledgerJournalTableExt.RecId)
{
ledgerJournalTableExt.LedgerJournalTable = ledgerJournalTable.RecId;
ledgerJournalTableExt.insert();
refRecId = ledgerJournalTableExt.recid;
}
}
counter++;
select firstonly NumberSequenceTable, JournalName from ledgerJournalName
where ledgerJournalName.JournalName == ledgerJournalTable.JournalName
join NumberSequence from numberSequenceTable
where numberSequenceTable.RecId == ledgerJournalName.NumberSequenceTable;
numberSeq = NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence);
ledgerJournalTrans.JournalNum = ledgerJournalTable.JournalNum;
ledgerJournalTrans.voucher = numberseq.voucher();
ledgerJournalTrans.initValue();
LedgerJournaltrans.initFromLedgerJournalTable_LT(ledgerJournalTable);
DefDimension = this.DefaultDimension(gBPDC.Divisions,gBPDC.ProfitCenter,"");
ledgerJournalTrans.Txt = gBPDC.Text;
ledgerJournalTrans.TransDate = gBPDC.CommittalDate;
LedgerJournalTrans.MarkedInvoice = gBPDC.Invoice;
ledgerJournalTrans.AmountCurCredit = gBPDC.Amount;
ledgerJournalTrans.CurrencyCode = CompanyInfo::standardCurrency();
ledgerJournalTrans.Company = curext();
LedgerJournalTrans.AcknowledgementDate = systemDateGet();
ledgerJournalTrans.PaymMode = gBPDC.PaymMode;
ledgerJournalTrans.PaymReference = gBPDC.PaymReference;
LedgerJournalTrans.CICDrawerName = gBPDC.DrawerName;
LedgerJournalTrans.CICDrawersBank = gBPDC.DrawersBank;
ledgerJournalTrans.CICCommissionPayoff = gBPDC.CommissionPayoff;
ledgerJournalTrans.Approved = NoYes::Yes;
ledgerJournalTrans.Approver = HcmWorker::userId2Worker(curUserId());
ledgerJournalTrans.Due = ledgerJournalTrans.TransDate;
changecompany(ledgerJournalTrans.Company)
{
select firstOnly PostingProfile from custParameters
index Key
where custParameters.Key == 0;
ledgerJournalTrans.PostingProfile = custParameters.PostingProfile;//CustParameters::findByCompany(ledgerJournalTrans.Company).PostingProfile;
}
ledgerJournalTrans.AccountType = LedgerJournalACType::Cust;
LedgerAccountValue = gBPDC.Customer;
ledgerJournalTrans.TransactionType = LedgerTransType::Payment;
if(LedgerAccountValue)
{
if(ledgerJournalTrans.AccountType == LedgerJournalACType::Cust)
{
ledgerDim = DimensionStorage::getDynamicAccount(LedgerAccountValue, ledgerJournalTrans.AccountType);
LedgerJournalTrans.LedgerDimension = DimensionAttributeValueCombination::find(ledgerDim).Recid;
LedgerJournalTrans.DefaultDimension = DefDimension;
}
}
select firstonly OffsetAccountType, JournalName from ledgerJournalName
where ledgerJournalName.JournalName == ledgerJournalTable.JournalName;
ledgerJournalTrans.OffsetAccountType = ledgerJournalName.OffsetAccountType;
select firstonly PaymMode, InterCompanyLedgerDimension from custPaymModeTable
where custPaymModeTable.PaymMode == gBPDC.PaymMode;
LedgerOffsetAccountValue = custPaymModeTable.InterCompanyLedgerDimension;
LedgerJournalTrans.OffsetDefaultDimension = DefDimension;
if(LedgerOffsetAccountValue)
{
if(ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger)
{
OffsetledgerDim = DimensionDefaultingService::serviceCreateLedgerDimension(LedgerOffsetAccountValue, DefDimension);
LedgerJournalTrans.OffsetLedgerDimension = OffsetledgerDim;
}
else
{
LedgerJournalTrans.OffsetLedgerDimension = LedgerOffsetAccountValue;
}
}
ledgerJournalTrans.LineNum = LedgerJournalTrans::lastLineNum(ledgerJournalTrans.JournalNum) + 1;
ledgerJournalTrans.ExchRate = Currency::exchRate(ledgerJournalTrans.CurrencyCode, ledgerJournalTrans.TransDate);
ledgerJournalTrans.insert();
ledgerJournalTransTaxExtensionIN.LedgerJournalTrans = LedgerJournalTrans.RecId;
ledgerJournalTransTaxExtensionIN.TaxInformation_IN = TaxInformation_IN::findDefaultbyLocation(CompanyInfo::findByCompany_IN().PrimaryAddressLocation).RecId;
ledgerJournalTransTaxExtensionIN.insert();
select firstOnly ledgerJournalTrans, GBPDCId, AccountTypeId, RecId from ledgerJournalTransExt
where ledgerJournalTransExt.ledgerJournalTrans == ledgerJournalTrans.RecId;
if(!ledgerJournalTransExt.RecId)
{
ledgerJournalTransExt.GBPDCId = gBPDC.GBPDCId;
ledgerJournalTransExt.AccountTypeId = gBPDC.AccountTypeId;
ledgerJournalTransExt.ledgerJournalTrans = ledgerJournalTrans.RecId;
ledgerJournalTransExt.insert();
}
select firstOnly forupdate recid, JournalNo from gBPDCDetails
where gBPDCDetails.recid == gBPDC.RecId;
if (gBPDCDetails.RecId)
{
gBPDCDetails.JournalNo = ledgerJournalTable.JournalNum;
gBPDCDetails.update();
}
this.GBPDCcustomerSettlement(gBPDC);
ttsCommit;
return refRecId;
}
------------------------------------------------------------------------------------------------------------------------
public void GBPDCCustomerSettlement(CICGBPDC _gBPDC)
{
custvendopentransmanager manager;
CustTransOpen CustTransOpen;
CustTrans CustTransExt;
ExchangeRateHelper exchangeRateHelper;
AmountCur totalSettlement;
select firstOnly AccountNum, RefRecId, AmountCur from CustTransopen
where CustTransOpen.AccountNum == _gBPDC.Customer
join Invoice, RecId, AccountNum from CustTransExt
where CustTransExt.Invoice == _gBPDC.Invoice
&& CustTransExt.RecId == CustTransopen.RefRecId
&& CustTransExt.AccountNum == CustTransOpen.AccountNum;
if(CustTransopen && CustTransOpen.AmountCur >= _gBPDC.Amount)
{
manager = custvendopentransmanager::construct(ledgerJournalTrans);
manager.updateTransMarked(CustTransOpen,true);
select firstonly RecId from companyInfo
where companyInfo.DataArea == ledgerJournalTrans.Company;
exchangeRateHelper = ExchangeRateHelper::newCurrency(Ledger::primaryLedger(companyInfo.RecId),ledgerJournalTrans.CurrencyCode);
totalSettlement = SpecTransManager::getTotalSettleAmountForSpecReference(
ledgerJournalTrans.Company,
ledgerJournalTrans.TableId,
ledgerJournalTrans.RecId,
ledgerJournalTrans.CurrencyCode,
ledgerJournalTrans.Company,
ledgerJournalTrans.TransDate,
exchangeRateHelper.prepareExchangeRateForStorage(ledgerJournalTrans.crossrate()));
//To update in ledgerJournal trans
ttsBegin;
ledgerJournalTrans.selectForUpdate(true);
ledgerJournalTrans.AmountCurCredit = _gBPDC.Amount <= abs(totalSettlement) ? _gBPDC.Amount : 0;
ledgerJournalTrans.SettleVoucher = SettlementType::SelectedTransact;
ledgerJournalTrans.MarkedInvoice = _gBPDC.Invoice;
ledgerJournalTrans.doupdate();
ttsCommit;
}
else
{
checkFailed(#checkInvoiceAmount);
}
}
{
LedgerJournalTransTaxExtensionIN ledgerJournalTransTaxExtensionIN;
LedgerJournalTable ledgerJournalTable;
LedgerJournalTrans ledgerJournalTrans;
SalesParameters salesParameters;
ledgerParameters ledgerParameters;
LedgerJournalName ledgerJournalName;
NumberSeq numberSeq;
NumberSequenceTable numSeqTable,numberSequenceTable;
container ledgerDimension,offsetDimension;
RecId offsetledgerrecid;
DimensionDisplayValue dimensionDisplayValue;
CICLedgerJournalTableExt ledgerJournalTableExt;
CICLedgerJournalTransExt ledgerJournalTransExt;
int64 ledgerDim, OffsetledgerDim,DefDimension,LedgerOffsetAccountValue;
Name LedgerAccountValue,LedgerOffsetAcc;
RefRecId refRecId;
CICCreditCommittal creditCommittalDetails;
CICGBPDC gBPDCDetails;
CICPettyCashRequisition cicPettycshReq;
LedgerJournalACType LedgerJournalACTypepetty;
CICPettyCashReplenishment pettyCashRep;
CICPettyCashClaim pettyCashCla;
CICPettyCashAutoGLLog postingLogTable;
LedgerJournalCheckPost ledgerJournalValidate, ledgerJournalPost;
int counter;
NumberSeq numberSeqDetails;
purchParameters purchParameters;
CICInternalRequisitionTable internalRequisitionLocal;
CustPaymModeTable custPaymModeTable;
CompanyInfo companyInfo;
CustParameters custParameters;
#define.checkInvoiceAmount("Please check the invoice amount.")
}
---------------------------------------------------------------------------------------------------------------------
public RefRecId GBPDCCreateJournal(CICGBPDC gBPDC)
{
ttsBegin;
if (counter == 0 )
{
select firstOnly JournalName from SalesParameters;
ledgerJournalTable.JournalName = SalesParameters.JournalName;
ledgerJournalTable.initFromLedgerJournalName(ledgerJournalTable.JournalName);
ledgerJournalTable.insert();
select firstOnly LedgerJournalTable, RecId from ledgerJournalTableExt
where ledgerJournalTableExt.LedgerJournalTable == ledgerJournalTable.RecId;
if(!ledgerJournalTableExt.RecId)
{
ledgerJournalTableExt.LedgerJournalTable = ledgerJournalTable.RecId;
ledgerJournalTableExt.insert();
refRecId = ledgerJournalTableExt.recid;
}
}
counter++;
select firstonly NumberSequenceTable, JournalName from ledgerJournalName
where ledgerJournalName.JournalName == ledgerJournalTable.JournalName
join NumberSequence from numberSequenceTable
where numberSequenceTable.RecId == ledgerJournalName.NumberSequenceTable;
numberSeq = NumberSeq::newGetVoucherFromCode(numberSequenceTable.NumberSequence);
ledgerJournalTrans.JournalNum = ledgerJournalTable.JournalNum;
ledgerJournalTrans.voucher = numberseq.voucher();
ledgerJournalTrans.initValue();
LedgerJournaltrans.initFromLedgerJournalTable_LT(ledgerJournalTable);
DefDimension = this.DefaultDimension(gBPDC.Divisions,gBPDC.ProfitCenter,"");
ledgerJournalTrans.Txt = gBPDC.Text;
ledgerJournalTrans.TransDate = gBPDC.CommittalDate;
LedgerJournalTrans.MarkedInvoice = gBPDC.Invoice;
ledgerJournalTrans.AmountCurCredit = gBPDC.Amount;
ledgerJournalTrans.CurrencyCode = CompanyInfo::standardCurrency();
ledgerJournalTrans.Company = curext();
LedgerJournalTrans.AcknowledgementDate = systemDateGet();
ledgerJournalTrans.PaymMode = gBPDC.PaymMode;
ledgerJournalTrans.PaymReference = gBPDC.PaymReference;
LedgerJournalTrans.CICDrawerName = gBPDC.DrawerName;
LedgerJournalTrans.CICDrawersBank = gBPDC.DrawersBank;
ledgerJournalTrans.CICCommissionPayoff = gBPDC.CommissionPayoff;
ledgerJournalTrans.Approved = NoYes::Yes;
ledgerJournalTrans.Approver = HcmWorker::userId2Worker(curUserId());
ledgerJournalTrans.Due = ledgerJournalTrans.TransDate;
changecompany(ledgerJournalTrans.Company)
{
select firstOnly PostingProfile from custParameters
index Key
where custParameters.Key == 0;
ledgerJournalTrans.PostingProfile = custParameters.PostingProfile;//CustParameters::findByCompany(ledgerJournalTrans.Company).PostingProfile;
}
ledgerJournalTrans.AccountType = LedgerJournalACType::Cust;
LedgerAccountValue = gBPDC.Customer;
ledgerJournalTrans.TransactionType = LedgerTransType::Payment;
if(LedgerAccountValue)
{
if(ledgerJournalTrans.AccountType == LedgerJournalACType::Cust)
{
ledgerDim = DimensionStorage::getDynamicAccount(LedgerAccountValue, ledgerJournalTrans.AccountType);
LedgerJournalTrans.LedgerDimension = DimensionAttributeValueCombination::find(ledgerDim).Recid;
LedgerJournalTrans.DefaultDimension = DefDimension;
}
}
select firstonly OffsetAccountType, JournalName from ledgerJournalName
where ledgerJournalName.JournalName == ledgerJournalTable.JournalName;
ledgerJournalTrans.OffsetAccountType = ledgerJournalName.OffsetAccountType;
select firstonly PaymMode, InterCompanyLedgerDimension from custPaymModeTable
where custPaymModeTable.PaymMode == gBPDC.PaymMode;
LedgerOffsetAccountValue = custPaymModeTable.InterCompanyLedgerDimension;
LedgerJournalTrans.OffsetDefaultDimension = DefDimension;
if(LedgerOffsetAccountValue)
{
if(ledgerJournalTrans.OffsetAccountType == LedgerJournalACType::Ledger)
{
OffsetledgerDim = DimensionDefaultingService::serviceCreateLedgerDimension(LedgerOffsetAccountValue, DefDimension);
LedgerJournalTrans.OffsetLedgerDimension = OffsetledgerDim;
}
else
{
LedgerJournalTrans.OffsetLedgerDimension = LedgerOffsetAccountValue;
}
}
ledgerJournalTrans.LineNum = LedgerJournalTrans::lastLineNum(ledgerJournalTrans.JournalNum) + 1;
ledgerJournalTrans.ExchRate = Currency::exchRate(ledgerJournalTrans.CurrencyCode, ledgerJournalTrans.TransDate);
ledgerJournalTrans.insert();
ledgerJournalTransTaxExtensionIN.LedgerJournalTrans = LedgerJournalTrans.RecId;
ledgerJournalTransTaxExtensionIN.TaxInformation_IN = TaxInformation_IN::findDefaultbyLocation(CompanyInfo::findByCompany_IN().PrimaryAddressLocation).RecId;
ledgerJournalTransTaxExtensionIN.insert();
select firstOnly ledgerJournalTrans, GBPDCId, AccountTypeId, RecId from ledgerJournalTransExt
where ledgerJournalTransExt.ledgerJournalTrans == ledgerJournalTrans.RecId;
if(!ledgerJournalTransExt.RecId)
{
ledgerJournalTransExt.GBPDCId = gBPDC.GBPDCId;
ledgerJournalTransExt.AccountTypeId = gBPDC.AccountTypeId;
ledgerJournalTransExt.ledgerJournalTrans = ledgerJournalTrans.RecId;
ledgerJournalTransExt.insert();
}
select firstOnly forupdate recid, JournalNo from gBPDCDetails
where gBPDCDetails.recid == gBPDC.RecId;
if (gBPDCDetails.RecId)
{
gBPDCDetails.JournalNo = ledgerJournalTable.JournalNum;
gBPDCDetails.update();
}
this.GBPDCcustomerSettlement(gBPDC);
ttsCommit;
return refRecId;
}
------------------------------------------------------------------------------------------------------------------------
public void GBPDCCustomerSettlement(CICGBPDC _gBPDC)
{
custvendopentransmanager manager;
CustTransOpen CustTransOpen;
CustTrans CustTransExt;
ExchangeRateHelper exchangeRateHelper;
AmountCur totalSettlement;
select firstOnly AccountNum, RefRecId, AmountCur from CustTransopen
where CustTransOpen.AccountNum == _gBPDC.Customer
join Invoice, RecId, AccountNum from CustTransExt
where CustTransExt.Invoice == _gBPDC.Invoice
&& CustTransExt.RecId == CustTransopen.RefRecId
&& CustTransExt.AccountNum == CustTransOpen.AccountNum;
if(CustTransopen && CustTransOpen.AmountCur >= _gBPDC.Amount)
{
manager = custvendopentransmanager::construct(ledgerJournalTrans);
manager.updateTransMarked(CustTransOpen,true);
select firstonly RecId from companyInfo
where companyInfo.DataArea == ledgerJournalTrans.Company;
exchangeRateHelper = ExchangeRateHelper::newCurrency(Ledger::primaryLedger(companyInfo.RecId),ledgerJournalTrans.CurrencyCode);
totalSettlement = SpecTransManager::getTotalSettleAmountForSpecReference(
ledgerJournalTrans.Company,
ledgerJournalTrans.TableId,
ledgerJournalTrans.RecId,
ledgerJournalTrans.CurrencyCode,
ledgerJournalTrans.Company,
ledgerJournalTrans.TransDate,
exchangeRateHelper.prepareExchangeRateForStorage(ledgerJournalTrans.crossrate()));
//To update in ledgerJournal trans
ttsBegin;
ledgerJournalTrans.selectForUpdate(true);
ledgerJournalTrans.AmountCurCredit = _gBPDC.Amount <= abs(totalSettlement) ? _gBPDC.Amount : 0;
ledgerJournalTrans.SettleVoucher = SettlementType::SelectedTransact;
ledgerJournalTrans.MarkedInvoice = _gBPDC.Invoice;
ledgerJournalTrans.doupdate();
ttsCommit;
}
else
{
checkFailed(#checkInvoiceAmount);
}
}
Thanks for sharing this informative content , Great work
ReplyDeleteLeanpitch provides online training in Enterprise agile coaching during this lockdown period everyone can use it wisely.
Enterprise agile coaching