Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Customer payment lines from bank statements in reconciliation

(0) ShareShare
ReportReport
Posted on by 5

Hi guys,

we're implementing d365 fo for our new customer and they want to import already existing payments in the system. We use their banks' ws integrations to get bank statements and populate new journals based on the type of payments. When the journal lines are created, their payment statuses are set to "sent". Also, we want to show appropriate lines in bank reconciliation worksheet.

So, based on the situation, I'm using CustVendPaymReconciliationSetStatus class for reconciliation while creating journal lines.

'public void importDataToJournal(List _statementList)

{
RecordContract_GE stmtRecord;
CustTable custTable;
LedgerJournalACType ledgerAccountType;
LedgerJournalAC ledgerAccount;
ListEnumerator le = _statementList.getEnumerator();
str recAccount;
str recIBAN;
CustParameters_GE custParameters = CustParameters_GE::find();

// code from the CustVendPaymReconciliationSetStatus.main() (set Sent status button)
custVendPaymReconciliationSetStatus = new CustVendPaymReconciliationSetStatus();
custVendPaymReconciliationSetStatus.parmStatus(CustVendPaymStatus::Sent);

while (le.moveNext())
{
stmtRecord = le.current();
totalPayments++;
recAccount = stmtRecord.parmBeneficiaryDetails().parmAccountNumber();
recIBAN = strDel(recAccount, strLen(recAccount) - 2, 3);


if ( stmtRecord.parmEntryAmountCredit() > 0
&& recIBAN == bankAccountTable.IBAN
&& ( custParameters.ImpCurExInCustPaymJournal == NoYes::Yes || stmtRecord.parmSenderDetails().parmInn() != innNumber )
)
{
if(!this.validateCustPaymLine(num2Str(stmtRecord.parmdocumentKey(),-1,-1,DecimalSeparator::Auto,ThousandSeparator::None)))
{
continue;
}

[custTable,
ledgerAccount,
ledgerAccountType] = this.createLedgerParameters(stmtRecord.parmSenderDetails().parmAccountNumber(),
stmtRecord.parmSenderDetails().parmInn(),
stmtRecord.parmSenderDetails().parmName(),
num2Str(stmtRecord.parmdocumentKey(),-1,-1,DecimalSeparator::Auto,ThousandSeparator::None)); 

this.createLedgerJournalTrans_ge(stmtRecord, custTable, ledgerAccountType, ledgerAccount); 
}
}

CustVendPaymReconciliationSetStatus::runServer(custVendPaymReconciliationSetStatus.pack()); // code from the CustVendPaymReconciliationSetStatus.main() (set Sent status button)
}'

Never mind the code in between, it's working, when it comes to createLedgerJournalTrans_ge method, that's where we create new lines and it looks like this:

