コード例 #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
 public final double getGrandestTotal() {
   grandTotal = 0.00;
   for (LineItem item : lineItems) {
     grandTotal += item.getGrandSubtotal();
   }
   return grandTotal;
 }
コード例 #3
0
 @Override
 public void removeLineItem(LineItem item) {
   String productCode = item.productCode().get();
   int quantity = item.quantity().get();
   inventory.add(productCode, quantity);
   next.removeLineItem(item);
 }
コード例 #4
0
 public final double getSavings() {
   double discount = 0.00;
   for (LineItem item : lineItems) {
     discount += item.getLineItemDiscount();
   }
   return discount;
 }
コード例 #5
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;
 }
コード例 #6
0
ファイル: Cart.java プロジェクト: MichalGoly/MusicStore
  /** @return The total price for the items in the cart */
  public double getTotalPrice() {
    double total = 0.0;
    for (LineItem i : items) {
      total += i.getTotalPrice();
    }

    return total;
  }
コード例 #7
0
 public double getTotal() {
   double total = 0.0;
   for (int i = 0; i < items.size(); i++) {
     LineItem lineItem = items.get(i);
     total += lineItem.getPrice();
   }
   return total;
 }
コード例 #8
0
  public double getInvoiceTotal() {
    double total = 0;

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

    return total;
  }
コード例 #9
0
 public void removeItem(LineItem item) {
   String code = item.getProduct().getCode();
   for (int i = 0; i < items.size(); i++) {
     LineItem lineItem = items.get(i);
     if (lineItem.getProduct().getCode().equals(code)) {
       items.remove(i);
       return;
     }
   }
 }
コード例 #10
0
ファイル: Order.java プロジェクト: fareeid/eclipse_projects
 public void addPurchase(String product, int quantity, double price) {
   if (lineItems == null) lineItems = new ArrayList<LineItem>();
   LineItem item = new LineItem();
   item.setOrder(this);
   item.setProduct(product);
   item.setQuantity(quantity);
   item.setSubtotal(quantity * price);
   lineItems.add(item);
   total += quantity * price;
 }
コード例 #11
0
  public void addItem(LineItem item) {

    // Only add the item if it's not yet in the cart
    String code = item.getProduct().getCode();
    for (int i = 0; i < items.size(); i++) {
      LineItem lineItem = items.get(i);
      if (lineItem.getProduct().getCode().equals(code)) {
        return;
      }
    }
    items.add(item);
  }
コード例 #12
0
 private static void processDelete(String type, String id) {
   if ("LineItem".equals(type)) {
     LineItem lineitem = LineItem.findById(new Long(id));
     lineitem.purchaseOrder.lineItems.remove(lineitem);
     lineitem.delete();
     setCurrentUseCaseName("Line Item deleted");
   } else if ("Order".equals(type)) {
     PurchaseOrder order = PurchaseOrder.findById(new Long(id));
     order.customer.purchaseOrders.remove(order);
     order.delete();
     setCurrentUseCaseName("Order deleted");
   }
 }
コード例 #13
0
ファイル: Cart.java プロジェクト: MichalGoly/MusicStore
  /**
   * Adds a line item into the cart if it's not already there. Otherwise, the quantity will be
   * increased.
   *
   * @param lineItem The line item to be added to the cart
   */
  public void addItem(LineItem lineItem) {
    String code = lineItem.getProduct().getCode();
    int quantity = lineItem.getQuantity();

    for (LineItem i : items) {
      if (i.getProduct().getCode().equals(code)) {
        // already exists
        i.setQuantity(quantity);
        return;
      }
    }

    items.add(lineItem);
  }
コード例 #14
0
ファイル: ShoppingCart.java プロジェクト: tom1410/test01
  /**
   *
   * <!-- begin-user-doc -->
   * <!--  end-user-doc  -->
   *
   * @generated
   * @ordered
   */
  public void addItems(LineItem newItems) {
    if (this.items == null) {
      this.items = new HashSet<LineItem>();
    }

    if (this.items.add(newItems)) newItems.basicSetSc(this);
  }
コード例 #15
0
 public synchronized boolean equals(java.lang.Object obj) {
   if (!(obj instanceof LineItem)) return false;
   LineItem other = (LineItem) obj;
   if (obj == null) return false;
   if (this == obj) return true;
   if (__equalsCalc != null) {
     return (__equalsCalc == obj);
   }
   __equalsCalc = obj;
   boolean _equals;
   _equals =
       super.equals(obj)
           && ((this.targeting == null && other.getTargeting() == null)
               || (this.targeting != null && this.targeting.equals(other.getTargeting())));
   __equalsCalc = null;
   return _equals;
 }
