/** * Get a station to put in the database * * @param id for the station * @param warehouse for the station * @return station */ public Station getStation(int id, Warehouse warehouse) { Station station = new Station(); station.setStationID(id); station.setWarehouseID(warehouse.getWarehouseID()); station.setName("Station #" + id); station.setAddress(randAddress()); station.setCity(cities.get(randInt(0, cities.size()))); station.setState(states.get(randInt(0, states.size()))); station.setZip(zips.get(randInt(0, zips.size()))); station.setSalesTax(new BigDecimal(randDouble(minSalesTax, maxSalesTax))); station.setTotalSales(new BigDecimal(0)); return station; }
/** * 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; }