Esempio n. 1
0
 private void customerNameChooserActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_customerNameChooserActionPerformed
   String name = (String) customerNameChooser.getSelectedItem();
   Customer c = null;
   customersWos = new ArrayList<>();
   for (Customer cu : customerList) {
     if (cu.getCustomerID().equals(customerMap.get(name))) {
       c = cu;
       currentCustomer = c;
     }
   }
   for (Vehicle v : vehicleList) {
     if (v.getCustomerID().equals(c)) {
       makeField1.setText(v.getMake());
       modelField1.setText(v.getModel());
       yearComboBox1.addItem(v.getYear());
       vinField1.setText(v.getVin());
       licenseField1.setText(v.getLicencePlate());
     }
   }
   woComboBox1.removeAllItems();
   woComboBox2.removeAllItems();
   CustomerIDField.setText(c.getCustomerID().toString());
   for (WorkOrder wo : workOrderList) {
     if (wo.getVehicleID().getCustomerID().equals(c)) {
       woComboBox1.addItem(wo.getOrderNo());
       woComboBox2.addItem(wo.getOrderNo());
       customersWos.add(wo);
     }
   }
 } // GEN-LAST:event_customerNameChooserActionPerformed
Esempio n. 2
0
  /** Tests the functionality of the set methods for the customer class */
  @Test
  public void CustomerSetMethods() {

    testCustomer.setCustomerID(10);
    assertEquals(10, testCustomer.getCustomerID());

    testCustomer.setCustomerPhone("07788254414");
    assertEquals("07788254414", testCustomer.getCustomerPhone());

    testCustomer.setAvailableCredit(5000);
    assertEquals(5000f, testCustomer.getAvailableCredit(), 0.001f);

    testCustomer.setCustomerName("Jerry Springer");
    assertEquals("Jerry Springer", testCustomer.getCustomerName());

    testCustomer.setCustomerEmail("*****@*****.**");
    assertEquals("*****@*****.**", testCustomer.getCustomerEmail());

    testCustomer.setCustomerUsername("spring");
    assertEquals("spring", testCustomer.getCustomerUsername());

    testCustomer.setCustomerPassword("springer123");
    assertEquals("springer123", testCustomer.getCustomerPassword());

    testCustomer.setCustomerContactMethod("PHONE");
    assertEquals("PHONE", testCustomer.getCustomerContactMethod());
  }
Esempio n. 3
0
 private void fillCustCombo() {
   EntityManager em = MainWindow.em;
   TypedQuery<Customer> q = em.createNamedQuery("Customer.findAll", Customer.class);
   for (Customer c : q.getResultList()) {
     String fName = c.getFName();
     String lName = c.getLName();
     String phone = c.getPhone();
     customerNameChooser.addItem(c.getCustomerID() + " " + fName + " " + lName + ", " + phone);
   }
 }
Esempio n. 4
0
 /** Tests the functionality of the get methods for the customer class */
 @Test
 public void CustomerGetMethods() {
   assertEquals(1, testCustomer.getCustomerID());
   assertEquals("01782566491", testCustomer.getCustomerPhone());
   assertEquals(10000f, testCustomer.getAvailableCredit(), 0.001f);
   assertEquals("George Freshwater", testCustomer.getCustomerName());
   assertEquals("*****@*****.**", testCustomer.getCustomerEmail());
   assertEquals("fresh", testCustomer.getCustomerUsername());
   assertEquals("water123", testCustomer.getCustomerPassword());
   assertEquals("EMAIL", testCustomer.getCustomerContactMethod());
 }
Esempio n. 5
0
  /**
   * Get an order to put in the database
   *
   * @param id for the order
   * @param warehouse for the order
   * @param station for the order
   * @param customer for the the order
   * @return order
   */
  public Order getOrder(int id, Warehouse warehouse, Station station, Customer customer) {
    Order order = new Order();

    order.setOrderID(id);
    order.setCustomerID(customer.getCustomerID());
    order.setWarehouseID(warehouse.getWarehouseID());
    order.setStationID(station.getStationID());
    order.setDateOrdered(randDate());
    order.setCompleted(1); // set as completed by default
    order.setNumLineItems(randInt(3, 10)); // number of line items per order

    customer.setDeliveriesReceived(customer.getDeliveriesReceived() + 1);
    customer.setNumPayments(customer.getNumPayments() + 1);

    return order;
  }
Esempio n. 6
0
  /**
   * 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;
  }