コード例 #16
0
ファイル: zzj.java プロジェクト: showmaxAlt/showmaxAndroid
 static void zza(LineItem lineitem, Parcel parcel, int i) {
   i = zzb.zzK(parcel);
   zzb.zzc(parcel, 1, lineitem.getVersionCode());
   zzb.zza(parcel, 2, lineitem.description, false);
   zzb.zza(parcel, 3, lineitem.zzaDt, false);
   zzb.zza(parcel, 4, lineitem.zzaDu, false);
   zzb.zza(parcel, 5, lineitem.zzaCR, false);
   zzb.zzc(parcel, 6, lineitem.zzaDv);
   zzb.zza(parcel, 7, lineitem.zzaCS, false);
   zzb.zzH(parcel, i);
 }
 static void m1780a(LineItem lineItem, Parcel parcel, int i) {
   int C = C0200b.m232C(parcel);
   C0200b.m259c(parcel, 1, lineItem.getVersionCode());
   C0200b.m247a(parcel, 2, lineItem.description, false);
   C0200b.m247a(parcel, 3, lineItem.aje, false);
   C0200b.m247a(parcel, 4, lineItem.ajf, false);
   C0200b.m247a(parcel, 5, lineItem.aiK, false);
   C0200b.m259c(parcel, 6, lineItem.ajg);
   C0200b.m247a(parcel, 7, lineItem.aiL, false);
   C0200b.m235G(parcel, C);
 }
コード例 #18
0
 private static void processInsert(
     String custId, String type, String id, String att, String value) {
   if (type == null || type.trim().length() == 0) return;
   if ("LineItem".equals(type)) {
     PurchaseOrder order = PurchaseOrder.findById(new Long(id));
     Product product = Product.findById(new Long(1));
     LineItem newItem = new LineItem();
     newItem.purchaseOrder = order;
     order.lineItems.add(newItem);
     newItem.product = product;
     product.lineItems.add(newItem);
     newItem.qtyOrdered = 1;
     setCurrentUseCaseName("New Line Item created");
     newItem.save();
   } else if ("Order".equals(type)) {
     Customer customer = Customer.findById(new Long(custId));
     PurchaseOrder newOrder = new PurchaseOrder();
     newOrder.customer = customer;
     newOrder.paid = Boolean.FALSE;
     newOrder.notes = "";
     setCurrentUseCaseName("New Order created");
     newOrder.save();
   }
 }
コード例 #19
0
 private static void processUpdate(String type, String id, String att, String value) {
   if (type == null || type.trim().length() == 0) return;
   if ("Order".equals(type)) {
     PurchaseOrder order = PurchaseOrder.findById(new Long(id));
     if ("paid".equals(att)) {
       Boolean oldValue = order.paid;
       if (oldValue == null) oldValue = Boolean.FALSE;
       order.paid = !oldValue;
       if (oldValue) setCurrentUseCaseName("Order unpaid");
       else setCurrentUseCaseName("Order paid");
     } else if ("customer".equals(att)) {
       if (value == null
           || value.startsWith(
               "- ")) // Do nothing if somehow the "- select a customer -" item was selected
       return;
       Customer customer = Customer.findById(new Long(value));
       order.customer = customer;
       Flash.current().success("The order has been reassigned to customer " + customer.name);
       setCurrentUseCaseName("Order reassigned");
     } else if ("notes".equals(att)) {
       order.notes = value;
       setCurrentUseCaseName("Order notes updated");
     }
     order.save();
   } else if ("Customer".equals(type)) {
     Customer customer = Customer.findById(new Long(id));
     if ("creditLimit".equals(att)) {
       BigDecimal val = NumberFormat.parseMoney(value);
       customer.creditLimit = val;
       setCurrentUseCaseName("Customer credit limit updated");
     }
     customer.save();
   } else if ("LineItem".equals(type)) {
     LineItem lineitem = LineItem.findById(new Long(id));
     if ("quantity".equals(att)) {
       Integer val = NumberFormat.parseNumber(value);
       lineitem.qtyOrdered = val;
       setCurrentUseCaseName("Line Item quantity updated");
     } else if ("unitPrice".equals(att)) {
       BigDecimal val = NumberFormat.parseMoney(value);
       lineitem.productPrice = val;
       setCurrentUseCaseName("Line Item unit price updated");
     } else if ("product".equals(att)) {
       Product product = Product.findById(new Long(value));
       lineitem.product = product;
       setCurrentUseCaseName("Line Item product changed");
     }
     lineitem.save();
   }
 }
