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?
André Arnaud de Cal...
291,996
Super User 2025 Season 1
Martin Dráb
230,853
Most Valuable Professional
nmaenpaa
101,156