src/org/openbravo/erpCommon/ad_callouts/SL_Invoice_Charge_Tax.java
author Carlos Aristu <carlos.aristu@openbravo.com>
Fri, 22 Mar 2019 12:52:07 +0100
changeset 35553 d63dbf55ca53
parent 35352 4590a05d86f8
permissions -rw-r--r--
related to issue 40438: AD Implementation Mapping - Mapping tab UI improvements

- Place mandatory field at the beginning, both in grid and form views
carlos@0
     1
/*
carlos@0
     2
 *************************************************************************
carlos@0
     3
 * The contents of this file are subject to the Openbravo  Public  License
priya@9072
     4
 * Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
carlos@0
     5
 * Version 1.1  with a permitted attribution clause; you may not  use this
carlos@0
     6
 * file except in compliance with the License. You  may  obtain  a copy of
carlos@0
     7
 * the License at http://www.openbravo.com/legal/license.html 
carlos@0
     8
 * Software distributed under the License  is  distributed  on  an "AS IS"
carlos@0
     9
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
carlos@0
    10
 * License for the specific  language  governing  rights  and  limitations
carlos@0
    11
 * under the License. 
carlos@0
    12
 * The Original Code is Openbravo ERP. 
ggi@6701
    13
 * The Initial Developer of the Original Code is Openbravo SLU 
markmm82@32538
    14
 * All portions are Copyright (C) 2001-2017 Openbravo SLU 
carlos@0
    15
 * All Rights Reserved. 
carlos@0
    16
 * Contributor(s):  ______________________________________.
carlos@0
    17
 ************************************************************************
martin@2462
    18
 */
carlos@0
    19
package org.openbravo.erpCommon.ad_callouts;
carlos@0
    20
martin@2598
    21
import java.io.IOException;
martin@2598
    22
martin@2598
    23
import javax.servlet.ServletException;
martin@2598
    24
markmm82@32538
    25
import org.apache.commons.lang.StringUtils;
markmm82@32538
    26
import org.openbravo.base.filter.IsIDFilter;
martin@2598
    27
import org.openbravo.erpCommon.businessUtility.Tax;
martin@2598
    28
import org.openbravo.erpCommon.utility.Utility;
carlos@0
    29
markmm82@32538
    30
public class SL_Invoice_Charge_Tax extends SimpleCallout {
carlos@0
    31
markmm82@32538
    32
  @Override
markmm82@32538
    33
  protected void execute(CalloutInfo info) throws ServletException {
carlos@0
    34
markmm82@32538
    35
    String strChanged = info.getLastFieldChanged();
markmm82@32538
    36
    if (log4j.isDebugEnabled()) {
markmm82@32538
    37
      log4j.debug("CHANGED: " + strChanged);
markmm82@32538
    38
    }
carlos@0
    39
markmm82@32538
    40
    // Parameters
markmm82@32538
    41
    String strMProductID = info.getStringParameter("inpmProductId", IsIDFilter.instance);
markmm82@32538
    42
    String strADOrgID = info.getStringParameter("inpadOrgId", IsIDFilter.instance);
markmm82@32538
    43
    String strCInvoiceID = info.getStringParameter("inpcInvoiceId", IsIDFilter.instance);
markmm82@32538
    44
    String strIsSOTrx = Utility.getContext(this, info.vars, "isSOTrx", info.getWindowId());
asier@35352
    45
    String strWarehouse = Utility.getContext(this, info.vars, "#M_Warehouse_ID",
asier@35352
    46
        info.getWindowId());
markmm82@32538
    47
    String strCChargeID = info.getStringParameter("inpcChargeId", IsIDFilter.instance);
markmm82@32538
    48
markmm82@32538
    49
    // Tax
markmm82@32538
    50
    SLInvoiceTaxData[] data = SLInvoiceTaxData.select(this, strCInvoiceID);
markmm82@32538
    51
    if (data != null && data.length > 0) {
martin@2868
    52
      try {
markmm82@32538
    53
        String strCTaxID = Tax.get(this, strMProductID, data[0].dateinvoiced, strADOrgID,
markmm82@32538
    54
            strWarehouse, data[0].cBpartnerLocationId, data[0].cBpartnerLocationId,
markmm82@32538
    55
            data[0].cProjectId, StringUtils.equals(strIsSOTrx, "Y"));
markmm82@32538
    56
        info.addResult("inpcTaxId", strCTaxID);
markmm82@32538
    57
      } catch (IOException e) {
markmm82@32538
    58
        log4j.error(e.getMessage());
martin@2868
    59
      }
markmm82@32538
    60
    }
carlos@0
    61
markmm82@32538
    62
    // Charge Amount
asier@35352
    63
    String chargeAmt = StringUtils.isEmpty(strCChargeID) ? "0"
asier@35352
    64
        : SLChargeData.chargeAmt(this, strCChargeID);
markmm82@32538
    65
    info.addResult("inpchargeamt", chargeAmt);
martin@2868
    66
  }
carlos@0
    67
}