コード例 #20
0
ファイル: LineItemColumn.java プロジェクト: sopel39/tpch
 public double getDouble(LineItem lineItem) {
   return lineItem.getTax();
 }
コード例 #21
0
ファイル: DataGenerator.java プロジェクト: mdfaller/db
  /**
   * Get a line item to put in the database
   *
   * @param id for the line item
   * @param warehouse for the station
   * @param Station station
   * @param Customer customer
   * @param Order order
   * @param ArrayList<Item> itemList
   * @return lineItem
   */
  public LineItem getLineItem(
      int id,
      Warehouse warehouse,
      Station station,
      Customer customer,
      Order order,
      ArrayList<Item> itemList) {
    LineItem lineItem = new LineItem();

    Item item = itemList.get(randInt(0, itemList.size()));

    int numOrdered = randInt(1, 5);

    if (item.getCurrentStock() < numOrdered) return null;

    lineItem.setLineItemID(id);
    lineItem.setOrderID(order.getOrderID());
    lineItem.setItemID(item.getItemID());
    lineItem.setCustomerID(customer.getCustomerID());
    lineItem.setWarehouseID(warehouse.getWarehouseID());
    lineItem.setStationID(station.getStationID());
    lineItem.setNumOrdered(numOrdered);
    lineItem.setAmountDue(item.getPrice().multiply(new BigDecimal(lineItem.getNumOrdered())));
    lineItem.setAmountDue(
        lineItem.getAmountDue().add(station.getSalesTax().multiply(lineItem.getAmountDue())));
    lineItem.setAmountDue(
        lineItem.getAmountDue().subtract(customer.getDiscount().multiply(lineItem.getAmountDue())));
    lineItem.setDateDelivered(randDate());

    item.setNumLineItems(item.getNumLineItems() + 1);
    item.setNumSold(item.getNumSold() + lineItem.getNumOrdered());
    // item.setCurrentStock(item.getCurrentStock() - lineItem.getNumOrdered()); don't modify stock
    // counts for random generation

    customer.setTotalPaid(customer.getTotalPaid().add(lineItem.getAmountDue()));
    station.setTotalSales(station.getTotalSales().add(lineItem.getAmountDue()));
    warehouse.setTotalSales(warehouse.getTotalSales().add(lineItem.getAmountDue()));

    return lineItem;
  }
コード例 #22
0
ファイル: LineItemColumn.java プロジェクト: sopel39/tpch
 public long getLong(LineItem lineItem) {
   return lineItem.getQuantity();
 }
コード例 #23
0
ファイル: ShoppingCart.java プロジェクト: tom1410/test01
  /**
   *
   * <!-- begin-user-doc -->
   * <!--  end-user-doc  -->
   *
   * @generated
   * @ordered
   */
  public void removeItems(LineItem oldItems) {
    if (this.items == null) return;

    if (this.items.remove(oldItems)) oldItems.unsetSc();
  }
コード例 #24
0
ファイル: LineItemColumn.java プロジェクト: sopel39/tpch
 public double getDouble(LineItem lineItem) {
   return lineItem.getExtendedPrice();
 }
コード例 #25
0
ファイル: ShoppingCart.java プロジェクト: tom1410/test01
 /**
  *
  * <!-- begin-user-doc -->
  * <!--  end-user-doc  -->
  *
  * @generated
  * @ordered
  */
 public void addAllItems(Set<LineItem> newItems) {
   if (this.items == null) {
     this.items = new HashSet<LineItem>();
   }
   for (LineItem tmp : newItems) tmp.setSc(this);
 }
コード例 #26
0
ファイル: LineItemColumn.java プロジェクト: sopel39/tpch
 public double getDouble(LineItem lineItem) {
   return lineItem.getDiscount();
 }
コード例 #27
0
ファイル: LineItemColumn.java プロジェクト: sopel39/tpch
 public int getDate(LineItem lineItem) {
   return lineItem.getShipDate();
 }
コード例 #28
0
ファイル: LineItemColumn.java プロジェクト: sopel39/tpch
 public String getString(LineItem lineItem) {
   return lineItem.getStatus();
 }
