protected boolean createJournalLine(CustTransOpen _custTransOpen)
{
    CustTable custTable;
    LedgerJournalTrans journalTrans;
    AxLedgerJournalTrans_CustPaymJour axJournalTrans;
    CustVendOpenTransManager manager;
    AmountMST feeAmount;

    custTable = this.getCustTable(_custTransOpen.AccountNum);
    axJournalTrans = AxLedgerJournalTrans_CustPaymJour::newLedgerJournalTable(journalTable);

    journalTrans = axJournalTrans.ledgerJournalTrans();

    journalTrans.TransDate = systemDateGet();
    journalTrans.parmAccount(custTable.AccountNum, LedgerJournalACType::Cust);
    journalTrans.initFromCustTable(custTable);
    journalTrans.initForCurrency(journalTable);
    journalTrans.parmOffsetLedgerDimension(journalTable.OffsetLedgerDimension);
    
	if(_custTransOpen.AmountCur < 0)
    {
        journalTrans.AmountCurDebit = abs(_custTransOpen.AmountCur);
    }
    else
    {
        journalTrans.AmountCurCredit = _custTransOpen.AmountCur;
    }

    axJournalTrans.save();

    manager = CustVendOpenTransManager::construct(journalTrans);
    manager.updateTransMarked(_custTransOpen, true);
    manager.calcAndUpdateFine_BR(_custTransOpen.company(), _custTransOpen, journalTrans.TransDate);
    manager.calcAndUpdateInterest_BR(_custTransOpen.company(), _custTransOpen, journalTrans.TransDate);
    manager.updateOriginatorForMarkedTrans();
    manager.updateSpecTransWithSelectedDate();

    journalTrans.updateEPRemitInfo_BR();
    journalTrans.updateMarkedInvoice(1);

    if(journalTrans.amount())
    {
        if (journalTrans.PaymMode && !CustPaymModeTable::find(journalTrans.PaymMode).FurtherPosting)
        {
            CustVendPaymJournalFee::createJournalFeeCust(journalTrans);
        }
        else
        {
            CustVendPaymJournalFee::deleteJournalFee(journalTrans);
        }
    }

    return journalTrans.RecId != 0;
}
Categories: AX2012

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

three + 1 =