Improved: General refactoring and code improvements, package

org.apache.ofbiz.accounting.invoice.
(OFBIZ-9870)

The patches were modified to remove unnecessary Debug.is[Loglevel]On()
conditions, see OFBIZ-10049.

Thanks Dennis Balkir for reporting and providing the patches.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1817748 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Brohl
2017-12-11 07:42:33 +00:00
parent 4842997323
commit 2a40c4378d
2 changed files with 315 additions and 307 deletions
@@ -62,7 +62,7 @@ public final class InvoiceWorker {
* Return the total amount of the invoice (including tax) using the the invoiceId as input.
* @param delegator the delegator
* @param invoiceId the invoice id
* @return Return the total amount of the invoice
* @return Return the total amount of the invoice
*/
public static BigDecimal getInvoiceTotal(Delegator delegator, String invoiceId) {
return getInvoiceTotal(delegator, invoiceId, Boolean.TRUE);
@@ -115,7 +115,7 @@ public final class InvoiceWorker {
/** Method to get the taxable invoice item types as a List of invoiceItemTypeIds. These are identified in Enumeration with enumTypeId TAXABLE_INV_ITM_TY. */
public static List<String> getTaxableInvoiceItemTypeIds(Delegator delegator) throws GenericEntityException {
List<String> typeIds = new LinkedList<String>();
List<String> typeIds = new LinkedList<>();
List<GenericValue> invoiceItemTaxTypes = EntityQuery.use(delegator).from("Enumeration").where("enumTypeId", "TAXABLE_INV_ITM_TY")
.cache().queryList();
for (GenericValue invoiceItemTaxType : invoiceItemTaxTypes) {
@@ -216,8 +216,9 @@ public final class InvoiceWorker {
} catch (GenericEntityException e) {
Debug.logError(e, "Trouble getting Party from InvoiceRole", module);
}
if (party != null)
if (party != null) {
return party;
}
}
return null;
}
@@ -259,8 +260,9 @@ public final class InvoiceWorker {
} catch (GenericEntityException e) {
Debug.logError(e, "Trouble getting Party from InvoiceRole", module);
}
if (party != null)
if (party != null) {
return party;
}
}
return null;
}
@@ -282,7 +284,7 @@ public final class InvoiceWorker {
public static GenericValue getSendFromAddress(GenericValue invoice) {
return getInvoiceAddressByType(invoice, "PAYMENT_LOCATION");
}
public static GenericValue getInvoiceAddressByType(GenericValue invoice, String contactMechPurposeTypeId) {
return getInvoiceAddressByType(invoice, contactMechPurposeTypeId, true);
}
@@ -301,10 +303,12 @@ public final class InvoiceWorker {
// if no locations found get it from the PartyAndContactMech using the from and to party on the invoice
String destinationPartyId = null;
Timestamp now = UtilDateTime.nowTimestamp();
if ("SALES_INVOICE".equals(invoice.getString("invoiceTypeId")))
if ("SALES_INVOICE".equals(invoice.getString("invoiceTypeId"))) {
destinationPartyId = invoice.getString("partyId");
if ("PURCHASE_INVOICE".equals(invoice.getString("invoiceTypeId")))
}
if ("PURCHASE_INVOICE".equals(invoice.getString("invoiceTypeId"))) {
destinationPartyId = invoice.getString("partyId");
}
try {
locations = EntityQuery.use(delegator).from("PartyContactWithPurpose")
.where("partyId", destinationPartyId, "contactMechPurposeTypeId", contactMechPurposeTypeId).queryList();
@@ -590,7 +594,7 @@ public final class InvoiceWorker {
@Deprecated
public static Map<String, Object> getInvoiceTaxByTaxAuthGeoAndParty(GenericValue invoice) {
BigDecimal taxGrandTotal = ZERO;
List<Map<String, Object>> taxByTaxAuthGeoAndPartyList = new LinkedList<Map<String,Object>>();
List<Map<String, Object>> taxByTaxAuthGeoAndPartyList = new LinkedList<>();
List<GenericValue> invoiceItems = null;
if (invoice != null) {
try {
@@ -638,7 +642,7 @@ public final class InvoiceWorker {
}
}
}
Map<String, Object> result = new HashMap<String, Object>();
Map<String, Object> result = new HashMap<>();
result.put("taxByTaxAuthGeoAndPartyList", taxByTaxAuthGeoAndPartyList);
result.put("taxGrandTotal", taxGrandTotal);
return result;
@@ -651,10 +655,11 @@ public final class InvoiceWorker {
* will not account for tax lines that do not contain a taxAuthPartyId
*/
public static Map<String, Set<String>> getInvoiceTaxAuthPartyAndGeos (GenericValue invoice) {
Map<String, Set<String>> result = new HashMap<String, Set<String>>();
Map<String, Set<String>> result = new HashMap<>();
if (invoice == null)
throw new IllegalArgumentException("Invoice cannot be null.");
if (invoice == null) {
throw new IllegalArgumentException("Invoice cannot be null.");
}
List<GenericValue> invoiceTaxItems = null;
try {
Delegator delegator = invoice.getDelegator();
@@ -672,7 +677,7 @@ public final class InvoiceWorker {
String taxAuthGeoId = invoiceItem.getString("taxAuthGeoId");
if (UtilValidate.isNotEmpty(taxAuthPartyId)) {
if (!result.containsKey(taxAuthPartyId)) {
Set<String> taxAuthGeos = new HashSet<String>();
Set<String> taxAuthGeos = new HashSet<>();
taxAuthGeos.add(taxAuthGeoId);
result.put(taxAuthPartyId, taxAuthGeos);
} else {