Attached Files | exportMultipleTaxes.diff [^] (9,690 bytes) 2018-10-23 20:55 [Show Content] [Hide Content]diff --git a/src/org/openbravo/service/integration/sap/ecc/mappings/component/PubonInvoiceLine.java b/src/org/openbravo/service/integration/sap/ecc/mappings/component/PubonInvoiceLine.java
--- a/src/org/openbravo/service/integration/sap/ecc/mappings/component/PubonInvoiceLine.java
+++ b/src/org/openbravo/service/integration/sap/ecc/mappings/component/PubonInvoiceLine.java
@@ -63,21 +63,11 @@
return amount != null ? amount.toString() : StringUtils.EMPTY;
}
- public String getTaxAmount() {
- BigDecimal amount = (BigDecimal) properties.get(MappingConstants.SAP_INVOICELINE_TAX_AMOUNT);
- return amount.toString();
- }
-
public String getTaxRate() {
return StringUtils.defaultIfBlank((String) properties.get(MappingConstants.SAP_TAX_RATE),
StringUtils.EMPTY);
}
- public String getInvoiceLineTaxRate() {
- return StringUtils.defaultIfBlank(
- (String) properties.get(MappingConstants.SAP_INVOICELINE_TAX_RATE), StringUtils.EMPTY);
- }
-
public String getPriceListSapCode() {
return StringUtils.defaultIfBlank(
(String) properties.get(MappingConstants.SAP_INVOICE_PRICELIST_SAP_CODE_FIELD),
@@ -104,4 +94,20 @@
}
return discountLines;
}
+
+ @SuppressWarnings("unchecked")
+ public List<PubonInvoiceLineTax> getInvoiceLineTaxes() {
+ List<PubonInvoiceLineTax> invoiceLineTaxes = new ArrayList<>();
+
+ List<SynchronizableBusinessObject> invoiceLineTaxesSbo = (List<SynchronizableBusinessObject>) properties
+ .get(MappingConstants.SAP_INVOICELINE_TAXES);
+ if (invoiceLineTaxesSbo == null) {
+ return invoiceLineTaxes;
+ }
+ for (SynchronizableBusinessObject invoiceLineTaxSbo : invoiceLineTaxesSbo) {
+ PubonInvoiceLineTax invoiceLineTax = new PubonInvoiceLineTax(invoiceLineTaxSbo.getProperties());
+ invoiceLineTaxes.add(invoiceLineTax);
+ }
+ return invoiceLineTaxes;
+ }
}
diff --git a/src/org/openbravo/service/integration/sap/ecc/mappings/component/PubonInvoiceLineTax.java b/src/org/openbravo/service/integration/sap/ecc/mappings/component/PubonInvoiceLineTax.java
new file mode 100644
--- /dev/null
+++ b/src/org/openbravo/service/integration/sap/ecc/mappings/component/PubonInvoiceLineTax.java
@@ -0,0 +1,40 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2018 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+
+package org.openbravo.service.integration.sap.ecc.mappings.component;
+
+import java.util.Map;
+
+import org.openbravo.service.integration.sap.ecc.mappings.util.MappingConstants;
+import org.openbravo.service.integration.sapecc.mapping.templates.PropertiesHolder;
+
+/**
+ * Template Component for segment E1WPB03 corresponding to Invoice lines taxes of the PUBON template
+ */
+public class PubonInvoiceLineTax implements PropertiesHolder {
+
+ private Map<String, Object> properties;
+
+ @Override
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public PubonInvoiceLineTax(Map<String, Object> properties) {
+ this.properties = properties;
+ }
+
+ public String getTaxSapCode() {
+ return (String) properties.get(MappingConstants.SAP_INVOICELINE_TAX_CODE);
+ }
+
+ public String getTaxRate() {
+ return (String) properties.get(MappingConstants.SAP_INVOICELINE_TAX_RATE);
+ }
+}
diff --git a/src/org/openbravo/service/integration/sap/ecc/mappings/javamapper/InvoiceLineJavaPropertyMappingHandler.java b/src/org/openbravo/service/integration/sap/ecc/mappings/javamapper/InvoiceLineJavaPropertyMappingHandler.java
--- a/src/org/openbravo/service/integration/sap/ecc/mappings/javamapper/InvoiceLineJavaPropertyMappingHandler.java
+++ b/src/org/openbravo/service/integration/sap/ecc/mappings/javamapper/InvoiceLineJavaPropertyMappingHandler.java
@@ -11,6 +11,7 @@
import static org.openbravo.service.integration.sap.ecc.mappings.util.MappingConstants.EXPORT_INVOICE_LINE_ENTITY_MAPPING_ID;
+import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -18,6 +19,7 @@
import org.apache.commons.lang.StringUtils;
import org.openbravo.base.exception.OBException;
+import org.openbravo.model.ad.access.InvoiceLineTax;
import org.openbravo.model.common.invoice.InvoiceLine;
import org.openbravo.model.common.invoice.InvoiceLineOffer;
import org.openbravo.model.financialmgmt.tax.TaxCategory;
@@ -48,12 +50,11 @@
properties.put(41, MappingConstants.SAP_INVOICELINE_RETURN_SIGN);
properties.put(51, MappingConstants.SAP_INVOICELINE_GROSS_AMOUNT);
properties.put(61, MappingConstants.SAP_INVOICELINE_TAX_AMOUNT);
- properties.put(71, MappingConstants.SAP_TAX_RATE);
properties.put(81, MappingConstants.SAP_INVOICE_PRICELIST_SAP_CODE_FIELD);
properties.put(91, MappingConstants.SAP_INVOICE_SERIAL_NUMBER);
properties.put(101, MappingConstants.SAP_INVOICELINE_DISCOUNT_SIGN);
properties.put(111, MappingConstants.SAP_INVOICELINE_DISCOUNT_SEGMENT);
- properties.put(121, MappingConstants.SAP_INVOICELINE_TAX_RATE);
+ properties.put(121, MappingConstants.SAP_INVOICELINE_TAXES);
properties.put(131, MappingConstants.SAP_INVOICELINE_QUANTITY);
return properties;
}
@@ -73,12 +74,8 @@
return getSignForSalesOrReturns(invoiceLine);
case MappingConstants.SAP_INVOICELINE_GROSS_AMOUNT:
return MappingUtils.getGrossAmountConsideringDiscountsAndTaxesInPriceList(invoiceLine);
- case MappingConstants.SAP_INVOICELINE_TAX_AMOUNT:
- return MappingUtils.getTaxRateScaled(invoiceLine);
case MappingConstants.SAP_TAX_RATE:
return getSalesSAPCode(invoiceLine.getTax().getTaxCategory());
- case MappingConstants.SAP_INVOICELINE_TAX_RATE:
- return MappingUtils.getSAPCode(invoiceLine.getTax());
case MappingConstants.SAP_INVOICE_PRICELIST_SAP_CODE_FIELD:
return MappingUtils.getSAPCode(invoiceLine.getInvoice().getPriceList());
case MappingConstants.SAP_INVOICE_SERIAL_NUMBER:
@@ -87,6 +84,8 @@
return getDiscount(invoiceLine);
case MappingConstants.SAP_INVOICELINE_QUANTITY:
return invoiceLine.getInvoicedQuantity().abs();
+ case MappingConstants.SAP_INVOICELINE_TAXES:
+ return getInvoiceLineTax(invoiceLine);
default:
return null;
}
@@ -175,6 +174,23 @@
return sbos;
}
+ private List<SynchronizableBusinessObject> getInvoiceLineTax(InvoiceLine invoiceLine) {
+ List<SynchronizableBusinessObject> sbos = new ArrayList<>();
+ for (InvoiceLineTax invoiceLineTax : invoiceLine.getInvoiceLineTaxList()) {
+ SynchronizableBusinessObject sbo = new SynchronizableBusinessObject();
+ processInvoiceLineTax(sbo, invoiceLineTax);
+ sbos.add(sbo);
+ }
+ return sbos;
+ }
+
+ private void processInvoiceLineTax(SynchronizableBusinessObject sbo, InvoiceLineTax invoiceLineTax) {
+ sbo.addProperty(MappingConstants.SAP_INVOICELINE_TAX_CODE,
+ MappingUtils.getSAPCode(invoiceLineTax.getTax()));
+ sbo.addProperty(MappingConstants.SAP_INVOICELINE_TAX_RATE, invoiceLineTax.getTax().getRate()
+ .multiply(BigDecimal.TEN).toPlainString());
+ }
+
protected void processInvoiceLineOffer(SynchronizableBusinessObject sbo,
InvoiceLineOffer lineOffer) {
MappingUtils.processInvoiceLineOffer(sbo, lineOffer);
diff --git a/src/org/openbravo/service/integration/sap/ecc/mappings/template/PUBON.ftl b/src/org/openbravo/service/integration/sap/ecc/mappings/template/PUBON.ftl
--- a/src/org/openbravo/service/integration/sap/ecc/mappings/template/PUBON.ftl
+++ b/src/org/openbravo/service/integration/sap/ecc/mappings/template/PUBON.ftl
@@ -48,10 +48,12 @@
<KONDITION>${line.priceListSapCode}</KONDITION>
<KONDVALUE>${line.grossAmount}</KONDVALUE>
</E1WPB03>
+ <#list line.invoiceLineTaxes as invoiceLineTax>
<E1WPB03 SEGMENT="1">
- <KONDITION>${line.invoiceLineTaxRate}</KONDITION>
- <KONDVALUE>${line.taxAmount}</KONDVALUE>
+ <KONDITION>${invoiceLineTax.taxSapCode}</KONDITION>
+ <KONDVALUE>${invoiceLineTax.taxRate}</KONDVALUE>
</E1WPB03>
+ </#list>
<#list line.discounts as discount>
<E1WPB03 SEGMENT="1">
<KONDITION>${discount.discountSapCode}</KONDITION>
diff --git a/src/org/openbravo/service/integration/sap/ecc/mappings/util/MappingConstants.java b/src/org/openbravo/service/integration/sap/ecc/mappings/util/MappingConstants.java
--- a/src/org/openbravo/service/integration/sap/ecc/mappings/util/MappingConstants.java
+++ b/src/org/openbravo/service/integration/sap/ecc/mappings/util/MappingConstants.java
@@ -118,7 +118,9 @@
public static final String SAP_INVOICELINE_DISCOUNT_SEGMENT = "SEGMENT03DISCOUNTS";
public static final String SAP_INVOICELINE_DISCOUNT_SAP_CODE_FIELD = "DISCOUNTSAPCODE";
public static final String SAP_INVOICELINE_DISCOUNT_AMOUNT = "DISCOUNTAMOUNT";
- public static final String SAP_INVOICELINE_TAX_RATE = "SEGMENT03TAXRATE";
+ public static final String SAP_INVOICELINE_TAXES = "SEGMENT03INVOICELINETAXES";
+ public static final String SAP_INVOICELINE_TAX_CODE = "TAXSAPCODE";
+ public static final String SAP_INVOICELINE_TAX_RATE = "TAXRATE";
public static final String SAP_INVOICELINE_QUANTITY = "MENGE";
public static final String SAP_WPUTAB_CURRENCY = "WAEHRUNG";
public static final String SAP_WPUTAB_SIGN = "VORZEICHEN";
|