shopizer-uncached

Details

diff --git a/shopizer-canadapost/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-canadapost-module/pom.properties b/shopizer-canadapost/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-canadapost-module/pom.properties
index 20899d0..3360b57 100644
--- a/shopizer-canadapost/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-canadapost-module/pom.properties
+++ b/shopizer-canadapost/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-canadapost-module/pom.properties
@@ -1,5 +1,5 @@
 #Generated by Maven Integration for Eclipse
-#Fri Jan 13 16:58:25 EST 2017
+#Tue Jan 17 10:34:20 EST 2017
 version=2.0.5-SNAPSHOT
 groupId=com.shopizer
 m2e.projectName=shopizer-canadapost
diff --git a/shopizer-shipping-distance-module/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-distance-processor/pom.properties b/shopizer-shipping-distance-module/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-distance-processor/pom.properties
index 1c6f08a..f3e1ab4 100644
--- a/shopizer-shipping-distance-module/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-distance-processor/pom.properties
+++ b/shopizer-shipping-distance-module/target/classes/META-INF/maven/com.shopizer/shopizer-shipping-distance-processor/pom.properties
@@ -1,5 +1,5 @@
 #Generated by Maven Integration for Eclipse
-#Mon Jan 16 09:00:50 EST 2017
+#Tue Jan 17 10:34:21 EST 2017
 version=2.0.5-SNAPSHOT
 groupId=com.shopizer
 m2e.projectName=shopizer-shipping-distance-processor
diff --git a/sm-core/src/main/java/com/salesmanager/core/business/repositories/order/OrderRepositoryImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/repositories/order/OrderRepositoryImpl.java
index d99ba66..b2b3f2e 100644
--- a/sm-core/src/main/java/com/salesmanager/core/business/repositories/order/OrderRepositoryImpl.java
+++ b/sm-core/src/main/java/com/salesmanager/core/business/repositories/order/OrderRepositoryImpl.java
@@ -47,7 +47,7 @@ public class OrderRepositoryImpl implements OrderRepositoryCustom {
 		String whereQuery = " where o.merchant.id=:mId";
 		countBuilderWhere.append(whereQuery);
 		objectBuilderWhere.append(whereQuery);
-		objectBuilderWhere.append(orderByCriteria);
+		
 
 		if(!StringUtils.isBlank(criteria.getCustomerName())) {
 			String nameQuery =" and o.billing.firstName like:nm or o.billing.lastName like:nm";
@@ -67,6 +67,8 @@ public class OrderRepositoryImpl implements OrderRepositoryCustom {
 			objectBuilderWhere.append(customerQuery);
 		}
 		
+		objectBuilderWhere.append(orderByCriteria);
+		
 
 		//count query
 		Query countQ = em.createQuery(
diff --git a/sm-core/src/main/java/com/salesmanager/core/business/services/shipping/ShippingServiceImpl.java b/sm-core/src/main/java/com/salesmanager/core/business/services/shipping/ShippingServiceImpl.java
index 1a9757b..7e1d1a3 100644
--- a/sm-core/src/main/java/com/salesmanager/core/business/services/shipping/ShippingServiceImpl.java
+++ b/sm-core/src/main/java/com/salesmanager/core/business/services/shipping/ShippingServiceImpl.java
@@ -400,9 +400,6 @@ public class ShippingServiceImpl implements ShippingService {
 
 			//look if customer country code excluded
 			Country shipCountry = delivery.getCountry();
-			if(shipCountry==null) {
-				throw new ServiceException("Delivery country is null");
-			}
 			
 			//a ship to country is required
 			Validate.notNull(shipCountry);
@@ -516,12 +513,18 @@ public class ShippingServiceImpl implements ShippingService {
 				for(ShippingQuotePrePostProcessModule preProcessor : shippingModulePreProcessors) {
 					//System.out.println("Using pre-processor " + preProcessor.getModuleCode());
 					preProcessor.prePostProcessShippingQuotes(shippingQuote, packages, orderTotal, delivery, shippingOrigin, store, configuration, shippingModule, shippingConfiguration, shippingMethods, locale);
-					//switch module if required
+					//TODO switch module if required
 					if(shippingQuote.getCurrentShippingModule()!=null && !shippingQuote.getCurrentShippingModule().getCode().equals(shippingModule.getCode())) {
-						shippingModule = shippingQuote.getCurrentShippingModule();
+						shippingModule = shippingQuote.getCurrentShippingModule();//determines the shipping module
+						configuration = modules.get(shippingModule.getCode());
+						if(configuration!=null) {
+							if(configuration.isActive()) {
 						moduleName = shippingModule.getCode();
 						shippingQuoteModule = this.shippingModules.get(shippingModule.getCode());
 						configuration = modules.get(shippingModule.getCode());
+							} //TODO use default
+						}
+						
 					}
 				}
 			}
@@ -532,7 +535,7 @@ public class ShippingServiceImpl implements ShippingService {
 			try {
 				shippingOptions = shippingQuoteModule.getShippingQuotes(shippingQuote, packages, orderTotal, delivery, shippingOrigin, store, configuration, shippingModule, shippingConfiguration, locale);
 			} catch(Exception e) {
-				LOGGER.error("Error while calculating shipping", e);
+				LOGGER.error("Error while calculating shipping : " + e.getMessage(), e);
 				merchantLogService.save(
 						new MerchantLog(store,
 								"Can't process " + shippingModule.getModule()
@@ -543,7 +546,9 @@ public class ShippingServiceImpl implements ShippingService {
 				return shippingQuote;
 			}
 			
-			if(shippingOptions==null &&!StringUtils.isBlank(delivery.getPostalCode())) {
+			if(shippingOptions==null && !StringUtils.isBlank(delivery.getPostalCode())) {
+				
+				//absolutely need to use in this case store pickup or other default shipping quote
 				shippingQuote.setShippingReturnCode(ShippingQuote.NO_SHIPPING_TO_SELECTED_COUNTRY);
 			}
 			
@@ -654,6 +659,7 @@ public class ShippingServiceImpl implements ShippingService {
 			
 			
 		} catch (Exception e) {
+			LOGGER.error(e.getMessage(), e);
 			throw new ServiceException(e);
 		}
 		
@@ -863,12 +869,4 @@ public class ShippingServiceImpl implements ShippingService {
 		
 		return metaData;
 	}
-	
-
-
-
-
-}
-
-
-
+}
\ No newline at end of file
diff --git a/sm-search/target/classes/META-INF/maven/com.shopizer/sm-search/pom.properties b/sm-search/target/classes/META-INF/maven/com.shopizer/sm-search/pom.properties
index 8ecd5c9..cf40b76 100644
--- a/sm-search/target/classes/META-INF/maven/com.shopizer/sm-search/pom.properties
+++ b/sm-search/target/classes/META-INF/maven/com.shopizer/sm-search/pom.properties
@@ -1,5 +1,5 @@
 #Generated by Maven Integration for Eclipse
-#Mon Jan 16 09:00:51 EST 2017
+#Tue Jan 17 10:34:10 EST 2017
 version=2.0.5-SNAPSHOT
 groupId=com.shopizer
 m2e.projectName=sm-search
diff --git a/sm-shop/350_working b/sm-shop/350_working
new file mode 100644
index 0000000..f936419
Binary files /dev/null and b/sm-shop/350_working differ
diff --git a/sm-shop/SALESMANAGER.h2.db b/sm-shop/SALESMANAGER.h2.db
index 7258342..388f0b7 100644
Binary files a/sm-shop/SALESMANAGER.h2.db and b/sm-shop/SALESMANAGER.h2.db differ
diff --git a/sm-shop/SALESMANAGER.lock.db b/sm-shop/SALESMANAGER.lock.db
index a34b579..7be8eb2 100644
--- a/sm-shop/SALESMANAGER.lock.db
+++ b/sm-shop/SALESMANAGER.lock.db
@@ -1,4 +1,4 @@
 #FileLock
-#Fri Jan 13 17:09:10 EST 2017
-id=15999e09070cb9cf1432fc03f8d915fc14a2254a3aa
+#Tue Jan 17 10:34:27 EST 2017
+id=159ad10a2dfc5f5cf28bc04767b604ab34bc5be70da
 method=file
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/admin/controller/orders/OrderActionsControler.java b/sm-shop/src/main/java/com/salesmanager/shop/admin/controller/orders/OrderActionsControler.java
index 74eda95..4c8414d 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/admin/controller/orders/OrderActionsControler.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/admin/controller/orders/OrderActionsControler.java
@@ -45,7 +45,6 @@ import java.util.*;
 /**
  * Manage order details
  * @author Carl Samson
- *
  */
 @Controller
 public class OrderActionsControler {
@@ -417,7 +416,7 @@ private static final Logger LOGGER = LoggerFactory.getLogger(OrderActionsControl
 			
 			Locale customerLocale = LocaleUtils.getLocale(customer.getDefaultLanguage());
 			
-			emailTemplatesUtils.sendOrderEmail(customer, dbOrder, customerLocale, customer.getDefaultLanguage(), store, request.getContextPath());
+			emailTemplatesUtils.sendOrderEmail(customer.getEmailAddress(), customer, dbOrder, customerLocale, customer.getDefaultLanguage(), store, request.getContextPath());
 			
 			
 			resp.setStatus(AjaxResponse.RESPONSE_OPERATION_COMPLETED);
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java
index f4c401d..2ae58fd 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/category/ShoppingCategoryController.java
@@ -441,7 +441,8 @@ public class ShoppingCategoryController {
 	 * @param response
 	 * @return
 	 * @throws Exception
-	 */
+	 **/
+	////TODO : services/public/DEFAULT/products/category/MYCATEGORY?lang=fr
 	@RequestMapping("/services/public/products/{store}/{language}/{category}")
 	@ResponseBody
 	public ProductList getProducts(@PathVariable final String store, @PathVariable final String language, @PathVariable final String category, Model model, HttpServletRequest request, HttpServletResponse response) throws Exception {
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/order/ShoppingOrderController.java b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/order/ShoppingOrderController.java
index 1fd324a..7fdd8da 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/store/controller/order/ShoppingOrderController.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/store/controller/order/ShoppingOrderController.java
@@ -258,13 +258,13 @@ public class ShoppingOrderController extends AbstractController {
 		/** shipping **/
 		ShippingQuote quote = null;
 		if(requiresShipping) {
-			System.out.println("** Berfore default shipping quote **");
+			//System.out.println("** Berfore default shipping quote **");
+			//Get all applicable shipping quotes
 			quote = orderFacade.getShippingQuote(customer, cart, order, store, language);
 			model.addAttribute("shippingQuote", quote);
 		}
 
 		if(quote!=null) {
-			
 			String shippingReturnCode = quote.getShippingReturnCode();
 
 			if(StringUtils.isBlank(shippingReturnCode) || shippingReturnCode.equals(ShippingQuote.NO_POSTAL_CODE)) {
@@ -579,14 +579,18 @@ public class ShoppingOrderController extends AbstractController {
 					}
 	    		}
 	    		
-				//send order confirmation email
-				emailTemplatesUtils.sendOrderEmail(modelCustomer, modelOrder, locale, language, store, request.getContextPath());
+				//send order confirmation email to customer
+				emailTemplatesUtils.sendOrderEmail(modelCustomer.getEmailAddress(), modelCustomer, modelOrder, locale, language, store, request.getContextPath());
 		        
 		        if(orderService.hasDownloadFiles(modelOrder)) {
 		        	emailTemplatesUtils.sendOrderDownloadEmail(modelCustomer, modelOrder, store, locale, request.getContextPath());
 		
 		        }
 	    		
+				//send order confirmation email to merchant
+				emailTemplatesUtils.sendOrderEmail(store.getStoreEmailAddress(), modelCustomer, modelOrder, locale, language, store, request.getContextPath());
+		        
+	    		
 	    		
 	        } catch(Exception e) {
 	        	LOGGER.error("Error while post processing order",e);
@@ -892,8 +896,6 @@ public class ShoppingOrderController extends AbstractController {
 		Language language = (Language)request.getAttribute("LANGUAGE");
 		MerchantStore store = (MerchantStore)request.getAttribute(Constants.MERCHANT_STORE);
 		String shoppingCartCode  = getSessionAttribute(Constants.SHOPPING_CART, request);
-		
-		System.out.println("*** ENTERING SHIPPING QUOTES ***");
 
 		Map<String, Object> configs = (Map<String, Object>) request.getAttribute(Constants.REQUEST_CONFIGS);
 		
@@ -1188,11 +1190,13 @@ public class ShoppingOrderController extends AbstractController {
 							
 							
 							readableSummary.setSelectedShippingOption(quoteOption);
-							readableSummary.setShippingOptions(options);
-							
+							readableSummary.setShippingOptions(options);							
 
 							summary.setShippingOption(quoteOption.getOptionId());
+							summary.setShippingOptionCode(quoteOption.getOptionCode());
 							summary.setShipping(quoteOption.getOptionPrice());
+							order.setShippingSummary(summary);//override with new summary
+							
 							
 							@SuppressWarnings("unchecked")
 							Map<String,String> informations = (Map<String,String>)request.getSession().getAttribute("SHIPPING_INFORMATIONS");
@@ -1209,6 +1213,7 @@ public class ShoppingOrderController extends AbstractController {
 			List<ShoppingCartItem> items = new ArrayList<ShoppingCartItem>(cart.getLineItems());
 			order.setShoppingCartItems(items);
 			
+			//order total calculation
 			OrderTotalSummary orderTotalSummary = orderFacade.calculateOrderTotal(store, order, language);
 			super.setSessionAttribute(Constants.ORDER_SUMMARY, orderTotalSummary, request);
 			
@@ -1219,7 +1224,7 @@ public class ShoppingOrderController extends AbstractController {
 
 			List<ReadableOrderTotal> subtotals = new ArrayList<ReadableOrderTotal>();
 			for(OrderTotal total : orderTotalSummary.getTotals()) {
-				if(!total.getOrderTotalCode().equals("order.total.total")) {
+				if(total.getOrderTotalCode() == null || !total.getOrderTotalCode().equals("order.total.total")) {
 					ReadableOrderTotal t = new ReadableOrderTotal();
 					totalPopulator.populate(total, t, store, language);
 					subtotals.add(t);
@@ -1243,4 +1248,4 @@ public class ShoppingOrderController extends AbstractController {
 	
 
 
-}
+}
\ No newline at end of file
diff --git a/sm-shop/src/main/java/com/salesmanager/shop/utils/EmailTemplatesUtils.java b/sm-shop/src/main/java/com/salesmanager/shop/utils/EmailTemplatesUtils.java
index 5d42c9f..fa4b979 100644
--- a/sm-shop/src/main/java/com/salesmanager/shop/utils/EmailTemplatesUtils.java
+++ b/sm-shop/src/main/java/com/salesmanager/shop/utils/EmailTemplatesUtils.java
@@ -86,7 +86,7 @@ public class EmailTemplatesUtils {
 	 * @param contextPath
 	 */
 	@Async
-	public void sendOrderEmail(Customer customer, Order order, Locale customerLocale, Language language, MerchantStore merchantStore, String contextPath) {
+	public void sendOrderEmail(String toEmail, Customer customer, Order order, Locale customerLocale, Language language, MerchantStore merchantStore, String contextPath) {
 			   /** issue with putting that elsewhere **/ 
 		       LOGGER.info( "Sending welcome email to customer" );
 		       try {
@@ -110,8 +110,6 @@ public class EmailTemplatesUtils {
 		    		   Zone zone = zones.get(order.getBilling().getZone().getCode());
 		    		   if(zone!=null) {
 		    			   billing.append(zone.getName());
-		    		   } else {
-		    			   billing.append(zone.getCode());
 		    		   }
 		    		   billing.append(LINE_BREAK);
 		    	   } else if(!StringUtils.isBlank(order.getBilling().getState())) {
@@ -141,8 +139,6 @@ public class EmailTemplatesUtils {
 			    		   Zone zone = zones.get(order.getDelivery().getZone().getCode());
 			    		   if(zone!=null) {
 			    			   shipping.append(zone.getName());
-			    		   } else {
-			    			   shipping.append(zone.getCode());
 			    		   }
 			    		   shipping.append(LINE_BREAK);
 			    	   } else if(!StringUtils.isBlank(order.getDelivery().getState())) {
@@ -167,18 +163,7 @@ public class EmailTemplatesUtils {
 		    	   for(OrderProduct product : order.getOrderProducts()) {
 		    		   //Product productModel = productService.getByCode(product.getSku(), language);
 		    		   orderTable.append(TR);
-		    		   	   //images are ugly
-/*		    		       orderTable.append(TD);
-			    		   if(productModel!=null && productModel.getProductImage()!=null) {
-			    			   String productImage = new StringBuilder().append(storeUri).append(imageUtils.buildProductimageUtils(merchantStore, productModel, productModel.getProductImage().getProductImage())).toString();
-			    			   
-			    			   String imgSrc = new StringBuilder().append("<img src=\"").append(productImage).append("\" width=\"40\">").toString();
-			    			   orderTable.append(imgSrc);
-			    		   } else {
-			    			   orderTable.append("&nbsp;");
-			    		   }
-			    		   orderTable.append(CLOSING_TD);*/
-			    		   orderTable.append(TD).append(product.getProductName()).append(CLOSING_TD);
+			    		   orderTable.append(TD).append(product.getProductName()).append(" - ").append(product.getSku()).append(CLOSING_TD);
 		    		   	   orderTable.append(TD).append(messages.getMessage("label.quantity", customerLocale)).append(": ").append(product.getProductQuantity()).append(CLOSING_TD);
 	    		   		   orderTable.append(TD).append(pricingService.getDisplayAmount(product.getOneTimeCharge(), merchantStore)).append(CLOSING_TD);
     		   		   orderTable.append(CLOSING_TR);
@@ -259,7 +244,7 @@ public class EmailTemplatesUtils {
 		           email.setFrom(merchantStore.getStorename());
 		           email.setFromEmail(merchantStore.getStoreEmailAddress());
 		           email.setSubject(messages.getMessage("email.order.title", title, customerLocale));
-		           email.setTo(customer.getEmailAddress());
+		           email.setTo(toEmail);
 		           email.setTemplateName(EmailConstants.EMAIL_ORDER_TPL);
 		           email.setTemplateTokens(templateTokens);
 
@@ -274,6 +259,7 @@ public class EmailTemplatesUtils {
 	
 	/**
 	 * Sends an email to the customer after registration
+	 * @param request
 	 * @param customer
 	 * @param merchantStore
 	 * @param customerLocale
@@ -360,6 +346,7 @@ public class EmailTemplatesUtils {
 	
 	/**
 	 * Send an email to the customer with last order status
+	 * @param request
 	 * @param customer
 	 * @param order
 	 * @param merchantStore
@@ -504,4 +491,4 @@ public class EmailTemplatesUtils {
 		
 	}
 
-}
+}
\ No newline at end of file
diff --git a/sm-shop/src/main/webapp/pages/admin/orders/order.jsp b/sm-shop/src/main/webapp/pages/admin/orders/order.jsp
index 87b8ab3..a484729 100644
--- a/sm-shop/src/main/webapp/pages/admin/orders/order.jsp
+++ b/sm-shop/src/main/webapp/pages/admin/orders/order.jsp
@@ -377,7 +377,7 @@ function captureOrder(orderId){
 							</c:if>
 				    	</li>
 				    	
-				    	<li><a href="<c:url value="/admin/orders/printInvoice.html?id=${order.id}" />"><s:message code="label.order.printinvoice" text="Print invoice"/></a></li>
+				    	<!--<li><a href="<c:url value="/admin/orders/printInvoice.html?id=${order.id}" />"><s:message code="label.order.printinvoice" text="Print invoice"/></a></li>-->
 				    	<!-- available soon <li><a href="<c:url value="/admin/orders/printShippingLabel.html?id=${order.id}" />"><s:message code="label.order.packing" text="Print packing slip"/></a></li>-->
 				    	<li>
 				    		<c:if test="${customer!=null}">
diff --git a/sm-shop/src/main/webapp/pages/shop/common/customer/orders.jsp b/sm-shop/src/main/webapp/pages/shop/common/customer/orders.jsp
index 11febdb..27212da 100644
--- a/sm-shop/src/main/webapp/pages/shop/common/customer/orders.jsp
+++ b/sm-shop/src/main/webapp/pages/shop/common/customer/orders.jsp
@@ -61,7 +61,7 @@ response.setDateHeader ("Expires", -1);
 						<c:forEach items="${customerOrders.orders}" var="order" varStatus="orderStatus">
 							<tr><!-- item -->
 								<td><a href="${customerOrder}?orderId=${order.id}">${order.id}</a></td>
-								<td><fmt:formatDate type="both" value="${order.datePurchased}" /></td>
+								<td><fmt:formatDate type="both" value="${order.datePurchased}" pattern="yyyy-MM-dd" /></td>
 								<td><sm:monetary value="${order.total.value}" />&nbsp;<small>(${fn:length(order.products)} <c:choose><c:when test="${fn:length(order.products)==1}"><s:message code="label.generic.item" text="item"/></c:when><c:otherwise><s:message code="label.generic.items" text="items"/></c:otherwise></c:choose>)</small></td>
 								<td>${order.orderStatus}</td>
 								
@@ -108,6 +108,4 @@ response.setDateHeader ("Expires", -1);
 		</div>
 		<!-- close row-fluid--> 
 	</div>
-	<!--close .container "main-content" -->
-	
-	<!-- http://theme.stepofweb.com/Alkaline/v1.0/shop-history-summary.html -->
\ No newline at end of file
+	<!--close .container "main-content" -->
\ No newline at end of file