/** * @see * org.kuali.kfs.module.ar.document.service.AccountsReceivableTaxService#getPostalCodeForTaxation(org.kuali.kfs.module.ar.document.CustomerInvoiceDocument) */ @Override public String getPostalCodeForTaxation(CustomerInvoiceDocument document) { String postalCode = null; String customerNumber = document.getAccountsReceivableDocumentHeader().getCustomerNumber(); Integer shipToAddressIdentifier = document.getCustomerShipToAddressIdentifier(); // if customer number or ship to address id isn't provided, go to org options if (ObjectUtils.isNotNull(shipToAddressIdentifier) && StringUtils.isNotEmpty(customerNumber)) { CustomerAddressService customerAddressService = SpringContext.getBean(CustomerAddressService.class); CustomerAddress customerShipToAddress = customerAddressService.getByPrimaryKey(customerNumber, shipToAddressIdentifier); if (ObjectUtils.isNotNull(customerShipToAddress)) { postalCode = customerShipToAddress.getCustomerZipCode(); } } else { Map<String, String> criteria = new HashMap<String, String>(); criteria.put("chartOfAccountsCode", document.getBillByChartOfAccountCode()); criteria.put("organizationCode", document.getBilledByOrganizationCode()); OrganizationOptions organizationOptions = (OrganizationOptions) businessObjectService.findByPrimaryKey(OrganizationOptions.class, criteria); if (ObjectUtils.isNotNull(organizationOptions)) { postalCode = organizationOptions.getOrganizationPostalZipCode(); } } return postalCode; }
/** * Refactor to have all the setters in here. * * @see * org.kuali.kfs.module.ar.document.service.CustomerInvoiceDocumentService#setupDefaultValuesForNewCustomerInvoiceDocument(org.kuali.kfs.module.ar.document.CustomerInvoiceDocument) */ @Override public void setupDefaultValuesForNewCustomerInvoiceDocument(CustomerInvoiceDocument document) { setupBasicDefaultValuesForCustomerInvoiceDocument(document); // set up the default values for the AR DOC Header AccountsReceivableDocumentHeader accountsReceivableDocumentHeader = accountsReceivableDocumentHeaderService .getNewAccountsReceivableDocumentHeaderForCurrentUser(); accountsReceivableDocumentHeader.setDocumentNumber(document.getDocumentNumber()); document.setAccountsReceivableDocumentHeader(accountsReceivableDocumentHeader); // set up the primary key for AR_INV_RCURRNC_DTL_T CustomerInvoiceRecurrenceDetails recurrenceDetails = new CustomerInvoiceRecurrenceDetails(); recurrenceDetails.setInvoiceNumber(document.getDocumentNumber()); // recurrenceDetails.setCustomerNumber(document.getCustomer().getCustomerNumber()); document.setCustomerInvoiceRecurrenceDetails(recurrenceDetails); Map<String, String> criteria = new HashMap<String, String>(); criteria.put( KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, document.getBillByChartOfAccountCode()); criteria.put(KFSPropertyConstants.ORGANIZATION_CODE, document.getBilledByOrganizationCode()); OrganizationOptions organizationOptions = businessObjectService.findByPrimaryKey(OrganizationOptions.class, criteria); if (ObjectUtils.isNotNull(organizationOptions)) { document.setPrintInvoiceIndicator(organizationOptions.getPrintInvoiceIndicator()); document.setInvoiceTermsText(organizationOptions.getOrganizationPaymentTermsText()); } // If document is using receivable option, set receivable accounting line for customer invoice // document String receivableOffsetOption = parameterService.getParameterValueAsString( CustomerInvoiceDocument.class, ArConstants.GLPE_RECEIVABLE_OFFSET_GENERATION_METHOD); boolean isUsingReceivableFAU = ArConstants.GLPE_RECEIVABLE_OFFSET_GENERATION_METHOD_FAU.equals(receivableOffsetOption); if (isUsingReceivableFAU) { receivableAccountingLineService.setReceivableAccountingLineForCustomerInvoiceDocument( document); } }