use of org.kuali.kfs.core.api.util.type.KualiInteger 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 = parameterService.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.setInvoiceNbr(filterOutIllegalXmlCharacters(document.getInvoiceNumber()));
if (ObjectUtils.isNull(document.getInvoiceDate())) {
pd.setInvoiceDate(new java.sql.Date(processRunDate.getTime()));
} else {
pd.setInvoiceDate(document.getInvoiceDate());
}
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 = dvpd.getDisbVchrSpecialHandlingPersonName();
String dvSpecialHandlingLine1Address = dvpd.getDisbVchrSpecialHandlingLine1Addr();
String dvSpecialHandlingLine2Address = dvpd.getDisbVchrSpecialHandlingLine2Addr();
String dvSpecialHandlingCity = dvpd.getDisbVchrSpecialHandlingCityName();
String dvSpecialHandlingState = dvpd.getDisbVchrSpecialHandlingStateCode();
String 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*/
parameterEvaluatorService.getParameterEvaluator(DisbursementVoucherDocument.class, FPParameterConstants.NON_EMPLOYEE_TRAVEL_PAY_REASONS, 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*/
parameterEvaluatorService.getParameterEvaluator(DisbursementVoucherDocument.class, FPParameterConstants.PREPAID_TRAVEL_PAYMENT_REASONS, 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);
}
}
}
final String text = filterOutIllegalXmlCharacters(document.getDisbVchrCheckStubText());
if (!StringUtils.isBlank(text)) {
pd.addNotes(paymentSourceHelperService.buildNotesForCheckStubText(text, line));
}
return pd;
}
use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.
the class CuBudgetAdjustmentDocumentBalancedValidation method validate.
public boolean validate(AttributedDocumentEvent event) {
boolean balanced = true;
// check base amounts are equal
// KFSMI-3036
KualiInteger sourceBaseBudgetTotal = getAccountingDocumentForValidation().getSourceBaseBudgetIncomeTotal().subtract(getAccountingDocumentForValidation().getSourceBaseBudgetExpenseTotal());
KualiInteger targetBaseBudgetTotal = getAccountingDocumentForValidation().getTargetBaseBudgetIncomeTotal().subtract(getAccountingDocumentForValidation().getTargetBaseBudgetExpenseTotal());
if (sourceBaseBudgetTotal.compareTo(targetBaseBudgetTotal) != 0) {
GlobalVariables.getMessageMap().putError(KFSConstants.ACCOUNTING_LINE_ERRORS, FPKeyConstants.ERROR_DOCUMENT_BA_BASE_AMOUNTS_BALANCED);
balanced = false;
}
// check document is balanced within the accounts
Map accountsMap = buildAccountBalanceMapForDocumentBalance(true);
for (KualiDecimal accountAmount : (Collection<KualiDecimal>) accountsMap.values()) {
if (accountAmount.isNonZero()) {
GlobalVariables.getMessageMap().putError(KFSConstants.ACCOUNTING_LINE_ERRORS, CUKFSKeyConstants.ERROR_DOCUMENT_BA_ACCOUNT_BASE_AMOUNTS_BALANCED);
balanced = false;
break;
}
}
// check current amounts balance, income stream balance Map should add to 0
Map incomeStreamMap = getAccountingDocumentForValidation().buildIncomeStreamBalanceMapForDocumentBalance();
KualiDecimal totalCurrentAmount = new KualiDecimal(0);
for (Object o : incomeStreamMap.values()) {
KualiDecimal streamAmount = (KualiDecimal) o;
totalCurrentAmount = totalCurrentAmount.add(streamAmount);
}
if (totalCurrentAmount.isNonZero()) {
GlobalVariables.getMessageMap().putError(KFSConstants.ACCOUNTING_LINE_ERRORS, FPKeyConstants.ERROR_DOCUMENT_BA_CURRENT_AMOUNTS_BALANCED);
balanced = false;
}
// check document is balanced within the accounts
accountsMap = buildAccountBalanceMapForDocumentBalance(false);
for (KualiDecimal accountAmount : (Collection<KualiDecimal>) accountsMap.values()) {
if (accountAmount.isNonZero()) {
GlobalVariables.getMessageMap().putError(KFSConstants.ACCOUNTING_LINE_ERRORS, CUKFSKeyConstants.ERROR_DOCUMENT_BA_ACCOUNT_AMOUNTS_BALANCED);
balanced = false;
break;
}
}
return balanced;
}
use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.
the class CuPdpExtractServiceImpl method addNotes.
@Override
protected void addNotes(AccountsPayableDocument accountsPayableDocument, PaymentDetail paymentDetail) {
int count = 1;
if (accountsPayableDocument instanceof PaymentRequestDocument) {
PaymentRequestDocument prd = (PaymentRequestDocument) accountsPayableDocument;
if (prd.getSpecialHandlingInstructionLine1Text() != null) {
PaymentNoteText pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(count++));
pnt.setCustomerNoteText(CUPurapConstants.SPECIAL_HANDLING_NOTE_LINE_1_NAME + prd.getSpecialHandlingInstructionLine1Text());
paymentDetail.addNote(pnt);
}
if (prd.getSpecialHandlingInstructionLine2Text() != null) {
PaymentNoteText pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(count++));
pnt.setCustomerNoteText(CUPurapConstants.SPECIAL_HANDLING_NOTE_LINE_2_ADDRESS + prd.getSpecialHandlingInstructionLine2Text());
paymentDetail.addNote(pnt);
}
if (prd.getSpecialHandlingInstructionLine3Text() != null) {
PaymentNoteText pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(count++));
pnt.setCustomerNoteText(CUPurapConstants.SPECIAL_HANDLING_NOTE_LINE_3_CITY_STATE_ZIP + prd.getSpecialHandlingInstructionLine3Text());
paymentDetail.addNote(pnt);
}
}
if (accountsPayableDocument.getNoteLine1Text() != null) {
PaymentNoteText pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(count++));
pnt.setCustomerNoteText(CUPurapConstants.PURAP_NOTES_IDENTIFIER + accountsPayableDocument.getNoteLine1Text());
paymentDetail.addNote(pnt);
}
if (accountsPayableDocument.getNoteLine2Text() != null) {
PaymentNoteText pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(count++));
pnt.setCustomerNoteText(CUPurapConstants.PURAP_NOTES_IDENTIFIER + accountsPayableDocument.getNoteLine2Text());
paymentDetail.addNote(pnt);
}
if (accountsPayableDocument.getNoteLine3Text() != null) {
PaymentNoteText pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(count++));
pnt.setCustomerNoteText(CUPurapConstants.PURAP_NOTES_IDENTIFIER + accountsPayableDocument.getNoteLine3Text());
paymentDetail.addNote(pnt);
}
PaymentNoteText pnt = new PaymentNoteText();
pnt.setCustomerNoteLineNbr(new KualiInteger(count++));
pnt.setCustomerNoteText("Sales Tax: " + accountsPayableDocument.getTotalRemitTax());
}
use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.
the class CuFormatServiceImpl method startFormatProcess.
@Override
public FormatProcessSummary startFormatProcess(Person user, String campus, List<CustomerProfile> customers, Date paydate, String paymentTypes, String paymentDistribution) {
LOG.debug("startFormatProcess() started");
for (CustomerProfile element : customers) {
LOG.debug("startFormatProcess() Customer: " + element);
}
// Create the process
Date d = new Date();
PaymentProcess paymentProcess = new PaymentProcess();
paymentProcess.setCampusCode(campus);
paymentProcess.setProcessUser(user);
paymentProcess.setProcessTimestamp(new Timestamp(d.getTime()));
this.businessObjectService.save(paymentProcess);
// add an entry in the format process table (to lock the format process)
FormatProcess formatProcess = new FormatProcess();
formatProcess.setPhysicalCampusProcessCode(campus);
formatProcess.setBeginFormat(dateTimeService.getCurrentTimestamp());
formatProcess.setPaymentProcIdentifier(paymentProcess.getId().intValue());
this.businessObjectService.save(formatProcess);
Timestamp now = new Timestamp((new Date()).getTime());
java.sql.Date sqlDate = new java.sql.Date(paydate.getTime());
Calendar c = Calendar.getInstance();
c.setTime(sqlDate);
c.set(Calendar.HOUR, 11);
c.set(Calendar.MINUTE, 59);
c.set(Calendar.SECOND, 59);
c.set(Calendar.MILLISECOND, 59);
c.set(Calendar.AM_PM, Calendar.PM);
Timestamp paydateTs = new Timestamp(c.getTime().getTime());
LOG.debug("startFormatProcess() last update = " + now);
LOG.debug("startFormatProcess() entered paydate = " + paydate);
LOG.debug("startFormatProcess() actual paydate = " + paydateTs);
PaymentStatus format = this.businessObjectService.findBySinglePrimaryKey(PaymentStatus.class, PdpConstants.PaymentStatusCodes.FORMAT);
List<KualiInteger> customerIds = new ArrayList<>();
for (CustomerProfile element : customers) {
customerIds.add(element.getId());
}
// Mark all of them ready for format
Iterator groupIterator = ((CuFormatPaymentDao) formatPaymentDao).markPaymentsForFormat(customerIds, paydateTs, paymentTypes, paymentDistribution);
while (groupIterator.hasNext()) {
PaymentGroup paymentGroup = (PaymentGroup) groupIterator.next();
paymentGroup.setLastUpdatedTimestamp(paydateTs);
paymentGroup.setPaymentStatus(format);
paymentGroup.setProcess(paymentProcess);
businessObjectService.save(paymentGroup);
}
// summarize them
FormatProcessSummary preFormatProcessSummary = new FormatProcessSummary();
Iterator<PaymentGroup> iterator = this.paymentGroupService.getByProcess(paymentProcess);
while (iterator.hasNext()) {
PaymentGroup paymentGroup = iterator.next();
preFormatProcessSummary.add(paymentGroup);
}
// if no payments found for format clear the format process
if (preFormatProcessSummary.getProcessSummaryList().size() == 0) {
LOG.debug("startFormatProcess() No payments to process. Format process ending");
clearUnfinishedFormat(paymentProcess.getId().intValue());
}
return preFormatProcessSummary;
}
use of org.kuali.kfs.core.api.util.type.KualiInteger in project cu-kfs by CU-CommunityApps.
the class CuPendingTransactionServiceImpl method getCrCancelMaintenancedocumentNumber.
private String getCrCancelMaintenancedocumentNumber(PaymentDetail paymentDetail) {
String crCancelMaintDocNbr = KFSConstants.EMPTY_STRING;
KualiInteger crCheckNbr = paymentDetail.getPaymentGroup().getDisbursementNbr();
Map<String, KualiInteger> fieldValues = new HashMap<String, KualiInteger>();
fieldValues.put("checkNumber", crCheckNbr);
Collection<CheckReconciliation> crEntries = getBusinessObjectService().findMatching(CheckReconciliation.class, fieldValues);
if (crEntries != null && crEntries.size() > 0) {
CheckReconciliation crEntry = crEntries.iterator().next();
crCancelMaintDocNbr = crEntry.getCancelDocHdrId();
}
return crCancelMaintDocNbr;
}
Aggregations