コード例 #29
0
ファイル: App.java プロジェクト: indykish/xero
  public static void main(String[] args) {

    // Prepare the Xero Client
    XeroClient xeroClient = null;
    try {
      XeroClientProperties clientProperties = new XeroClientProperties();
      clientProperties.load(new FileInputStream("./xeroApi.properties"));
      xeroClient = new XeroClient(clientProperties);
    } catch (IOException ex) {
      ex.printStackTrace();
    }

    // Retrieve a list of Invoices
    try {

      ArrayOfInvoice arrayOfExistingInvoices = xeroClient.getInvoices();
      if (arrayOfExistingInvoices != null && arrayOfExistingInvoices.getInvoice() != null) {

        for (Invoice invoice : arrayOfExistingInvoices.getInvoice()) {
          System.out.println("Invoice: " + invoice.getInvoiceID());
        }

        // Retrieve an invoice as a PDF
        // (can be used to retrieve json too, just change application/pdf to application/json)
        if (!arrayOfExistingInvoices.getInvoice().isEmpty()) {
          xeroClient.getInvoiceAsPdf(arrayOfExistingInvoices.getInvoice().get(0).getInvoiceID());
        }
      }

    } catch (XeroClientException ex) {
      ex.printDetails();
    } catch (XeroClientUnexpectedException ex) {
      ex.printStackTrace();
    }

    // Create an Invoice
    Invoice invoice = null;
    try {

      ArrayOfInvoice arrayOfInvoice = new ArrayOfInvoice();
      List<Invoice> invoices = arrayOfInvoice.getInvoice();
      invoice = new Invoice();

      Contact contact = new Contact();
      contact.setName("Jane Smith");
      contact.setEmailAddress("*****@*****.**");
      invoice.setContact(contact);

      ArrayOfLineItem arrayOfLineItem = new ArrayOfLineItem();
      List<LineItem> lineItems = arrayOfLineItem.getLineItem();
      LineItem lineItem = new LineItem();
      lineItem.setAccountCode("200");
      BigDecimal qty = new BigDecimal("2");
      lineItem.setQuantity(qty);
      BigDecimal amnt = new BigDecimal("50.00");
      lineItem.setUnitAmount(amnt);
      lineItem.setDescription("Programming books");
      lineItem.setLineAmount(qty.multiply(amnt));
      lineItems.add(lineItem);
      invoice.setLineItems(arrayOfLineItem);

      invoice.setDate(Calendar.getInstance());
      Calendar due = Calendar.getInstance();
      due.set(due.get(Calendar.YEAR), due.get(Calendar.MONTH) + 1, 20);
      invoice.getLineAmountTypes().add("Inclusive");
      invoice.setDueDate(due);
      invoice.setInvoiceNumber("INV-API-001");
      invoice.setType(InvoiceType.ACCREC);
      invoice.setStatus(InvoiceStatus.AUTHORISED);
      invoices.add(invoice);

      xeroClient.postInvoices(arrayOfInvoice);
    } catch (XeroClientException ex) {
      ex.printDetails();
    } catch (XeroClientUnexpectedException ex) {
      ex.printStackTrace();
    }

    // Create a new Contact
    try {

      ArrayOfContact arrayOfContact = new ArrayOfContact();
      List<Contact> contacts = arrayOfContact.getContact();

      Contact contact1 = new Contact();
      contact1.setName("John Smith");
      contact1.setEmailAddress("*****@*****.**");
      contacts.add(contact1);
      xeroClient.postContacts(arrayOfContact);

    } catch (XeroClientException ex) {
      ex.printDetails();
    } catch (XeroClientUnexpectedException ex) {
      ex.printStackTrace();
    }

    // Add a payment to an exisiting Invoice
    try {

      Invoice invoice1 = new Invoice();
      invoice1.setInvoiceNumber("INV-0038");

      Account account = new Account();
      account.setCode("090");

      Payment payment = new Payment();
      payment.setAccount(account);
      payment.setInvoice(invoice);
      payment.setAmount(new BigDecimal("20.00"));
      payment.setDate(Calendar.getInstance());

      ArrayOfPayment arrayOfPayment = new ArrayOfPayment();
      List<Payment> payments = arrayOfPayment.getPayment();
      payments.add(payment);

      xeroClient.postPayments(arrayOfPayment);

    } catch (XeroClientException ex) {
      ex.printDetails();
    } catch (XeroClientUnexpectedException ex) {
      ex.printStackTrace();
    }
  }
コード例 #30
0
ファイル: LineItemColumn.java プロジェクト: sopel39/tpch
 public String getString(LineItem lineItem) {
   return lineItem.getReturnFlag();
 }