use of org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper in project cu-kfs by CU-CommunityApps.
the class CUPaymentMethodGeneralLedgerPendingEntryServiceImpl method generateFinalEntriesForPRNC.
/**
* Creates final entries for PRNC doc: Reverse all usage 2900 object codes Replaces with 1000 offset object code Generate
* Bank Offsets for total amounts
*
* @see edu.cornell.kfs.fp.service.CUPaymentMethodGeneralLedgerPendingEntryService#generateFinalEntriesForPRNC(org.kuali.kfs.module.purap.document.PaymentRequestDocument)
*/
public void generateFinalEntriesForPRNC(PaymentRequestDocument document) {
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper(getNextAvailableSequence(document.getDocumentNumber()));
String documentType = CuPaymentRequestDocument.DOCUMENT_TYPE_NON_CHECK;
if (PaymentMethod.PM_CODE_INTERNAL_BILLING.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode())) {
documentType = CuPaymentRequestDocument.DOCUMENT_TYPE_INTERNAL_BILLING;
}
// generate bank offset
if (PaymentMethod.PM_CODE_FOREIGN_DRAFT.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode()) || PaymentMethod.PM_CODE_WIRE.equalsIgnoreCase(((CuPaymentRequestDocument) document).getPaymentMethodCode())) {
generateDocumentBankOffsetEntries((AccountingDocument) document, document.getBankCode(), KRADConstants.DOCUMENT_PROPERTY_NAME + "." + "bankCode", documentType, sequenceHelper, document.getTotalDollarAmount().negated());
}
// check for balance type Actual offset pending entries and replace the object code with chart cash object code (currently replacing object code 2900 with 1000)
List<GeneralLedgerPendingEntry> glpes = document.getGeneralLedgerPendingEntries();
for (GeneralLedgerPendingEntry glpe : glpes) {
OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(glpe.getUniversityFiscalYear(), glpe.getChartOfAccountsCode(), documentType, KFSConstants.BALANCE_TYPE_ACTUAL);
if (glpe.getFinancialObjectCode().equalsIgnoreCase(offsetDefinition.getFinancialObjectCode())) {
if (ObjectUtils.isNull(glpe.getChart())) {
glpe.refreshReferenceObject(KFSPropertyConstants.CHART);
}
glpe.setFinancialObjectCode(glpe.getChart().getFinancialCashObjectCode());
glpe.refreshReferenceObject(KFSPropertyConstants.FINANCIAL_OBJECT);
glpe.setFinancialObjectTypeCode(glpe.getFinancialObject().getFinancialObjectTypeCode());
}
}
// reverse 2900
// check for posted entries and create reverse pending entries
// get all charts on document
List<AccountingLine> accountingLines = new ArrayList<AccountingLine>();
if (ObjectUtils.isNotNull(document.getSourceAccountingLines())) {
accountingLines.addAll(document.getSourceAccountingLines());
}
if (ObjectUtils.isNotNull(document.getTargetAccountingLines())) {
accountingLines.addAll(document.getTargetAccountingLines());
}
Map<String, String> chartOffsets = new HashMap<String, String>();
if (accountingLines.size() > 0) {
for (AccountingLine accountingLine : accountingLines) {
if (!chartOffsets.containsKey(accountingLine.getChartOfAccountsCode())) {
OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(accountingLine.getPostingYear(), accountingLine.getChartOfAccountsCode(), documentType, KFSConstants.BALANCE_TYPE_ACTUAL);
chartOffsets.put(accountingLine.getChartOfAccountsCode(), offsetDefinition.getFinancialObjectCode());
}
}
}
for (String offsetObjectCode : chartOffsets.values()) {
Collection<Entry> glEntries = findMatchingGLEntries(document, offsetObjectCode);
if (glEntries != null && glEntries.size() > 0) {
for (Entry entry : glEntries) {
// create reversal
GeneralLedgerPendingEntry glpe = new GeneralLedgerPendingEntry();
boolean debit = KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(entry.getTransactionDebitCreditCode());
glpe = getGeneralLedgerPendingEntryService().buildGeneralLedgerPendingEntry((GeneralLedgerPostingDocument) document, entry.getAccount(), entry.getFinancialObject(), entry.getSubAccountNumber(), entry.getFinancialSubObjectCode(), entry.getOrganizationReferenceId(), entry.getProjectCode(), entry.getReferenceFinancialDocumentNumber(), entry.getReferenceFinancialDocumentTypeCode(), entry.getReferenceFinancialSystemOriginationCode(), entry.getTransactionLedgerEntryDescription(), debit, entry.getTransactionLedgerEntryAmount(), sequenceHelper);
glpe.setFinancialDocumentTypeCode(documentType);
document.addPendingEntry(glpe);
sequenceHelper.increment();
// create cash entry
GeneralLedgerPendingEntry cashGlpe = new GeneralLedgerPendingEntry();
cashGlpe = getGeneralLedgerPendingEntryService().buildGeneralLedgerPendingEntry((GeneralLedgerPostingDocument) document, entry.getAccount(), entry.getChart().getFinancialCashObject(), entry.getSubAccountNumber(), entry.getFinancialSubObjectCode(), entry.getOrganizationReferenceId(), entry.getProjectCode(), entry.getReferenceFinancialDocumentNumber(), entry.getReferenceFinancialDocumentTypeCode(), entry.getReferenceFinancialSystemOriginationCode(), entry.getTransactionLedgerEntryDescription(), !debit, entry.getTransactionLedgerEntryAmount(), sequenceHelper);
cashGlpe.setFinancialDocumentTypeCode(documentType);
document.addPendingEntry(cashGlpe);
sequenceHelper.increment();
}
}
}
if (document.getGeneralLedgerPendingEntries() != null && document.getGeneralLedgerPendingEntries().size() > 0) {
for (GeneralLedgerPendingEntry glpe : document.getGeneralLedgerPendingEntries()) {
glpe.setFinancialDocumentApprovedCode(KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.APPROVED);
}
}
}
use of org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method populatePaymentGeneralLedgerPendingEntry.
/**
* Populates and stores a new GLPE for each account detail in the payment group.
*
* @param paymentGroup payment group to generate entries for
* @param achFdocTypeCode doc type for ach disbursements
* @param checkFdocTypeCod doc type for check disbursements
* @param reversal boolean indicating if this is a reversal
*/
protected void populatePaymentGeneralLedgerPendingEntry(PaymentGroup paymentGroup, String achFdocTypeCode, String checkFdocTypeCod, boolean reversal) {
List<PaymentAccountDetail> accountListings = new ArrayList<PaymentAccountDetail>();
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
accountListings.addAll(paymentDetail.getAccountDetail());
}
// GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
for (PaymentAccountDetail paymentAccountDetail : accountListings) {
GlPendingTransaction glPendingTransaction = new GlPendingTransaction();
glPendingTransaction.setSequenceNbr(new KualiInteger(sequenceHelper.getSequenceCounter()));
if (StringUtils.isNotBlank(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode()) && StringUtils.isNotBlank(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode())) {
glPendingTransaction.setFdocRefTypCd(paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode());
glPendingTransaction.setFsRefOriginCd(paymentAccountDetail.getPaymentDetail().getFinancialSystemOriginCode());
} else {
glPendingTransaction.setFdocRefTypCd(PdpConstants.PDP_FDOC_TYPE_CODE);
glPendingTransaction.setFsRefOriginCd(PdpConstants.PDP_FDOC_ORIGIN_CODE);
}
glPendingTransaction.setFinancialBalanceTypeCode(org.kuali.kfs.sys.KFSConstants.BALANCE_TYPE_ACTUAL);
Date transactionTimestamp = new Date(dateTimeService.getCurrentDate().getTime());
glPendingTransaction.setTransactionDt(transactionTimestamp);
AccountingPeriod fiscalPeriod = accountingPeriodService.getByDate(new java.sql.Date(transactionTimestamp.getTime()));
glPendingTransaction.setUniversityFiscalYear(fiscalPeriod.getUniversityFiscalYear());
glPendingTransaction.setUnivFiscalPrdCd(fiscalPeriod.getUniversityFiscalPeriodCode());
glPendingTransaction.setAccountNumber(paymentAccountDetail.getAccountNbr());
glPendingTransaction.setSubAccountNumber(paymentAccountDetail.getSubAccountNbr());
glPendingTransaction.setChartOfAccountsCode(paymentAccountDetail.getFinChartCode());
if (paymentGroup.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.ACH)) {
glPendingTransaction.setFinancialDocumentTypeCode(achFdocTypeCode);
} else if (paymentGroup.getDisbursementType().getCode().equals(PdpConstants.DisbursementTypeCodes.CHECK)) {
glPendingTransaction.setFinancialDocumentTypeCode(checkFdocTypeCod);
}
glPendingTransaction.setFsOriginCd(PdpConstants.PDP_FDOC_ORIGIN_CODE);
glPendingTransaction.setFdocNbr(paymentGroup.getDisbursementNbr().toString());
// if stale
if (StringUtils.equals(FDOC_TYP_CD_STALE_CHECK, checkFdocTypeCod)) {
ParameterService parameterService = SpringContext.getBean(ParameterService.class);
String clAcct = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_ACCOUNT);
String obCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_OBJECT_CODE);
String coaCode = parameterService.getParameterValueAsString(CheckReconciliationImportStep.class, CRConstants.CLEARING_COA);
// Use clearing parameters if stale
glPendingTransaction.setAccountNumber(clAcct);
glPendingTransaction.setFinancialObjectCode(obCode);
glPendingTransaction.setChartOfAccountsCode(coaCode);
glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
// KFSUPGRADE-943
glPendingTransaction.setSubAccountNumber(KFSConstants.getDashSubAccountNumber());
} else {
Boolean relieveLiabilities = paymentGroup.getBatch().getCustomerProfile().getRelieveLiabilities();
if ((relieveLiabilities != null) && (relieveLiabilities.booleanValue()) && paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode() != null) {
OffsetDefinition offsetDefinition = SpringContext.getBean(OffsetDefinitionService.class).getByPrimaryId(glPendingTransaction.getUniversityFiscalYear(), glPendingTransaction.getChartOfAccountsCode(), paymentAccountDetail.getPaymentDetail().getFinancialDocumentTypeCode(), glPendingTransaction.getFinancialBalanceTypeCode());
glPendingTransaction.setFinancialObjectCode(offsetDefinition != null ? offsetDefinition.getFinancialObjectCode() : paymentAccountDetail.getFinObjectCode());
glPendingTransaction.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
} else {
glPendingTransaction.setFinancialObjectCode(paymentAccountDetail.getFinObjectCode());
glPendingTransaction.setFinancialSubObjectCode(paymentAccountDetail.getFinSubObjectCode());
}
}
glPendingTransaction.setProjectCd(paymentAccountDetail.getProjectCode());
glPendingTransaction.setDebitCrdtCd(pdpUtilService.isDebit(paymentAccountDetail, reversal) ? KFSConstants.GL_DEBIT_CODE : KFSConstants.GL_CREDIT_CODE);
glPendingTransaction.setAmount(paymentAccountDetail.getAccountNetAmount().abs());
// Changes for Research Participant Upload
String trnDesc = StringUtils.EMPTY;
CustomerProfile customerProfile = paymentGroup.getBatch().getCustomerProfile();
// KFSUPGRADE-973
if (researchParticipantPaymentValidationService.isResearchParticipantPayment(customerProfile)) {
BusinessObjectEntry businessObjectEntry = dataDictionaryService.getDataDictionary().getBusinessObjectEntry(PaymentDetail.class.getName());
AttributeDefinition attributeDefinition = businessObjectEntry.getAttributeDefinition("paymentGroup.payeeName");
AttributeSecurity originalPayeeNameAttributeSecurity = attributeDefinition.getAttributeSecurity();
// This is a temporary work around for an issue introduced with KFSCNTRB-705.
if (ObjectUtils.isNotNull(originalPayeeNameAttributeSecurity)) {
String maskLiteral = ((MaskFormatterLiteral) originalPayeeNameAttributeSecurity.getMaskFormatter()).getLiteral();
trnDesc = maskLiteral;
}
} else {
String payeeName = paymentGroup.getPayeeName();
if (StringUtils.isNotBlank(payeeName)) {
trnDesc = payeeName.length() > 40 ? payeeName.substring(0, 40) : StringUtils.rightPad(payeeName, 40);
}
if (reversal) {
String poNbr = paymentAccountDetail.getPaymentDetail().getPurchaseOrderNbr();
if (StringUtils.isNotBlank(poNbr)) {
trnDesc += " " + (poNbr.length() > 9 ? poNbr.substring(0, 9) : StringUtils.rightPad(poNbr, 9));
}
String invoiceNbr = paymentAccountDetail.getPaymentDetail().getInvoiceNbr();
if (StringUtils.isNotBlank(invoiceNbr)) {
trnDesc += " " + (invoiceNbr.length() > 14 ? invoiceNbr.substring(0, 14) : StringUtils.rightPad(invoiceNbr, 14));
}
if (trnDesc.length() > 40) {
trnDesc = trnDesc.substring(0, 40);
}
}
}
glPendingTransaction.setDescription(trnDesc);
glPendingTransaction.setOrgDocNbr(paymentAccountDetail.getPaymentDetail().getOrganizationDocNbr());
glPendingTransaction.setOrgReferenceId(paymentAccountDetail.getOrgReferenceId());
glPendingTransaction.setFdocRefNbr(paymentAccountDetail.getPaymentDetail().getCustPaymentDocNbr());
// update the offset account if necessary
SpringContext.getBean(FlexibleOffsetAccountService.class).updateOffset(glPendingTransaction);
this.businessObjectService.save(glPendingTransaction);
sequenceHelper.increment();
if (bankService.isBankSpecificationEnabled()) {
this.populateBankOffsetEntry(paymentGroup, glPendingTransaction, sequenceHelper);
}
}
}
use of org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method generateStopGeneralLedgerPendingEntry.
/**
* @see org.kuali.kfs.pdp.service.PendingTransactionService#generateCancellationGeneralLedgerPendingEntry(org.kuali.kfs.pdp.businessobject.PaymentGroup)
*/
public void generateStopGeneralLedgerPendingEntry(PaymentGroup paymentGroup) {
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
// Need to reverse the payment document's GL entries if the check is stopped or cancelled
reverseSourceDocumentsEntries(paymentDetail, sequenceHelper);
}
this.populatePaymentGeneralLedgerPendingEntry(paymentGroup, FDOC_TYP_CD_CANCEL_ACH, FDOC_TYP_CD_STOP_CHECK, true);
}
use of org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method generateCRCancellationGeneralLedgerPendingEntry.
/**
* @see org.kuali.kfs.pdp.service.PendingTransactionService#generateCRCancellationGeneralLedgerPendingEntry(org.kuali.kfs.pdp.businessobject.PaymentGroup)
*/
public void generateCRCancellationGeneralLedgerPendingEntry(PaymentGroup paymentGroup) {
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
for (PaymentDetail paymentDetail : paymentGroup.getPaymentDetails()) {
// Need to reverse the payment document's GL entries if the check is stopped or cancelled
reverseSourceDocumentsEntries(paymentDetail, sequenceHelper);
}
this.populatePaymentGeneralLedgerPendingEntry(paymentGroup, FDOC_TYP_CD_CANCEL_ACH, FDOC_TYP_CD_CANCEL_CHECK, true);
}
use of org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method generateEntriesPaymentRequest.
/**
* Creates the general ledger entries for Payment Request actions.
*
* @param preq Payment Request document to create entries
* @param encumbrances List of encumbrance accounts if applies
* @param accountingLines List of preq accounts to create entries
* @param processType Type of process (create, modify, cancel)
* @return Boolean returned indicating whether entry creation succeeded
*/
protected boolean generateEntriesPaymentRequest(PaymentRequestDocument preq, List encumbrances, List summaryAccounts) {
LOG.debug("generateEntriesPaymentRequest() started");
boolean success = true;
preq.setGeneralLedgerPendingEntries(new ArrayList());
/*
* Can't let generalLedgerPendingEntryService just create all the entries because we need the sequenceHelper to carry over
* from the encumbrances to the actuals and also because we need to tell the PaymentRequestDocumentRule customize entry
* method how to customize differently based on if creating an encumbrance or actual.
*/
GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper(getNextAvailableSequence(preq.getDocumentNumber()));
// when cancelling a PREQ, do not book encumbrances if PO is CLOSED
if (encumbrances != null) {
// on cancel, use DEBIT code
preq.setDebitCreditCodeForGLEntries(GL_DEBIT_CODE);
preq.setGenerateEncumbranceEntries(true);
for (Iterator iter = encumbrances.iterator(); iter.hasNext(); ) {
AccountingLine accountingLine = (AccountingLine) iter.next();
preq.generateGeneralLedgerPendingEntries(accountingLine, sequenceHelper);
// increment for the next line
sequenceHelper.increment();
}
}
if (ObjectUtils.isNotNull(summaryAccounts) && !summaryAccounts.isEmpty()) {
LOG.debug("generateEntriesPaymentRequest() now book the actuals");
preq.setGenerateEncumbranceEntries(false);
// on cancel, use CREDIT code
preq.setDebitCreditCodeForGLEntries(GL_CREDIT_CODE);
for (Iterator iter = summaryAccounts.iterator(); iter.hasNext(); ) {
SummaryAccount summaryAccount = (SummaryAccount) iter.next();
preq.generateGeneralLedgerPendingEntries(summaryAccount.getAccount(), sequenceHelper);
// increment for the next line
sequenceHelper.increment();
}
// generate offset accounts for use tax if it exists (useTaxContainers will be empty if not a use tax document)
List<UseTaxContainer> useTaxContainers = SpringContext.getBean(PurapAccountingService.class).generateUseTaxAccount(preq);
for (UseTaxContainer useTaxContainer : useTaxContainers) {
PurApItemUseTax offset = useTaxContainer.getUseTax();
List<SourceAccountingLine> accounts = useTaxContainer.getAccounts();
for (SourceAccountingLine sourceAccountingLine : accounts) {
preq.generateGeneralLedgerPendingEntries(sourceAccountingLine, sequenceHelper, useTaxContainer.getUseTax());
// increment for the next line
sequenceHelper.increment();
}
}
}
// Manually save GL entries for Payment Request and encumbrances
LOG.debug("saveGLEntries() started");
businessObjectService.save(preq.getGeneralLedgerPendingEntries());
return success;
}
Aggregations