protected void createLedgerJournalTrans_ge(
ServiceContract_GE _stmtRecord,
CustTable _custTable,
LedgerJournalACType _accountType,
LedgerJournalAC _account
)
{
LedgerJournalEngine ledgerJournalEngine;

ledgerJournalEngine = LedgerJournalEngine::construct(ledgerJournalTable.JournalType);
ledgerJournalEngine.ledgerJournalTable(ledgerJournalTable);
ledgerJournalEngine.newJournalActive(ledgerJournalTable);

ledgerJournalTrans.clear();
ledgerJournalTrans.JournalNum = ledgerJournalId;
ledgerJournalTrans.PaymMode = paymMode;
ledgerJournalTrans.LoadingDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
ledgerJournalTrans.TransDate = DateTimeUtil::date(DateTimeUtil::parse(_stmtRecord.parmEntryDate()));
ledgerJournalTrans.TransactionType = LedgerTransType::Payment;
ledgerJournalTrans.CurrencyCode = bankAccountTable.CurrencyCode;

ledgerJournalTrans.parmAccount(_account, _accountType, curext()); // LedgerDimension
if (_custTable)
{
ledgerJournalTrans.DefaultDimension = _custTable.DefaultDimension;
ledgerJournalTrans.TaxGroup = _custTable.TaxGroup;
ledgerJournalTrans.Payment = _custTable.PaymTermId;
}

ledgerJournalTrans.parmOffsetAccount(offsetAccount, LedgerJournalACType::Bank, curext());
ledgerJournalTrans.OffsetDefaultDimension = bankAccountTable.DefaultDimension;

ledgerJournalTrans.LedgerDimensionName = ledgerJournalTrans.accountName();
ledgerJournalTrans.AmountCurCredit = _stmtRecord.parmEntryAmountCredit();
ledgerJournalTrans.Triangulation = Currency::triangulation(ledgerJournalTrans.CurrencyCode, ledgerJournalTrans.TransDate);
ledgerJournalTrans.ExchRate = ExchangeRateHelper::exchRate(ledgerJournalTrans.CurrencyCode, ledgerJournalTrans.TransDate);
ledgerJournalTrans.ExchRateSecond = ExchangeRateHelper::exchRateSecond(ledgerJournalTrans.CurrencyCode, ledgerJournalTrans.TransDate);

if (Ledger::reportingCurrency())
{
[ledgerJournalTrans.ReportingCurrencyExchRate,
ledgerJournalTrans.ReportingCurrencyExchRateSecondary] = CustInPaym::calculateReportingCurrencyExchRate(
Ledger::reportingCurrencyExchangeRateType(),
ledgerJournalTrans.CurrencyCode,
Ledger::reportingCurrency(),
ledgerJournalTrans.TransDate);
}

ledgerJournalTrans.SettleVoucher = this.findAutomaticSettlementType();
ledgerJournalEngine.initTaxItemGroup(ledgerJournalTrans);

ledgerJournalTrans.DocumentDate = DateTimeUtil::date(DateTimeUtil::parse(_stmtRecord.parmdocumentActualDate()));
ledgerJournalTrans.DocumentNum = num2Str(_stmtRecord.parmdocumentKey(),-1,-1,DecimalSeparator::Auto,ThousandSeparator::None);
ledgerJournalTrans.BankCentralBankPurposeText = _stmtRecord.parmDocumentNomination();
ledgerJournalTrans.PaymentNotes = _stmtRecord.parmDocumentInformation();
ledgerJournalTrans.PaymentStatus = CustVendPaymStatus::Sent;
ledgerJournalTrans.PostingProfile = CustParameters::find().PostingProfile;
ledgerJournalTrans.BankTransType = CustPaymModeTable::find(paymMode).BankTransType;
LedgerJournalTrans.CustVendBankAccountId = CVBankAccoutId;

ledgerJournalTrans.Approved = NoYes::Yes;
ledgerJournalTrans.Approver = HcmWorkerLookup::currentWorker();
if (!ledgerJournalTrans.Approver)
{
ledgerJournalTrans.Approver = CustParameters_GE::find().CustImportApprover;
}

this.loadVoucherNum();
ledgerJournalTrans.Voucher = voucher;
ledgerJournalTrans.insert();

importedPayments++;

// code from the CustVendPaymReconciliationSetStatus.main() (set Sent status button)
custVendPaymReconciliationSetStatus.parmRecid(ledgerJournalTrans.RecId);
this.addFeesForPaymentLine(ledgerJournalTrans.RecId, custVendPaymReconciliationSetStatus);
}

as you see, here I use parmRecid on the reconciliation class. It didn't work, we couldn't see the lines in the worksheet so I just replicated whatever was in the main method (one additional internal method). Still, it's not working. This is in practice copy paste of CustVendPaymReconciliationSetStatus main method. When we go to the journal and manually set payment statuses first to none and then to sent again, it's showed in the worksheet. I don't understand what's wrong, code is basically the same. Any ideas?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,996 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,853 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans