1 package sellwin.domain; 2 3 import java.util.*; 4 import java.io.*; 5 import java.text.*; 6 import javax.swing.text.*; 7 8 12 13 18 public class Order implements Serializable { 19 20 public static final String [] METHODS = { 21 "VISA Card", "Send Bill", "American Express" }; 22 23 public static final String STATUS_OPEN = "Open"; 24 public static final String STATUS_CLOSED = "Closed"; 25 public static final String STATUS_SUBMITTED = "Submitted"; 26 public static final String STATUS_CANCELLED = "Cancelled"; 27 28 public static final String [] STATUS = { 29 STATUS_OPEN, STATUS_CLOSED, STATUS_SUBMITTED, STATUS_CANCELLED }; 30 31 private long pk; 32 private long oppPK; 33 private Long orderNumber; 34 private Quote quote; 35 private long quotePK; 36 private long shipAddressPK; 37 private Address shipAddress; 38 private long billAddressPK; 39 private Address billAddress; 40 private String status; 41 private String paymentForm; 42 private double subTotal=0.00; 43 private double tax=0.00; 44 private double shipping=0.00; 45 private double total=0.00; 46 private String modifiedBy; 47 private Date modifiedDate; 48 private boolean updatedLocally=false; 49 private boolean addedLocally=false; 50 51 public Order() { 52 status = STATUS_OPEN; 53 modifiedDate = new Date(); 54 paymentForm = METHODS[0]; 55 } 56 57 public final void setPK(long pk) { this.pk = pk; } 58 public final void setOppKey(long pk) { oppPK = pk; } 59 public final void setOrderNumber(Long o) { orderNumber = o; } 60 public final void setModifiedBy(String n) { modifiedBy = n;} 61 public final void setModifiedDate(Date n) { modifiedDate = n;} 62 public final void setStatus(String n) { status = n;} 63 public final void setPaymentForm(String s) { paymentForm = s; } 64 public final void setSubTotal(double d) { subTotal = d; } 65 public final void setTax(double d) { tax = d; } 66 public final void setShipping(double d) { shipping = d; } 67 public final void setTotal(double d) { total = d; } 68 public final void setQuote(Quote q) { 69 quote = q; } 70 public final void setQuoteKey(long q) { quotePK = q; } 71 public final void setShipAddress(Address a) { shipAddress = a; } 72 public final void setBillAddress(Address a) { billAddress = a; } 73 public final void setBillAddressKey(long q) { billAddressPK = q; } 74 public final void setShipAddressKey(long q) { shipAddressPK = q; } 75 public final void setUpdatedLocally(boolean b) { updatedLocally=b; } 76 public final void setAddedLocally(boolean b) { addedLocally=b; } 77 78 79 public final long getPK() { return pk; } 80 public final long getOppKey() { return oppPK; } 81 public final Long getOrderNumber() { return orderNumber; } 82 public final String getStatus() { return status; } 83 public final String getModifiedBy() { return modifiedBy; } 84 public final Date getModifiedDate() { return modifiedDate; } 85 public final String getPaymentForm() { return paymentForm; } 86 public final double getSubTotal() { return subTotal; } 87 public final double getTax() { return tax; } 88 public final double getShipping() { return shipping; } 89 public final double getTotal() { return total; } 90 public final Quote getQuote() { return quote; } 91 public final long getQuoteKey() { return quotePK; } 92 public final Address getShipAddress() { return shipAddress; } 93 public final Address getBillAddress() { return billAddress; } 94 public final long getShipAddressKey() { return billAddressPK; } 95 public final long getBillAddressKey() { return billAddressPK; } 96 public final boolean getUpdatedLocally() { return updatedLocally; } 97 public final boolean getAddedLocally() { return addedLocally; } 98 99 public final Order copy() { 100 Order copy = new Order(); 101 copy.setPK(getPK()); 102 copy.setOrderNumber(new Long (getOrderNumber().longValue())); 103 copy.setShipAddress(shipAddress.copy()); 104 copy.setBillAddress(billAddress.copy()); 105 copy.status = new String (status); 106 if (modifiedBy != null) 107 copy.modifiedBy = new String (modifiedBy); 108 if (modifiedDate != null) 109 copy.modifiedDate = new Date(modifiedDate.getTime()); 110 111 copy.setSubTotal(subTotal); 112 copy.setTax(tax); 113 copy.setShipping(shipping); 114 copy.setTotal(total); 115 116 if (quote != null) 117 copy.quote = quote.copy(); 118 119 if (paymentForm != null) 120 copy.paymentForm = new String (paymentForm); 121 122 return copy; 123 } 124 125 public final void print() { 126 System.out.println("<<Order>>"); 127 System.out.println("pk=["+getPK()+"]"); 128 System.out.println("orderNumber=["+getOrderNumber()+"]"); 129 System.out.println("status=["+getStatus()+"]"); 130 System.out.println("subTotal=["+getSubTotal()+"]"); 131 System.out.println("tax=["+getTax()+"]"); 132 System.out.println("Shipping=["+getShipping()+"]"); 133 System.out.println("Total=["+getTotal()+"]"); 134 System.out.println("ship addr pk="+getShipAddress().getPK()); 135 System.out.println("bill addr pk="+getBillAddress().getPK()); 136 System.out.println("Modified By=["+getModifiedBy()+"]"); 137 System.out.println("Modified On=["+getModifiedDate()+"]"); 138 } 139 } 140 | Popular Tags |