Exemplo n.º 1
0
  private String buildInvoice() {
    double taxRate = 6;
    String message;

    this.grandTotal = ((taxRate / 100) * this.subtotal) + this.subtotal;

    DateFormat dateFormat = new SimpleDateFormat("dd/MM/YY HH:mm:ss z");
    this.transDate = new Date();

    message = "Date: " + dateFormat.format(this.transDate) + "\n\n";
    message += "Number of line items: " + this.totalItems + "\n\n";
    message += "Item# / ID / Title / Price / Qty / Disc % / Subtotal:\n\n";
    int counter = 0;
    for (Item i : order.getOrder()) {
      counter++;
      message += counter + ". " + i.toString() + "\n";
    }
    message += "\n";
    message += "Order subtotal: " + formatter.format(this.subtotal) + "\n\n";
    message += "Tax rate: " + taxRate + "%\n\n";
    message += "Tax amount: " + formatter.format(((taxRate / 100) * this.subtotal)) + "\n\n";
    message += "Order total: " + formatter.format(this.grandTotal) + "\n\n";
    message += "Thanks for shopping at Funky Town Books\n\n";

    return message;
  }
Exemplo n.º 2
0
  public void viewOrder() {
    String currentOrder = "";
    int counter = 0;
    for (Item i : order.getOrder()) {
      counter++;
      currentOrder += counter + ". " + i.toString() + "\n";
    }
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setTitle("Current Order");
    alert.setHeaderText("Your current order is as follows:");
    alert.setContentText(currentOrder);
    alert.getDialogPane().setStyle(" -fx-max-width:500px; -fx-pref-width: 500px;");

    alert.showAndWait();
  }
Exemplo n.º 3
0
 public void processItem() {
   createItem();
   if (item != null) {
     text_info.setText(item.toString());
     btn_confirm.setDisable(false);
   }
 }
Exemplo n.º 4
0
  public void confirmItem() {
    this.subtotal += item.getTotal();
    String subtotalStr = formatter.format(this.subtotal);
    text_bookID.setText("");
    text_quantity.setText("");
    text_subtotal.setText(subtotalStr);

    confirmAlert();

    order.addItem(item);
    this.totalQuantity += item.getQuantity();
    changeItemNumber();
    btn_confirm.setDisable(true);
    btn_view.setDisable(false);
    text_totalItems.setDisable(true);
    item = null;
  }
Exemplo n.º 5
0
  private String buildTransaction() {
    String transaction = "";
    DateFormat dateFormat;

    for (Item i : order.getOrder()) {
      dateFormat = new SimpleDateFormat("YYMMddHHmmss");
      transaction += dateFormat.format(this.transDate) + ", ";
      transaction +=
          i.getBook().getId() + ", " + i.getBook().getTitle() + ", " + i.getBook().getPriceStr();
      transaction +=
          ", " + i.getQuantity() + ", " + i.getPercentStr() + ", " + i.getTotalStr() + ", ";
      dateFormat = new SimpleDateFormat("dd/MM/YY HH:mm:ss z");
      transaction += dateFormat.format(this.transDate) + newLine;
    }
    return transaction;
  }