use of org.kuali.kfs.sys.document.service.AccountingDocumentRuleHelperService in project cu-kfs by CU-CommunityApps.
the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateDocumentBankOffsetEntries.
/**
* If bank specification is enabled generates bank offsetting entries for the document amount
*/
public boolean generateDocumentBankOffsetEntries(AccountingDocument document, String bankCode, String bankCodePropertyName, String documentTypeCode, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, KualiDecimal bankOffsetAmount) {
boolean success = true;
if (!getBankService().isBankSpecificationEnabled()) {
return success;
}
Bank bank = getBankService().getByPrimaryId(bankCode);
if (bankOffsetAmount == null) {
bankOffsetAmount = getGeneralLedgerPendingEntryService().getOffsetToCashAmount(document).negated();
}
if (!KualiDecimal.ZERO.equals(bankOffsetAmount)) {
GeneralLedgerPendingEntry bankOffsetEntry = new GeneralLedgerPendingEntry();
success &= getGeneralLedgerPendingEntryService().populateBankOffsetGeneralLedgerPendingEntry(bank, bankOffsetAmount, document, document.getPostingYear(), sequenceHelper, bankOffsetEntry, bankCodePropertyName);
if (success) {
AccountingDocumentRuleHelperService accountingDocumentRuleUtil = SpringContext.getBean(AccountingDocumentRuleHelperService.class);
bankOffsetEntry.setTransactionLedgerEntryDescription(accountingDocumentRuleUtil.formatProperty(KFSKeyConstants.Bank.DESCRIPTION_GLPE_BANK_OFFSET));
bankOffsetEntry.setFinancialDocumentTypeCode(documentTypeCode);
document.addPendingEntry(bankOffsetEntry);
sequenceHelper.increment();
GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(bankOffsetEntry);
success &= getGeneralLedgerPendingEntryService().populateOffsetGeneralLedgerPendingEntry(document.getPostingYear(), bankOffsetEntry, sequenceHelper, offsetEntry);
bankOffsetEntry.setFinancialDocumentTypeCode(documentTypeCode);
document.addPendingEntry(offsetEntry);
sequenceHelper.increment();
}
}
return success;
}
Aggregations