Subversion Repositories SmartDukaan

Rev

Rev 22139 | Rev 23026 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.web.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
import com.spice.profitmandi.common.model.ProfitMandiConstants;
import com.spice.profitmandi.service.inventory.PurchaseService;
import com.spice.profitmandi.web.model.LoginDetails;
import com.spice.profitmandi.web.util.CookiesProcessor;

@Controller
@Transactional(rollbackFor=Throwable.class)
public class PurchaseController {

        private static final Logger LOGGER = LoggerFactory.getLogger(PurchaseController.class);
        
        @Autowired
        private PurchaseService purchaseService;

        @Autowired
        private CookiesProcessor cookiesProcessor;

        @RequestMapping(value = "/purchase", method = RequestMethod.POST)
        public String purchaseByAirwayBillOrInvoiceNumber(HttpServletRequest request, @RequestParam(name = ProfitMandiConstants.AIRWAY_BILL_OR_INVOICE_NUMBER) String airwayBillOrInvoiceNumber, Model model)  throws ProfitMandiBusinessException{
                LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
                LOGGER.info("Request Received at url {} with airwayBillOrInvoiceNumber {}", request.getRequestURI(), airwayBillOrInvoiceNumber);
                
                Map<String, Object> map = purchaseService.purchaseByInvoiceNumber(airwayBillOrInvoiceNumber, fofoDetails.getFofoId());
                model.addAllAttributes(map);
                return "purchase";
        }

        @RequestMapping(value = "/purchase", method = RequestMethod.GET)
        public String purchase(HttpServletRequest request)  throws Exception{
                return "purchase";
        }
}