Beispiel #1
0
        private PurchaseOrder ImportPurchaseOrder(PurchaseOrderObject purchaseOrderObj)
        {
            if (purchaseOrderObj == null)
            {
                return(null);
            }

            bool          isNew = false;
            PurchaseOrder order = importRepo.PurchaseOrderRepo.Get(purchaseOrderObj.Id);

            if (order == null)
            {
                order = new PurchaseOrder();
                isNew = true;
            }

            order.Id       = purchaseOrderObj.Id;
            order.IsActive = purchaseOrderObj.IsActive;
            order.Number   = purchaseOrderObj.Number;
            order.Date     = purchaseOrderObj.Date;

            if (isNew)
            {
                importRepo.PurchaseOrderRepo.Save(order);
            }
            else
            {
                importRepo.PurchaseOrderRepo.SaveOrUpdate(order);
            }

            return(order);
        }
Beispiel #2
0
 void AssertPurchaseOrder(PurchaseOrderObject obj)
 {
     Assert.AreEqual(id, obj.Id);
     Assert.AreEqual(NUMBER, obj.Number);
     Assert.AreEqual(DATE, obj.Date);
     Assert.IsTrue(obj.IsActive);
 }
        public ActionResult EditPurchaseOrder(PurchaseOrderObject purchaseOrder)
        {
            var gVal = new GenericValidator();

            try
            {
                var valStatus = ValidatePurchaseOrder(purchaseOrder);
                if (valStatus.Code < 1)
                {
                    gVal.Code  = 0;
                    gVal.Error = valStatus.Error;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var k = new PurchaseOrderServices().UpdatePurchaseOrder(purchaseOrder);
                if (k < 1)
                {
                    gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure;
                    gVal.Code  = 0;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = 5;
                gVal.Error = message_Feedback.Update_Success;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
        private GenericValidator ValidatePurchaseOrder(PurchaseOrderObject purchaseOrder)
        {
            var gVal = new GenericValidator();

            if (purchaseOrder == null)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Fatal_Error;
                return(gVal);
            }

            if (purchaseOrder.DerivedTotalCost < 1)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Derived_Total_Cost_Error;
                return(gVal);
            }

            if (purchaseOrder.SupplierId < 1)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Supplier_Selection_Error;
                return(gVal);
            }

            if (purchaseOrder.AccountId < 1)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Chart_Of_Account_Selection_Error;
                return(gVal);
            }

            if (!purchaseOrder.PurchaseOrderItemObjects.Any())
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Purchase_Order_Items_Error;
                return(gVal);
            }

            if (purchaseOrder.ExpectedDeliveryDate.Year == 1)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Expected_Delivery_Date_Error;
                return(gVal);
            }



            gVal.Code = 5;
            return(gVal);
        }
        public ActionResult AddPurchaseOrder(PurchaseOrderObject purchaseOrder)
        {
            var gVal = new GenericValidator();

            try
            {
                var valStatus = ValidatePurchaseOrder(purchaseOrder);
                if (valStatus.Code < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = valStatus.Error;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var userInfo = GetSignedOnUser();
                if (userInfo == null || userInfo.UserProfile.Id < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = "Your session has timed out.";
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                purchaseOrder.StoreOutletId  = userInfo.UserProfile.StoreOutletId;
                purchaseOrder.StatusCode     = (int)PurchaseOrderDeliveryStatus.Pending;
                purchaseOrder.GeneratedById  = userInfo.UserProfile.EmployeeId;
                purchaseOrder.DateTimePlaced = DateTime.Now;

                string purchaseOrderNumber;
                var    k = new PurchaseOrderServices().AddPurchaseOrder(purchaseOrder, out purchaseOrderNumber);
                if (k < 1)
                {
                    gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                    gVal.Code  = -1;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code = k;
                gVal.PurchaseOrderNumber = purchaseOrderNumber;
                gVal.Error = message_Feedback.Insertion_Success;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult EditPurchaseOrderDelivery(PurchaseOrderObject deliveryObject)
        {
            try
            {
                var mainOutlet = new StoreItemStockServices().GetStoreDefaultOutlet();
                if (mainOutlet == null || mainOutlet.StoreOutletId < 1)
                {
                    return(Json(new List <ItemPriceObject>(), JsonRequestBehavior.AllowGet));
                }

                //var status = new PurchaseOrderServices().EditPurchaseOrderDelivery(deliveryObject);
                //return Json(status, JsonRequestBehavior.AllowGet);
                return(Json(new List <ItemPriceObject>(), JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new List <StoreItemStockObject>(), JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #7
0
        public void TestPurchaseOrderObjectCasting()
        {
            PurchaseOrderObject obj = SetupMock();

            AssertPurchaseOrder(obj);
        }
Beispiel #8
0
        public void TestPurchaseOrderObjectCopyConstructor()
        {
            PurchaseOrderObject obj = new PurchaseOrderObject(SetupMock());

            AssertPurchaseOrder(obj);
        }
 public long UpdatePurchaseOrder(PurchaseOrderObject purchaseOrder)
 {
     return(_purchaseOrderRepository.UpdatePurchaseOrder(purchaseOrder));
 }
 public long AddPurchaseOrder(PurchaseOrderObject purchaseOrder, out string purchaseOrderNumber)
 {
     return(_purchaseOrderRepository.AddPurchaseOrder(purchaseOrder, out purchaseOrderNumber));
 }
 public long AddPurchaseOrder(PurchaseOrderObject purchaseOrder)
 {
     return(_purchaseOrderRepository.AddPurchaseOrder(purchaseOrder));
 }