/** * @see * org.kuali.kfs.module.ar.document.service.CustomerInvoiceDocumentService#getOriginalTotalAmountForCustomerInvoiceDocument(org.kuali.kfs.module.ar.document.CustomerInvoiceDocument) */ @Override public KualiDecimal getOriginalTotalAmountForCustomerInvoiceDocument( CustomerInvoiceDocument customerInvoiceDocument) { LOG.info( "\n\n\n\t\t invoice: " + customerInvoiceDocument.getDocumentNumber() + "\n\t\t 111111111 HEADER TOTAL AMOUNT (should be null): " + customerInvoiceDocument .getFinancialSystemDocumentHeader() .getFinancialDocumentTotalAmount() + "\n\n"); customerInvoiceDocument.getDocumentNumber(); HashMap criteria = new HashMap(); criteria.put( KFSPropertyConstants.DOCUMENT_NUMBER, customerInvoiceDocument.getDocumentHeader().getDocumentTemplateNumber()); FinancialSystemDocumentHeader financialSystemDocumentHeader = businessObjectService.findByPrimaryKey(FinancialSystemDocumentHeader.class, criteria); KualiDecimal originalTotalAmount = KualiDecimal.ZERO; originalTotalAmount = financialSystemDocumentHeader.getFinancialDocumentTotalAmount(); LOG.info( "\n\n\n\t\t invoice: " + customerInvoiceDocument.getDocumentNumber() + "\n\t\t 333333333333 HEADER TOTAL AMOUNT (should be set now): " + customerInvoiceDocument .getFinancialSystemDocumentHeader() .getFinancialDocumentTotalAmount() + "\n\n"); return originalTotalAmount; }
/** * @see * org.kuali.kfs.module.ar.document.service.InvoiceRecurrenceService#isInvoiceApproved(String) */ @Override public boolean isInvoiceApproved(String invoiceNumber) { boolean success = true; if (ObjectUtils.isNull(invoiceNumber)) { return success; } CustomerInvoiceDocument customerInvoiceDocument = null; try { customerInvoiceDocument = (CustomerInvoiceDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(invoiceNumber); } catch (WorkflowException e) { } if (ObjectUtils.isNotNull(customerInvoiceDocument)) { WorkflowDocument workflowDocument = customerInvoiceDocument.getDocumentHeader().getWorkflowDocument(); if (!(workflowDocument.isApproved())) { success = false; } } else { success = false; } return success; }
/** * @see * org.kuali.kfs.module.ar.document.service.CustomerInvoiceDocumentService#getPrintableCustomerInvoiceDocumentsByInitiatorPrincipalName(java.lang.String) */ @Override public List<CustomerInvoiceDocument> getPrintableCustomerInvoiceDocumentsByInitiatorPrincipalName( String initiatorPrincipalName) { if (StringUtils.isBlank(initiatorPrincipalName)) { throw new IllegalArgumentException( "The parameter [initiatorPrincipalName] passed in was null or blank."); } // IMPORTANT NOTES ABOUT THIS METHOD // // This method behaves differently than the other invoice printing methods. This is // because there's no way from within KFS to do a direct DB call to get all the invoices // you want. This is because workflow holds the document initiator, and you cant guarantee // that in a given implementation that you have access to that other db. It could be on // another box in another network, and you only have web-services access to the Rice box. // // Given that, we try to minimize the resource hit of this call as much as possible. First // we retrieve all invoices that havent been printed (ie, dont have a print date) and that // are marked for the USER print queue. At any given time that should be a manageable number of // documents. // // Then we walk through them, retrieve the full workflow-populated version of it, and only // return the ones that match the initiator. // // This isnt as performant a solution as the other getPrintableCustomerInvoiceBy... // methods, but its the best we can do in this release, and it should be manageable. // // attempt to retrieve the initiator person specified, and puke if not found Principal initiator = KimApiServiceLocator.getIdentityService() .getPrincipalByPrincipalName(initiatorPrincipalName); if (initiator == null) { throw new IllegalArgumentException( "The parameter value for initiatorPrincipalName [" + initiatorPrincipalName + "] passed in doesnt map to a person."); } // retrieve all the ready-to-print docs in the user-queue for all users List<String> printableUserQueueDocNumbers = customerInvoiceDocumentDao.getPrintableCustomerInvoiceDocumentNumbersFromUserQueue(); // get all the documents that might be right, but this set includes documents generated // by the wrong user List<CustomerInvoiceDocument> customerInvoiceDocumentsSuperSet = new ArrayList<CustomerInvoiceDocument>(); if (printableUserQueueDocNumbers.size() > 0) { try { for (Document doc : documentService.getDocumentsByListOfDocumentHeaderIds( CustomerInvoiceDocument.class, printableUserQueueDocNumbers)) { customerInvoiceDocumentsSuperSet.add((CustomerInvoiceDocument) doc); } } catch (WorkflowException e) { throw new RuntimeException("Unable to retrieve Customer Invoice Documents", e); } } else { customerInvoiceDocumentsSuperSet = new ArrayList<CustomerInvoiceDocument>(); } // filter only the ones initiated by the correct user List<CustomerInvoiceDocument> customerInvoiceDocuments = new ArrayList<CustomerInvoiceDocument>(); for (CustomerInvoiceDocument superSetDocument : customerInvoiceDocumentsSuperSet) { if (StringUtils.equalsIgnoreCase( superSetDocument.getDocumentHeader().getWorkflowDocument().getInitiatorPrincipalId(), initiator.getPrincipalId())) { customerInvoiceDocuments.add(superSetDocument); } } return customerInvoiceDocuments; }