public BigDecimal getTaxTotal() {
    BigDecimal cartFeesTotal = new BigDecimal("0");
    final Set<Tax> taxes = getTaxes();
    if (taxes != null) {
      for (Iterator<Tax> iterator = taxes.iterator(); iterator.hasNext(); ) {
        final Tax tax = (Tax) iterator.next();

        // TODO TAX can be only on product or deliveyMethod or both

        BigDecimal taxesCalc = getDeliveryMethodTotal();
        taxesCalc = taxesCalc.multiply(tax.getPercent());
        taxesCalc = taxesCalc.divide(new BigDecimal("100"));
        cartFeesTotal = cartFeesTotal.add(taxesCalc);
      }
    }
    return cartFeesTotal;
  }
示例#2
0
  /**
   * Invoice Line - Tax. - basis: Product, Charge, BPartner Location - sets C_Tax_ID Calls Amount
   *
   * @param ctx context
   * @param WindowNo window no
   * @param mTab tab
   * @param mField field
   * @param value value
   * @return null or error message
   */
  public String tax(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value) {
    String column = mField.getColumnName();
    if (value == null) return "";

    //	Check Product
    int M_Product_ID = 0;
    if (column.equals("M_Product_ID")) M_Product_ID = ((Integer) value).intValue();
    else M_Product_ID = Env.getContextAsInt(ctx, WindowNo, "M_Product_ID");
    int C_Charge_ID = 0;
    if (column.equals("C_Charge_ID")) C_Charge_ID = ((Integer) value).intValue();
    else C_Charge_ID = Env.getContextAsInt(ctx, WindowNo, "C_Charge_ID");
    log.fine("Product=" + M_Product_ID + ", C_Charge_ID=" + C_Charge_ID);
    if (M_Product_ID == 0 && C_Charge_ID == 0) return amt(ctx, WindowNo, mTab, mField, value); //

    //	Check Partner Location
    int shipC_BPartner_Location_ID = Env.getContextAsInt(ctx, WindowNo, "C_BPartner_Location_ID");
    if (shipC_BPartner_Location_ID == 0) return amt(ctx, WindowNo, mTab, mField, value); //
    log.fine("Ship BP_Location=" + shipC_BPartner_Location_ID);
    int billC_BPartner_Location_ID = shipC_BPartner_Location_ID;
    log.fine("Bill BP_Location=" + billC_BPartner_Location_ID);

    //	Dates
    Timestamp billDate = Env.getContextAsDate(ctx, WindowNo, "DateInvoiced");
    log.fine("Bill Date=" + billDate);
    Timestamp shipDate = billDate;
    log.fine("Ship Date=" + shipDate);

    int AD_Org_ID = Env.getContextAsInt(ctx, WindowNo, "AD_Org_ID");
    log.fine("Org=" + AD_Org_ID);

    int M_Warehouse_ID = Env.getContextAsInt(ctx, "#M_Warehouse_ID");
    log.fine("Warehouse=" + M_Warehouse_ID);

    //
    int C_Tax_ID =
        Tax.get(
            ctx,
            M_Product_ID,
            C_Charge_ID,
            billDate,
            shipDate,
            AD_Org_ID,
            M_Warehouse_ID,
            billC_BPartner_Location_ID,
            shipC_BPartner_Location_ID,
            Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"));
    log.info("Tax ID=" + C_Tax_ID);
    //
    if (C_Tax_ID == 0) mTab.fireDataStatusEEvent(CLogger.retrieveError());
    else mTab.setValue("C_Tax_ID", new Integer(C_Tax_ID));
    //
    return amt(ctx, WindowNo, mTab, mField, value);
  } //	tax
示例#3
0
 public static void main(String[] args) {
   double grossIncome; // 	local	variables
   String state;
   int dependents;
   grossIncome = 50000;
   dependents = 2;
   state = "NJ";
   Tax t = new Tax(grossIncome, state, dependents);
   Tax t2 = new Tax(65000, "TX", 4);
   double yourTax = t.calcTax(); // calculating	tax
   double hisTax = t2.calcTax();
   Tax.convertToEuros(yourTax);
   Tax.convertToEuros(hisTax);
   //	Printing	the	result
   System.out.println("Your tax is	" + yourTax);
 }