Coverage Report - org.paneris.jammyjoes.model.ShopOrderItem
 
Classes in this File Line Coverage Branch Coverage Complexity
ShopOrderItem
0%
0/28
0%
0/8
1.8
 
 1  
 package org.paneris.jammyjoes.model;
 2  
 
 3  
 import java.sql.Date;
 4  
 import java.util.Map;
 5  
 
 6  
 import org.paneris.jammyjoes.model.generated.ShopOrderItemBase;
 7  
 
 8  
 public class ShopOrderItem extends ShopOrderItemBase {
 9  0
   public ShopOrderItem() {
 10  0
   }
 11  
 
 12  
   // order items are associated with s stocktransaction
 13  
   public final void delete(Map map) {
 14  0
     deleteTransaction();
 15  0
     super.delete(map);
 16  0
   }
 17  
 
 18  
   public void deleteTransaction() {
 19  0
     StockTransaction st = getStocktransaction();
 20  0
     setStocktransaction(null);
 21  0
     if (st != null)
 22  0
       st.delete();
 23  0
   }
 24  
 
 25  
   public void setTransaction() {
 26  0
     JammyjoesDatabaseTables tables = getJammyjoesDatabaseTables();
 27  0
     StockTransactionType type = tables.getStockTransactionTypeTable().getInternetSale();
 28  0
     if (getOrder().getType().equals(tables.getOrderTypeTable().getTelephoneOrder())) {
 29  0
       type = tables.getStockTransactionTypeTable().getTelephoneSale();
 30  
     }
 31  0
     if (getOrder().getStatus().equals(tables.getOrderStatusTable().getIncomplete())) {
 32  0
       deleteTransaction();
 33  
     } else {
 34  0
       StockTransactionTable stt = tables.getStockTransactionTable();
 35  0
       StockTransaction st = getStocktransaction();
 36  0
       if (st == null) {
 37  0
         st =
 38  
           getProduct().newStockTransaction(
 39  
             new Date(getOrder().getDate().getTime()),
 40  
             type,
 41  
             getQuantity());
 42  0
         stt.create(st);
 43  0
         setStocktransaction(st);
 44  
       } else {
 45  0
         st.setDate(new Date(getOrder().getDate().getTime()));
 46  0
         st.setType(type);
 47  0
         st.setQuantity(getQuantity());
 48  
       }
 49  
     }
 50  0
   }
 51  
 
 52  
   public void postWrite() {
 53  0
     setTransaction();
 54  0
   }
 55  
 }