コード例 #1
0
  private void consolidateInvoices() {

    for (Invoice i : invoices) {
      for (LineItem l : i.getInvoice()) {
        String code = l.getProduct().getCode();
        int quant = l.getQuantity();
        double total = l.getTotal();
        double price = l.getProduct().getPrice();
        double[] sale = new double[3];
        if (salesOrder.containsKey(code)) {
          sale = salesOrder.get(code);
          sale[0] += quant;
          sale[1] += total;
        } else {
          sale[0] = quant;
          sale[1] = total;
        }
        sale[2] = 0;
        salesOrder.put(code, sale);
      }
    }

    Iterator<Map.Entry<String, double[]>> entries = salesOrder.entrySet().iterator();

    while (entries.hasNext()) {
      Map.Entry<String, double[]> entry = entries.next();
      String code = entry.getKey();
      double[] sale = entry.getValue();
      sale[2] = sale[1] / sale[0];
      salesOrder.put(code, sale);
    }
  }
コード例 #2
0
ファイル: Invoice.java プロジェクト: EvgheniAnachii/jsp
 public double getInvoiceTotal() {
   double invoiceTotal = 0.0;
   for (int i = 0; i < lineItems.size(); i++) {
     LineItem item = lineItems.get(i);
     invoiceTotal += item.getTotal();
   }
   return invoiceTotal;
 }
コード例 #3
0
  public double getInvoiceTotal() {
    double total = 0;

    for (LineItem item : items) {
      total += item.getTotal();
    }

    return total;
  }