Sunday, 24 November 2024

Add field in GeneralJournalAccountEntry in D365 FO


[ExtensionOf(classStr(LedgerVoucherTransObject))]
final class LedgerVoucherTransObject_Extension
{
public str customField;

/// <summary>
/// Gets or sets the <c>customField</c> parameter.
/// </summary>
/// <param name = "_customField">The value to set</param>
/// <returns>The value of the <c>customField</c> parameter</returns>
public str parmCustomField(str _customField= customField)
{
generalJournalAccountEntry.customField = _customField;

return generalJournalAccountEntry.customField;
}

public LedgerPostingTransactionTmp getLedgerPostingTransaction()
{
LedgerPostingTransactionTmp ledgerPostingTransaction;

ledgerPostingTransaction = next getLedgerPostingTransaction();

ledgerPostingTransaction.CustomField = generalJournalAccountEntry.CustomField;

return ledgerPostingTransaction;
}

public void initFromLedgerPostingTransaction(LedgerPostingTransactionTmp _ledgerPostingTransaction, LedgerPostingTransactionProjectTmp _projectPostingTransaction)
{
next initFromLedgerPostingTransaction(_ledgerPostingTransaction, _projectPostingTransaction);

generalJournalAccountEntry.CustomField = _ledgerPostingTransaction.CustomField;

}

public static LedgerVoucherTransObject newTransLedgerJournal(
LedgerJournalTrans _ledgerJournalTrans,
TaxAmount _taxAmount,
boolean _bridging,
container _intercompanyRecIds,
boolean _reversalsMayExist,
boolean _forcedExchangeRate)
{
LedgerVoucherTransObject ledgerVoucherTransObject;

ledgerVoucherTransObject = next newTransLedgerJournal(_ledgerJournalTrans, _taxAmount, _bridging, _intercompanyRecIds, _reversalsMayExist, _forcedExchangeRate);

ledgerVoucherTransObject.parmCustomField(_ledgerJournalTrans.CustomField);

return ledgerVoucherTransObject;
}

} 

--------------------------------------------------------------------------------------------------------------

if we want to pass from different Journals or vouchers

/// <summary>
/// extension of LedgerVoucherObject
/// </summary>
[ExtensionOf(classStr(LedgerVoucherObject))]
final class BTC_LedgerVoucherObject_Extension
{
private InventTransId inventTransId;

/// <summary>
/// This method is sued to get invent journal trans
/// </summary>
/// <param name = "_inventTransId">InventTransId</param>
/// <returns>InventTransId</returns>
public InventTransId parmInventJournalTrans(InventTransId _inventTransId = inventTransId)
{
inventTransId = _inventTransId;

return inventTransId;
}

}

[ExtensionOf(classStr(InventJournalCheckPost_Movement))]
final class BTC_InventJournalCheckPost_Movement_C_Extension
{
/// <summary>
/// This method is used to postTransLedger
/// </summary>
/// <param name = "_journalTransData">JournalTransData</param>
/// <param name = "_ledgerVoucher">LedgerVoucher</param>
protected void postTransLedger(
JournalTransData _journalTransData,
LedgerVoucher _ledgerVoucher)
{
InventJournalTrans inventJournalTrans = _journalTransData.journalTrans();

if (inventJournalTrans.inventJournalTable().JournalType == InventJournalType::Movement)
{
_ledgerVoucher.findLedgerVoucherObject().parmInventJournalTrans(inventJournalTrans.InventTransId);
}

next postTransLedger(_journalTransData, _ledgerVoucher);

}

/// <summary>
/// This method is used to call end of posting the journal
/// </summary>
/// <param name = "_deleteErrors">boolean</param>
/// <returns>Integer</returns>
protected Integer runEnd(boolean _deleteErrors)
{
int ret = next runEnd(_deleteErrors);

if (journalCheckPostType != JournalCheckPostType::Check
&& journalTableData.journalTable().Posted)
{
InventJournalTable inventJournalTable = journalTableData.journalTable();

if (inventJournalTable.JournalType == InventJournalType::Movement)
{
    //Add logic for addtional changes 
}
}

return ret;
}
}

No comments:

Post a Comment

Clean up jobs in D365FO

  https://anithasantosh.wordpress.com/2024/11/07/clean-up-jobs-in-d365fo/