use of org.kuali.kfs.sys.businessobject.SourceAccountingLine in project cu-kfs by CU-CommunityApps.
the class RecurringDisbursementVoucherDocumentServiceImpl method buildSourceAccountingLine.
private SourceAccountingLine buildSourceAccountingLine(ScheduledSourceAccountingLine scheduledAccountingLine) {
SourceAccountingLine line = new SourceAccountingLine();
line.setAccountExpiredOverride(scheduledAccountingLine.getAccountExpiredOverride());
line.setAccountExpiredOverrideNeeded(scheduledAccountingLine.getAccountExpiredOverrideNeeded());
line.setAccountNumber(scheduledAccountingLine.getAccountNumber());
line.setChartOfAccountsCode(scheduledAccountingLine.getChartOfAccountsCode());
line.setDebitCreditCode(scheduledAccountingLine.getDebitCreditCode());
line.setEncumbranceUpdateCode(scheduledAccountingLine.getEncumbranceUpdateCode());
line.setFinancialDocumentLineDescription(scheduledAccountingLine.getFinancialDocumentLineDescription());
line.setFinancialDocumentLineTypeCode(scheduledAccountingLine.getFinancialDocumentLineTypeCode());
line.setFinancialObjectCode(scheduledAccountingLine.getFinancialObjectCode());
line.setFinancialSubObjectCode(scheduledAccountingLine.getFinancialSubObjectCode());
line.setNonFringeAccountOverride(scheduledAccountingLine.getNonFringeAccountOverride());
line.setNonFringeAccountOverrideNeeded(scheduledAccountingLine.getNonFringeAccountOverrideNeeded());
line.setOrganizationReferenceId(scheduledAccountingLine.getOrganizationReferenceId());
line.setPostingYear(scheduledAccountingLine.getPostingYear());
line.setProjectCode(scheduledAccountingLine.getProjectCode());
line.setReferenceNumber(scheduledAccountingLine.getReferenceNumber());
line.setReferenceTypeCode(scheduledAccountingLine.getReferenceTypeCode());
line.setSalesTaxRequired(scheduledAccountingLine.isSalesTaxRequired());
line.setSubAccountNumber(scheduledAccountingLine.getSubAccountNumber());
return line;
}
use of org.kuali.kfs.sys.businessobject.SourceAccountingLine in project cu-kfs by CU-CommunityApps.
the class CuDisbursementVoucherExtractionHelperServiceImpl method buildPaymentDetail.
protected PaymentDetail buildPaymentDetail(DisbursementVoucherDocument document, Date processRunDate) {
if (LOG.isDebugEnabled()) {
LOG.debug("buildPaymentDetail() started");
}
final String maxNoteLinesParam = getParameterService().getParameterValueAsString(KfsParameterConstants.PRE_DISBURSEMENT_ALL.class, PdpParameterConstants.MAX_NOTE_LINES);
int maxNoteLines;
try {
maxNoteLines = Integer.parseInt(maxNoteLinesParam);
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("Invalid Max Notes Lines parameter, value: " + maxNoteLinesParam + " cannot be converted to an integer");
}
PaymentDetail pd = new PaymentDetail();
if (StringUtils.isNotEmpty(document.getDocumentHeader().getOrganizationDocumentNumber())) {
pd.setOrganizationDocNbr(document.getDocumentHeader().getOrganizationDocumentNumber());
}
pd.setCustPaymentDocNbr(document.getDocumentNumber());
pd.setInvoiceDate(new java.sql.Date(processRunDate.getTime()));
pd.setOrigInvoiceAmount(document.getDisbVchrCheckTotalAmount());
pd.setInvTotDiscountAmount(KualiDecimal.ZERO);
pd.setInvTotOtherCreditAmount(KualiDecimal.ZERO);
pd.setInvTotOtherDebitAmount(KualiDecimal.ZERO);
pd.setInvTotShipAmount(KualiDecimal.ZERO);
pd.setNetPaymentAmount(document.getDisbVchrCheckTotalAmount());
pd.setPrimaryCancelledPayment(Boolean.FALSE);
pd.setFinancialDocumentTypeCode(DisbursementVoucherConstants.DOCUMENT_TYPE_CHECKACH);
pd.setFinancialSystemOriginCode(KFSConstants.ORIGIN_CODE_KUALI);
// Handle accounts
for (SourceAccountingLine sal : (List<? extends SourceAccountingLine>) document.getSourceAccountingLines()) {
PaymentAccountDetail pad = new PaymentAccountDetail();
pad.setFinChartCode(sal.getChartOfAccountsCode());
pad.setAccountNbr(sal.getAccountNumber());
if (StringUtils.isNotEmpty(sal.getSubAccountNumber())) {
pad.setSubAccountNbr(sal.getSubAccountNumber());
} else {
pad.setSubAccountNbr(KFSConstants.getDashSubAccountNumber());
}
pad.setFinObjectCode(sal.getFinancialObjectCode());
if (StringUtils.isNotEmpty(sal.getFinancialSubObjectCode())) {
pad.setFinSubObjectCode(sal.getFinancialSubObjectCode());
} else {
pad.setFinSubObjectCode(KFSConstants.getDashFinancialSubObjectCode());
}
if (StringUtils.isNotEmpty(sal.getOrganizationReferenceId())) {
pad.setOrgReferenceId(sal.getOrganizationReferenceId());
}
if (StringUtils.isNotEmpty(sal.getProjectCode())) {
pad.setProjectCode(sal.getProjectCode());
} else {
pad.setProjectCode(KFSConstants.getDashProjectCode());
}
pad.setAccountNetAmount(sal.getAmount());
pd.addAccountDetail(pad);
}
// Handle notes
DisbursementVoucherPayeeDetail dvpd = document.getDvPayeeDetail();
int line = 0;
PaymentNoteText pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_PREPARER + document.getDisbVchrContactPersonName() + " " + document.getDisbVchrContactPhoneNumber());
pd.addNote(pnt);
String dvSpecialHandlingPersonName = null;
String dvSpecialHandlingLine1Address = null;
String dvSpecialHandlingLine2Address = null;
String dvSpecialHandlingCity = null;
String dvSpecialHandlingState = null;
String dvSpecialHandlingZip = null;
dvSpecialHandlingPersonName = dvpd.getDisbVchrSpecialHandlingPersonName();
dvSpecialHandlingLine1Address = dvpd.getDisbVchrSpecialHandlingLine1Addr();
dvSpecialHandlingLine2Address = dvpd.getDisbVchrSpecialHandlingLine2Addr();
dvSpecialHandlingCity = dvpd.getDisbVchrSpecialHandlingCityName();
dvSpecialHandlingState = dvpd.getDisbVchrSpecialHandlingStateCode();
dvSpecialHandlingZip = dvpd.getDisbVchrSpecialHandlingZipCode();
if (StringUtils.isNotEmpty(dvSpecialHandlingPersonName)) {
pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText("Send Check To: " + dvSpecialHandlingPersonName);
if (LOG.isDebugEnabled()) {
LOG.debug("Creating special handling person name note: " + pnt.getCustomerNoteText());
}
pd.addNote(pnt);
}
if (StringUtils.isNotEmpty(dvSpecialHandlingLine1Address)) {
pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_SPECIAL_HANDLING_ADDRESS1 + dvSpecialHandlingLine1Address);
if (LOG.isDebugEnabled()) {
LOG.debug("Creating special handling address 1 note: " + pnt.getCustomerNoteText());
}
pd.addNote(pnt);
}
if (StringUtils.isNotEmpty(dvSpecialHandlingLine2Address)) {
pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_SPECIAL_HANDLING_ADDRESS2 + dvSpecialHandlingLine2Address);
if (LOG.isDebugEnabled()) {
LOG.debug("Creating special handling address 2 note: " + pnt.getCustomerNoteText());
}
pd.addNote(pnt);
}
if (StringUtils.isNotEmpty(dvSpecialHandlingCity)) {
pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText(CuDisbursementVoucherConstants.DV_EXTRACT_NOTE_PREFIX_SPECIAL_HANDLING_ADDRESS3 + dvSpecialHandlingCity + ", " + dvSpecialHandlingState + " " + dvSpecialHandlingZip);
if (LOG.isDebugEnabled()) {
LOG.debug("Creating special handling city note: " + pnt.getCustomerNoteText());
}
pd.addNote(pnt);
}
if (document.isDisbVchrAttachmentCode()) {
pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText("Attachment Included");
if (LOG.isDebugEnabled()) {
LOG.debug("create attachment note: " + pnt.getCustomerNoteText());
}
pd.addNote(pnt);
}
String paymentReasonCode = dvpd.getDisbVchrPaymentReasonCode();
if (/*REFACTORME*/
getParameterEvaluatorService().getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.NONEMPLOYEE_TRAVEL_PAY_REASONS_PARM_NM, paymentReasonCode).evaluationSucceeds()) {
DisbursementVoucherNonEmployeeTravel dvnet = document.getDvNonEmployeeTravel();
pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText("Reimbursement associated with " + dvnet.getDisbVchrServicePerformedDesc());
if (LOG.isDebugEnabled()) {
LOG.debug("Creating non employee travel notes: " + pnt.getCustomerNoteText());
}
pd.addNote(pnt);
pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText("The total per diem amount for your daily expenses is " + dvnet.getDisbVchrPerdiemActualAmount());
if (LOG.isDebugEnabled()) {
LOG.debug("Creating non employee travel notes: " + pnt.getCustomerNoteText());
}
pd.addNote(pnt);
if (dvnet.getDisbVchrPersonalCarAmount() != null && dvnet.getDisbVchrPersonalCarAmount().compareTo(KualiDecimal.ZERO) != 0) {
pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText("The total dollar amount for your vehicle mileage is " + dvnet.getDisbVchrPersonalCarAmount());
if (LOG.isDebugEnabled()) {
LOG.debug("Creating non employee travel vehicle note: " + pnt.getCustomerNoteText());
}
pd.addNote(pnt);
for (DisbursementVoucherNonEmployeeExpense exp : (List<DisbursementVoucherNonEmployeeExpense>) dvnet.getDvNonEmployeeExpenses()) {
if (line < (maxNoteLines - 8)) {
pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText(exp.getDisbVchrExpenseCompanyName() + " " + exp.getDisbVchrExpenseAmount());
if (LOG.isDebugEnabled()) {
LOG.debug("Creating non employee travel expense note: " + pnt.getCustomerNoteText());
}
pd.addNote(pnt);
}
}
}
} else if (/*REFACTORME*/
getParameterEvaluatorService().getParameterEvaluator(DisbursementVoucherDocument.class, DisbursementVoucherConstants.PREPAID_TRAVEL_PAYMENT_REASONS_PARM_NM, paymentReasonCode).evaluationSucceeds()) {
pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText("Payment is for the following individuals/charges:");
pd.addNote(pnt);
if (LOG.isDebugEnabled()) {
LOG.info("Creating prepaid travel note note: " + pnt.getCustomerNoteText());
}
DisbursementVoucherPreConferenceDetail dvpcd = document.getDvPreConferenceDetail();
for (DisbursementVoucherPreConferenceRegistrant dvpcr : (List<DisbursementVoucherPreConferenceRegistrant>) dvpcd.getDvPreConferenceRegistrants()) {
if (line < (maxNoteLines - 8)) {
pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(line++));
pnt.setCustomerNoteText(dvpcr.getDvConferenceRegistrantName() + " " + dvpcr.getDisbVchrExpenseAmount());
if (LOG.isDebugEnabled()) {
LOG.debug("Creating pre-paid conference registrants note: " + pnt.getCustomerNoteText());
}
pd.addNote(pnt);
}
}
}
// Get the original, raw form, note text from the DV document.
final String text = document.getDisbVchrCheckStubText();
if (!StringUtils.isBlank(text)) {
pd.addNotes(getPaymentSourceHelperService().buildNotesForCheckStubText(text, line));
}
return pd;
}
use of org.kuali.kfs.sys.businessobject.SourceAccountingLine in project cu-kfs by CU-CommunityApps.
the class YearEndGeneralLedgerPendingEntriesServiceImpl method generateYearEndGeneralLedgerPendingEntries.
/**
* @see edu.cornell.kfs.fp.document.service.YearEndGeneralLedgerPendingEntriesService#generateYearEndGeneralLedgerPendingEntries(org.kuali.kfs.sys.document.AccountingDocumentBase, java.lang.String, java.util.List, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper, java.util.Collection)
*/
@Override
public boolean generateYearEndGeneralLedgerPendingEntries(AccountingDocumentBase document, String documentTypeCode, List<AccountingLine> accountingLines, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, Collection<String> closingCharts) {
Integer fiscalYear = new Integer(getParameterService().getParameterValueAsString(KfsParameterConstants.GENERAL_LEDGER_BATCH.class, GeneralLedgerConstants.ANNUAL_CLOSING_FISCAL_YEAR_PARM));
List<String> nominalActivityObjectTypeCodes = objectTypeService.getNominalActivityClosingAllowedObjectTypes(fiscalYear);
List<String> balanceForwardObjectTypeCodes = objectTypeService.getGeneralForwardBalanceObjectTypes(fiscalYear);
List<String> expenseObjectCodeTypes = objectTypeService.getExpenseObjectTypes(fiscalYear);
List<String> incomeObjectCodeTypes = objectTypeService.getBasicIncomeObjectTypes(fiscalYear);
Map<String, AccountingLine> incomeAccounts = new HashMap<String, AccountingLine>();
Map<String, AccountingLine> expenseAccounts = new HashMap<String, AccountingLine>();
List<AccountingLine> bbAccounts = new ArrayList<AccountingLine>();
Map<String, AccountingLine> accountCredit = new HashMap<String, AccountingLine>();
Map<String, AccountingLine> accountDebit = new HashMap<String, AccountingLine>();
for (AccountingLine accountingLine : accountingLines) {
if (ObjectUtils.isNull(closingCharts) || closingCharts.isEmpty()) {
// do nothing
} else {
if (closingCharts.contains(accountingLine.getChartOfAccountsCode())) {
// BB
if (balanceForwardObjectTypeCodes.contains(accountingLine.getFinancialObjectCode()) && accountingLine.getAmount().isNonZero()) {
bbAccounts.add(accountingLine);
}
// get the expense accounts
if (expenseObjectCodeTypes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode()) && nominalActivityObjectTypeCodes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode())) {
String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
if (expenseAccounts.containsKey(accountKey)) {
KualiDecimal expense = expenseAccounts.get(accountKey).getAmount();
KualiDecimal amount = accountingLine.getAmount();
// Expense will be positive with Debit (D) flag. If the flag is C it will be treated as a negative.
if (KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
amount = amount.negated();
}
expenseAccounts.get(accountKey).setAmount(expense.add(amount));
expenseAccounts.put(accountKey, expenseAccounts.get(accountKey));
} else {
KualiDecimal expense = accountingLine.getAmount();
// Expense will be positive with Debit (D) flag. If the flag is C it will be treated as a negative.
if (KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
expense = expense.negated();
}
SourceAccountingLine expenseAcctLine = new SourceAccountingLine();
expenseAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
expenseAcctLine.setAccountNumber(accountingLine.getAccountNumber());
expenseAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
expenseAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
expenseAcctLine.setProjectCode(accountingLine.getProjectCode());
expenseAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
expenseAcctLine.setAmount(expense);
expenseAccounts.put(accountKey, expenseAcctLine);
}
} else if (incomeObjectCodeTypes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode()) && nominalActivityObjectTypeCodes.contains(accountingLine.getObjectCode().getFinancialObjectTypeCode())) {
// get income
String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
if (incomeAccounts.containsKey(accountKey)) {
KualiDecimal income = incomeAccounts.get(accountKey).getAmount();
KualiDecimal amount = accountingLine.getAmount();
// Income will be positive with Credit (C) flag. If the flag is D it will be treated as a negative.
if (KFSConstants.GL_DEBIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
amount = amount.negated();
}
incomeAccounts.get(accountKey).setAmount(income.add(amount));
incomeAccounts.put(accountKey, incomeAccounts.get(accountKey));
} else {
KualiDecimal income = accountingLine.getAmount();
// Income will be positive with Credit (C) flag. If the flag is D it will be treated as a negative.
if (KFSConstants.GL_DEBIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
income = income.negated();
}
SourceAccountingLine incomeAcctLine = new SourceAccountingLine();
incomeAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
incomeAcctLine.setAccountNumber(accountingLine.getAccountNumber());
incomeAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
incomeAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
incomeAcctLine.setProjectCode(accountingLine.getProjectCode());
incomeAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
incomeAcctLine.setAmount(income);
incomeAccounts.put(accountKey, incomeAcctLine);
}
}
// credit
if (KFSConstants.GL_CREDIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
if (accountCredit.containsKey(accountKey)) {
KualiDecimal credit = accountCredit.get(accountKey).getAmount();
KualiDecimal amount = accountingLine.getAmount();
accountCredit.get(accountKey).setAmount(credit.add(amount));
accountCredit.put(accountKey, accountCredit.get(accountKey));
} else {
KualiDecimal credit = accountingLine.getAmount();
SourceAccountingLine creditAcctLine = new SourceAccountingLine();
creditAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
creditAcctLine.setAccountNumber(accountingLine.getAccountNumber());
creditAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
creditAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
creditAcctLine.setProjectCode(accountingLine.getProjectCode());
creditAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
creditAcctLine.setAmount(credit);
accountCredit.put(accountKey, creditAcctLine);
}
}
// debit
if (KFSConstants.GL_DEBIT_CODE.equalsIgnoreCase(accountingLine.getDebitCreditCode())) {
String accountKey = accountingLine.getChartOfAccountsCode() + accountingLine.getAccountNumber() + accountingLine.getSubAccountNumber() + accountingLine.getFinancialSubObjectCode() + accountingLine.getProjectCode() + accountingLine.getOrganizationReferenceId();
if (accountDebit.containsKey(accountKey)) {
KualiDecimal debit = accountDebit.get(accountKey).getAmount();
KualiDecimal amount = accountingLine.getAmount();
accountDebit.get(accountKey).setAmount(debit.add(amount));
accountDebit.put(accountKey, accountDebit.get(accountKey));
} else {
KualiDecimal debit = accountingLine.getAmount();
SourceAccountingLine debitAcctLine = new SourceAccountingLine();
debitAcctLine.setChartOfAccountsCode(accountingLine.getChartOfAccountsCode());
debitAcctLine.setAccountNumber(accountingLine.getAccountNumber());
debitAcctLine.setSubAccountNumber(accountingLine.getSubAccountNumber());
debitAcctLine.setFinancialSubObjectCode(accountingLine.getFinancialSubObjectCode());
debitAcctLine.setProjectCode(accountingLine.getProjectCode());
debitAcctLine.setOrganizationReferenceId(accountingLine.getOrganizationReferenceId());
debitAcctLine.setAmount(debit);
accountDebit.put(accountKey, debitAcctLine);
}
}
}
}
// create gl entries
// create NB 4490 income entry and 3190 offset
List<GeneralLedgerPendingEntry> entries = createPendingEntries(document, accountingLine, sequenceHelper, closingCharts, fiscalYear);
for (GeneralLedgerPendingEntry entry : entries) {
document.addPendingEntry(entry);
}
}
Set<String> incomeExpenseSet = new HashSet<String>();
incomeExpenseSet.addAll(incomeAccounts.keySet());
incomeExpenseSet.addAll(expenseAccounts.keySet());
// create BB income - expense 3190 entry
for (String accountKey : incomeExpenseSet) {
KualiDecimal income = KualiDecimal.ZERO;
KualiDecimal expense = KualiDecimal.ZERO;
AccountingLine acctLine = ObjectUtils.isNull(incomeAccounts.get(accountKey)) ? expenseAccounts.get(accountKey) : incomeAccounts.get(accountKey);
if (ObjectUtils.isNotNull(incomeAccounts.get(accountKey))) {
income = incomeAccounts.get(accountKey).getAmount();
}
if (ObjectUtils.isNotNull(expenseAccounts.get(accountKey))) {
expense = expenseAccounts.get(accountKey).getAmount();
}
KualiDecimal amount = income.subtract(expense);
acctLine.setAmount(amount);
if (ObjectUtils.isNotNull(amount) && amount.isNonZero()) {
document.addPendingEntry(generateBBIncomeLessExpenseOffset(document, acctLine, sequenceHelper.getSequenceCounter(), fiscalYear));
sequenceHelper.increment();
}
}
Set<String> creditDebitSet = new HashSet<String>();
creditDebitSet.addAll(accountCredit.keySet());
creditDebitSet.addAll(accountDebit.keySet());
// create 1000 cash offset entry for remaining cash = credit - debit
for (String accountKey : creditDebitSet) {
KualiDecimal credit = KualiDecimal.ZERO;
KualiDecimal debit = KualiDecimal.ZERO;
AccountingLine acctLine = ObjectUtils.isNull(accountCredit.get(accountKey)) ? accountDebit.get(accountKey) : accountCredit.get(accountKey);
if (ObjectUtils.isNotNull(accountCredit.get(accountKey))) {
credit = accountCredit.get(accountKey).getAmount();
}
if (ObjectUtils.isNotNull(accountDebit.get(accountKey))) {
debit = accountDebit.get(accountKey).getAmount();
}
KualiDecimal amount = credit.subtract(debit);
acctLine.setAmount(amount);
if (ObjectUtils.isNotNull(amount) && amount.isNonZero()) {
document.addPendingEntry(generateBBCashOffset(document, acctLine, sequenceHelper.getSequenceCounter(), documentTypeCode, fiscalYear));
sequenceHelper.increment();
}
}
return true;
}
use of org.kuali.kfs.sys.businessobject.SourceAccountingLine in project cu-kfs by CU-CommunityApps.
the class PurApAccountingLineBase method generateSourceAccountingLine.
/**
* @see org.kuali.kfs.module.purap.businessobject.PurApAccountingLine#generateSourceAccountingLine()
*/
@Override
public SourceAccountingLine generateSourceAccountingLine() {
// the fields here should probably match method 'accountStringsAreEqual' above
SourceAccountingLine sourceLine = new SourceAccountingLine();
sourceLine.setChartOfAccountsCode(getChartOfAccountsCode());
sourceLine.setAccountNumber(getAccountNumber());
sourceLine.setSubAccountNumber(getSubAccountNumber());
sourceLine.setFinancialObjectCode(getFinancialObjectCode());
sourceLine.setFinancialSubObjectCode(getFinancialSubObjectCode());
sourceLine.setProjectCode(getProjectCode());
sourceLine.setOrganizationReferenceId(getOrganizationReferenceId());
sourceLine.setAmount(getAmount());
sourceLine.setSequenceNumber(getSequenceNumber());
return sourceLine;
}
use of org.kuali.kfs.sys.businessobject.SourceAccountingLine in project cu-kfs by CU-CommunityApps.
the class CuAdvanceDepositDocumentAuthorizer method addAttributes.
protected void addAttributes(AdvanceDepositDocument advanceDepositDocument, Map<String, String> attributes) {
organizationService = SpringContext.getBean(OrganizationService.class);
Person currentUser = GlobalVariables.getUserSession().getPerson();
String roleId = getRoleService().getRoleIdByNamespaceCodeAndName(KFSConstants.ParameterNamespaces.FINANCIAL, CUKFSConstants.SysKimApiConstants.ADVANCE_DEPOSIT_ORGANIZATION_REVIEWER_ROLE_NAME);
List<String> roleIds = new ArrayList<String>();
roleIds.add(roleId);
List<Map<String, String>> qualifiers = new ArrayList<Map<String, String>>();
qualifiers.addAll(getRoleService().getRoleQualifersForPrincipalByRoleIds(currentUser.getPrincipalId(), roleIds, new HashMap<String, String>()));
if (qualifiers == null || qualifiers.isEmpty()) {
qualifiers.addAll(getRoleService().getNestedRoleQualifiersForPrincipalByRoleIds(currentUser.getPrincipalId(), roleIds, new HashMap<String, String>()));
}
// getRoleQualifiersForPrincipalIncludingNested does not work for simple principal members so we try RoleMembershipInfo for principals
if (qualifiers == null || qualifiers.isEmpty()) {
List<RoleMembership> roleMemberships = getRoleService().getRoleMembers(roleIds, null);
if (roleMemberships != null && roleMemberships.size() > 0) {
for (RoleMembership roleMembershipInfo : roleMemberships) {
if (currentUser.getPrincipalId().equalsIgnoreCase(roleMembershipInfo.getMemberId())) {
qualifiers.add(roleMembershipInfo.getQualifier());
}
}
}
}
Map<String, String> permissionDetails = new HashMap<String, String>();
if (qualifiers != null && qualifiers.size() > 0) {
for (Map<String, String> qualifier : qualifiers) {
{
for (String key : qualifier.keySet()) {
if (KfsKimAttributes.CHART_OF_ACCOUNTS_CODE.equalsIgnoreCase(key)) {
permissionDetails.put(key, qualifier.get(key));
}
if (KfsKimAttributes.ORGANIZATION_CODE.equalsIgnoreCase(key)) {
permissionDetails.put(key, qualifier.get(key));
}
if (KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME.equalsIgnoreCase(key)) {
permissionDetails.put(key, qualifier.get(key));
}
}
}
}
if (permissionDetails.containsKey(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME) && "AD".equalsIgnoreCase(permissionDetails.get(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME))) {
if (permissionDetails.containsKey(KfsKimAttributes.CHART_OF_ACCOUNTS_CODE) && permissionDetails.containsKey(KfsKimAttributes.ORGANIZATION_CODE)) {
if (advanceDepositDocument.getSourceAccountingLines() != null && advanceDepositDocument.getSourceAccountingLines().size() > 0) {
String chart = permissionDetails.get(KfsKimAttributes.CHART_OF_ACCOUNTS_CODE);
String org = permissionDetails.get(KfsKimAttributes.ORGANIZATION_CODE);
for (Object accountingLine : advanceDepositDocument.getSourceAccountingLines()) {
SourceAccountingLine sourceAccountingLine = (SourceAccountingLine) accountingLine;
String accountingLineChart = sourceAccountingLine.getChartOfAccountsCode();
String accountingLineOrg = KFSConstants.EMPTY_STRING;
sourceAccountingLine.refreshReferenceObject("account");
if (sourceAccountingLine.getAccount() != null) {
accountingLineOrg = sourceAccountingLine.getAccount().getOrganizationCode();
}
if (chart != null && chart.equalsIgnoreCase(accountingLineChart) && org != null && (org.equalsIgnoreCase(accountingLineOrg) || organizationService.isParentOrganization(accountingLineChart, accountingLineOrg, chart, org))) {
attributes.put(KfsKimAttributes.CHART_OF_ACCOUNTS_CODE, accountingLineChart);
attributes.put(KfsKimAttributes.ORGANIZATION_CODE, accountingLineOrg);
}
}
}
}
}
}
}
Aggregations