コード例 #1
0
 public CashSalesInvoiceDetail ConfirmObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService, IWarehouseItemService _warehouseItemService,
                                             IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService)
 {
     if (_validator.ValidConfirmObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _warehouseItemService))
     {
         CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);
         WarehouseItem    warehouseItem    = _warehouseItemService.FindOrCreateObject(cashSalesInvoice.WarehouseId, cashSalesInvoiceDetail.ItemId);
         Item             item             = _itemService.GetObjectById(cashSalesInvoiceDetail.ItemId);
         StockMutation    stockMutation    = new StockMutation()
         {
             ItemId                   = cashSalesInvoiceDetail.ItemId,
             ItemCase                 = Core.Constants.Constant.ItemCase.Ready,
             Status                   = Core.Constants.Constant.MutationStatus.Deduction,
             Quantity                 = cashSalesInvoiceDetail.Quantity,
             SourceDocumentCode       = cashSalesInvoice.Code,
             SourceDocumentId         = cashSalesInvoice.Id,
             SourceDocumentType       = Core.Constants.Constant.SourceDocumentType.CashSalesInvoice,
             SourceDocumentDetailCode = cashSalesInvoiceDetail.Code,
             SourceDocumentDetailId   = cashSalesInvoiceDetail.Id,
             SourceDocumentDetailType = Core.Constants.Constant.SourceDocumentDetailType.CashSalesInvoiceDetail,
             WarehouseId              = cashSalesInvoice.WarehouseId,
             WarehouseItemId          = warehouseItem.Id
         };
         stockMutation           = _stockMutationService.CreateObject(stockMutation, _warehouseService, _warehouseItemService, _itemService, _barringService);
         stockMutation.CreatedAt = (DateTime)cashSalesInvoice.ConfirmationDate.GetValueOrDefault();
         _stockMutationService.UpdateObject(stockMutation, _warehouseService, _warehouseItemService, _itemService, _barringService);
         _stockMutationService.StockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
         cashSalesInvoiceDetail.CoGS = cashSalesInvoiceDetail.Quantity * item.AvgPrice;
         cashSalesInvoiceDetail      = _repository.ConfirmObject(cashSalesInvoiceDetail);
     }
     return(cashSalesInvoiceDetail);
 }
コード例 #2
0
 public bool ValidCreateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService,
                               ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IItemService _itemService, IWarehouseItemService _warehouseItemService,
                               IQuantityPricingService _quantityPricingService)
 {
     VCreateObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _cashSalesInvoiceDetailService, _itemService, _warehouseItemService, _quantityPricingService);
     return(isValid(cashSalesInvoiceDetail));
 }
コード例 #3
0
 public CashSalesInvoiceDetail VUpdateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService,
                                             ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IItemService _itemService, IWarehouseItemService _warehouseItemService,
                                             IQuantityPricingService _quantityPricingService)
 {
     //VIsParentNotConfirmed(cashSalesInvoiceDetail, _cashSalesInvoiceService);
     //if (!isValid(cashSalesInvoiceDetail)) { return cashSalesInvoiceDetail; }
     return(VCreateObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _cashSalesInvoiceDetailService, _itemService, _warehouseItemService, _quantityPricingService));
 }
コード例 #4
0
 public bool ValidUpdateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService,
                               ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IItemService _itemService, IWarehouseItemService _warehouseItemService,
                               IQuantityPricingService _quantityPricingService)
 {
     cashSalesInvoiceDetail.Errors.Clear();
     VUpdateObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _cashSalesInvoiceDetailService, _itemService, _warehouseItemService, _quantityPricingService);
     return(isValid(cashSalesInvoiceDetail));
 }
コード例 #5
0
 public CashSalesInvoiceDetail VIsValidDiscount(CashSalesInvoiceDetail cashSalesInvoiceDetail)
 {
     if (cashSalesInvoiceDetail.Discount < 0 || cashSalesInvoiceDetail.Discount > 100)
     {
         cashSalesInvoiceDetail.Errors.Add("Discount", "Harus antara 0 sampai 100");
     }
     return(cashSalesInvoiceDetail);
 }
コード例 #6
0
 public CashSalesInvoiceDetail VIsValidAssignedPrice(CashSalesInvoiceDetail cashSalesInvoiceDetail)
 {
     if (cashSalesInvoiceDetail.IsManualPriceAssignment && cashSalesInvoiceDetail.AssignedPrice < 0)
     {
         cashSalesInvoiceDetail.Errors.Add("AssignedPrice", "Harus lebih besar atau sama dengan 0");
     }
     return(cashSalesInvoiceDetail);
 }
コード例 #7
0
        public CashSalesInvoiceDetail VHasCashSalesInvoice(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService)
        {
            CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);

            if (cashSalesInvoice == null)
            {
                cashSalesInvoiceDetail.Errors.Add("CashSalesInvoiceId", "Tidak valid");
            }
            return(cashSalesInvoiceDetail);
        }
コード例 #8
0
        public CashSalesInvoiceDetail VHasItem(CashSalesInvoiceDetail cashSalesInvoiceDetail, IItemService _itemService)
        {
            Item item = _itemService.GetObjectById(cashSalesInvoiceDetail.ItemId);

            if (item == null)
            {
                cashSalesInvoiceDetail.Errors.Add("ItemId", "Tidak valid");
            }
            return(cashSalesInvoiceDetail);
        }
コード例 #9
0
        public dynamic UpdateDetail(CashSalesInvoiceDetail model)
        {
            decimal total = 0;

            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.CashSalesInvoice, Core.Constants.Constant.MenuGroupName.Transaction))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Edit record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }
                if ((model.IsManualPriceAssignment || model.Discount > 0) && (!AuthenticationModel.IsAllowed("ManualPricing", Core.Constants.Constant.MenuName.CashSalesInvoice, Core.Constants.Constant.MenuGroupName.Transaction)))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Use Manual Pricing/Discount");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _cashSalesInvoiceDetailService.GetObjectById(model.Id);
                data.ItemId   = model.ItemId;
                data.Quantity = model.Quantity;
                data.Discount = model.Discount;
                data.IsManualPriceAssignment = model.IsManualPriceAssignment;
                data.AssignedPrice           = model.AssignedPrice;
                data.CashSalesInvoiceId      = model.CashSalesInvoiceId;
                model = _cashSalesInvoiceDetailService.UpdateObject(data, _cashSalesInvoiceService, _itemService, _warehouseItemService, _quantityPricingService);
                total = _cashSalesInvoiceService.GetObjectById(model.CashSalesInvoiceId).Total;
            }
            catch (Exception ex)
            {
                LOG.Error("Update Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors,
                Total = total
            }));
        }
コード例 #10
0
        public CashSalesReturnDetail VIsValidQuantity(CashSalesReturnDetail cashSalesReturnDetail, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, ICashSalesReturnDetailService _cashSalesReturnDetailService)
        {
            CashSalesInvoiceDetail cashSalesInvoiceDetail = _cashSalesInvoiceDetailService.GetObjectById(cashSalesReturnDetail.CashSalesInvoiceDetailId);

            if (cashSalesReturnDetail.Quantity <= 0 || _cashSalesReturnDetailService.GetTotalQuantityByCashSalesInvoiceDetailId(cashSalesReturnDetail.CashSalesInvoiceDetailId) > cashSalesInvoiceDetail.Quantity)
            {
                cashSalesReturnDetail.Errors.Add("Quantity", "Quantity harus lebih besar dari 0 dan lebih kecil atau sama dengan CashSalesInvoiceDetail Quantity");
                return(cashSalesReturnDetail);
            }
            return(cashSalesReturnDetail);
        }
コード例 #11
0
        /*public CashSalesInvoiceDetail VHasQuantityPricing(CashSalesInvoiceDetail cashSalesInvoiceDetail, IItemService _itemService, IQuantityPricingService _quantityPricingService)
         * {
         *  Item item = _itemService.GetObjectById(cashSalesInvoiceDetail.ItemId);
         *  IList<QuantityPricing> quantityPricings = _quantityPricingService.GetObjectsByItemTypeId(item.ItemTypeId);
         *  if (quantityPricings.Any())
         *  {
         *      cashSalesInvoiceDetail.Errors.Add("Generic", "Tidak ada QuantityPricing terasosiasi");
         *  }
         *  return cashSalesInvoiceDetail;
         * }*/

        public CashSalesInvoiceDetail VIsValidQuantityOrdered(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService, IWarehouseItemService _warehouseItemService)
        {
            CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);
            WarehouseItem    warehouseItem    = _warehouseItemService.FindOrCreateObject(cashSalesInvoice.WarehouseId, cashSalesInvoiceDetail.ItemId);

            if (warehouseItem.Quantity - cashSalesInvoiceDetail.Quantity < 0)
            {
                cashSalesInvoiceDetail.Errors.Add("Generic", "Quantity harus lebih kecil atau sama dengan WarehouseItem Quantity");
                return(cashSalesInvoiceDetail);
            }
            return(cashSalesInvoiceDetail);
        }
コード例 #12
0
        public CashSalesInvoiceDetail VIsValidQuantity(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService, IWarehouseItemService _warehouseItemService)
        {
            CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);
            WarehouseItem    warehouseItem    = _warehouseItemService.FindOrCreateObject(cashSalesInvoice.WarehouseId, cashSalesInvoiceDetail.ItemId);

            if (cashSalesInvoiceDetail.Quantity <= 0 || cashSalesInvoiceDetail.Quantity > warehouseItem.Quantity)
            {
                cashSalesInvoiceDetail.Errors.Add("Quantity", "Quantity harus lebih besar dari 0 dan lebih kecil atau sama dengan WarehouseItem Quantity");
                return(cashSalesInvoiceDetail);
            }
            return(cashSalesInvoiceDetail);
        }
コード例 #13
0
        public string PrintError(CashSalesInvoiceDetail obj)
        {
            string erroroutput = "";
            KeyValuePair <string, string> first = obj.Errors.ElementAt(0);

            erroroutput += first.Key + "," + first.Value;
            foreach (KeyValuePair <string, string> pair in obj.Errors.Skip(1))
            {
                erroroutput += Environment.NewLine;
                erroroutput += pair.Key + "," + pair.Value;
            }
            return(erroroutput);
        }
コード例 #14
0
 public CashSalesInvoiceDetail SoftDeleteObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService)
 {
     if (_validator.ValidDeleteObject(cashSalesInvoiceDetail, _cashSalesInvoiceService))
     {
         CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);
         _repository.SoftDeleteObject(cashSalesInvoiceDetail);
         cashSalesInvoice.Total = CalculateTotal(cashSalesInvoice.Id);
         cashSalesInvoice.CoGS  = CalculateCoGS(cashSalesInvoice.Id);
         _cashSalesInvoiceService.GetRepository().Update(cashSalesInvoice);
     }
     ;
     return(cashSalesInvoiceDetail);
 }
コード例 #15
0
        public CashSalesInvoiceDetail VUniqueItem(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IItemService _itemService)
        {
            IList <CashSalesInvoiceDetail> details = _cashSalesInvoiceDetailService.GetObjectsByCashSalesInvoiceId(cashSalesInvoiceDetail.CashSalesInvoiceId);

            foreach (var detail in details)
            {
                if (detail.ItemId == cashSalesInvoiceDetail.ItemId && detail.Id != cashSalesInvoiceDetail.Id)
                {
                    cashSalesInvoiceDetail.Errors.Add("Generic", "Tidak boleh ada duplikasi item dalam 1 CashSalesInvoice");
                }
            }
            return(cashSalesInvoiceDetail);
        }
コード例 #16
0
 public CashSalesReturnDetail UpdateObject(CashSalesReturnDetail cashSalesReturnDetail, ICashSalesReturnService _cashSalesReturnService,
                                           ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService)
 {
     if (_validator.ValidUpdateObject(cashSalesReturnDetail, _cashSalesReturnService, this, _cashSalesInvoiceDetailService))
     {
         CashSalesReturn        cashSalesReturn        = _cashSalesReturnService.GetObjectById(cashSalesReturnDetail.CashSalesReturnId);
         CashSalesInvoiceDetail cashSalesInvoiceDetail = _cashSalesInvoiceDetailService.GetObjectById(cashSalesReturnDetail.CashSalesInvoiceDetailId);
         cashSalesReturnDetail.TotalPrice = (cashSalesInvoiceDetail.Amount / cashSalesInvoiceDetail.Quantity) * cashSalesReturnDetail.Quantity;
         cashSalesReturnDetail            = _repository.UpdateObject(cashSalesReturnDetail);
         cashSalesReturn.Total            = CalculateTotal(cashSalesReturn.Id);
         _cashSalesReturnService.GetRepository().Update(cashSalesReturn);
     }
     return(cashSalesReturnDetail);
 }
コード例 #17
0
 public CashSalesReturnDetail CreateObject(CashSalesReturnDetail cashSalesReturnDetail, ICashSalesReturnService _cashSalesReturnService,
                                           ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService)
 {
     cashSalesReturnDetail.Errors = new Dictionary <String, String>();
     if (_validator.ValidCreateObject(cashSalesReturnDetail, _cashSalesReturnService, this, _cashSalesInvoiceDetailService))
     {
         CashSalesReturn        cashSalesReturn        = _cashSalesReturnService.GetObjectById(cashSalesReturnDetail.CashSalesReturnId);
         CashSalesInvoiceDetail cashSalesInvoiceDetail = _cashSalesInvoiceDetailService.GetObjectById(cashSalesReturnDetail.CashSalesInvoiceDetailId);
         cashSalesReturnDetail.TotalPrice = (cashSalesInvoiceDetail.Amount / cashSalesInvoiceDetail.Quantity) * cashSalesReturnDetail.Quantity;
         cashSalesReturnDetail            = _repository.CreateObject(cashSalesReturnDetail);
         cashSalesReturn.Total            = CalculateTotal(cashSalesReturn.Id);
         _cashSalesReturnService.GetRepository().Update(cashSalesReturn);
     }
     return(cashSalesReturnDetail);
 }
コード例 #18
0
        public CashSalesInvoiceDetail VIsParentNotConfirmed(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService)
        {
            CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);

            if (cashSalesInvoice != null)
            {
                if (cashSalesInvoice.IsConfirmed)
                {
                    cashSalesInvoiceDetail.Errors.Add("Generic", "CashSalesInvoice tidak boleh terkonfirmasi");
                }
            }
            else
            {
                cashSalesInvoiceDetail.Errors.Add("Generic", "CashSalesInvoice tidak ada");
            }
            return(cashSalesInvoiceDetail);
        }
コード例 #19
0
 public CashSalesInvoiceDetail UnconfirmObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, IWarehouseItemService _warehouseItemService,
                                               IWarehouseService _warehouseService, IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService)
 {
     if (_validator.ValidUnconfirmObject(cashSalesInvoiceDetail))
     {
         IList <StockMutation> stockMutations = _stockMutationService.GetObjectsBySourceDocumentDetailForItem(cashSalesInvoiceDetail.ItemId, Core.Constants.Constant.SourceDocumentDetailType.CashSalesInvoiceDetail, cashSalesInvoiceDetail.Id);
         foreach (var stockMutation in stockMutations)
         {
             stockMutation.Errors = new Dictionary <string, string>();
             _stockMutationService.ReverseStockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
             _stockMutationService.SoftDeleteObject(stockMutation, _warehouseService, _warehouseItemService, _itemService, _barringService);
         }
         cashSalesInvoiceDetail.CoGS = 0;
         cashSalesInvoiceDetail      = _repository.UnconfirmObject(cashSalesInvoiceDetail);
     }
     return(cashSalesInvoiceDetail);
 }
コード例 #20
0
 public CashSalesInvoiceDetail VCreateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService,
                                             ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, IItemService _itemService, IWarehouseItemService _warehouseItemService,
                                             IQuantityPricingService _quantityPricingService)
 {
     VIsParentNotConfirmed(cashSalesInvoiceDetail, _cashSalesInvoiceService);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VHasCashSalesInvoice(cashSalesInvoiceDetail, _cashSalesInvoiceService);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VIsValidQuantity(cashSalesInvoiceDetail, _cashSalesInvoiceService, _warehouseItemService);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VIsValidDiscount(cashSalesInvoiceDetail);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VIsValidAssignedPrice(cashSalesInvoiceDetail);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VHasItem(cashSalesInvoiceDetail, _itemService);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VUniqueItem(cashSalesInvoiceDetail, _cashSalesInvoiceDetailService, _itemService);
     if (!isValid(cashSalesInvoiceDetail))
     {
         return(cashSalesInvoiceDetail);
     }
     VConfirmObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _warehouseItemService);
     //if (!isValid(cashSalesInvoiceDetail)) { return cashSalesInvoiceDetail; }
     //VHasQuantityPricing(cashSalesInvoiceDetail, _itemService, _quantityPricingService);
     return(cashSalesInvoiceDetail);
 }
コード例 #21
0
        public CashSalesReturnDetail VIsValidCashSalesInvoiceDetail(CashSalesReturnDetail cashSalesReturnDetail, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService, ICashSalesReturnService _cashSalesReturnService)
        {
            CashSalesInvoiceDetail cashSalesInvoiceDetail = _cashSalesInvoiceDetailService.GetObjectById(cashSalesReturnDetail.CashSalesInvoiceDetailId);
            CashSalesReturn        cashSalesReturn        = _cashSalesReturnService.GetObjectById(cashSalesReturnDetail.CashSalesReturnId);

            if (cashSalesInvoiceDetail == null)
            {
                cashSalesReturnDetail.Errors.Add("CashSalesInvoiceDetailId", "Tidak valid");
            }
            else if (cashSalesReturn == null)
            {
                cashSalesReturnDetail.Errors.Add("CashSalesReturnId", "Tidak valid");
            }
            else if (cashSalesInvoiceDetail.CashSalesInvoiceId != cashSalesReturn.CashSalesInvoiceId)
            {
                cashSalesReturnDetail.Errors.Add("CashSalesInvoiceId", "Tidak sama");
            }
            return(cashSalesReturnDetail);
        }
コード例 #22
0
 public CashSalesReturnDetail UnconfirmObject(CashSalesReturnDetail cashSalesReturnDetail, ICashSalesInvoiceDetailService _cashSalesInvoiceDetailService,
                                              IWarehouseItemService _warehouseItemService, IWarehouseService _warehouseService,
                                              IItemService _itemService, IBarringService _barringService, IStockMutationService _stockMutationService)
 {
     if (_validator.ValidUnconfirmObject(cashSalesReturnDetail))
     {
         CashSalesInvoiceDetail cashSalesInvoiceDetail = _cashSalesInvoiceDetailService.GetObjectById(cashSalesReturnDetail.CashSalesInvoiceDetailId);
         Item item = _itemService.GetObjectById(cashSalesInvoiceDetail.ItemId);
         IList <StockMutation> stockMutations = _stockMutationService.GetObjectsBySourceDocumentDetailForItem(cashSalesInvoiceDetail.ItemId, Core.Constants.Constant.SourceDocumentDetailType.CashSalesReturnDetail, cashSalesReturnDetail.Id);
         foreach (var stockMutation in stockMutations)
         {
             stockMutation.Errors = new Dictionary <string, string>();
             _stockMutationService.ReverseStockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
             _stockMutationService.SoftDeleteObject(stockMutation, _warehouseService, _warehouseItemService, _itemService, _barringService);
         }
         item.AvgPrice         = _itemService.CalculateAndUpdateAvgPrice(item, cashSalesReturnDetail.Quantity * (-1), (cashSalesInvoiceDetail.CoGS / cashSalesInvoiceDetail.Quantity));
         cashSalesReturnDetail = _repository.UnconfirmObject(cashSalesReturnDetail);
     }
     return(cashSalesReturnDetail);
 }
コード例 #23
0
        public CashSalesInvoiceDetail CreateObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService,
                                                   IItemService _itemService, IWarehouseItemService _warehouseItemService,
                                                   IQuantityPricingService _quantityPricingService)
        {
            cashSalesInvoiceDetail.Errors = new Dictionary <String, String>();
            if (_validator.ValidCreateObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, this, _itemService, _warehouseItemService, _quantityPricingService))
            {
                Item            item            = _itemService.GetObjectById(cashSalesInvoiceDetail.ItemId);
                QuantityPricing quantityPricing = _quantityPricingService.GetObjectByItemTypeIdAndQuantity(item.ItemTypeId, cashSalesInvoiceDetail.Quantity);
                decimal         price           = item.SellingPrice;
                decimal         discount        = cashSalesInvoiceDetail.Discount;
                if (cashSalesInvoiceDetail.IsManualPriceAssignment)
                {
                    price = cashSalesInvoiceDetail.AssignedPrice;
                }
                else
                {
                    cashSalesInvoiceDetail.AssignedPrice = 0;
                }
                if (quantityPricing != null)
                {
                    if (cashSalesInvoiceDetail.Discount <= 0)
                    {
                        discount = quantityPricing.Discount;
                    }
                    ;
                }
                cashSalesInvoiceDetail.Amount = (price * (100 - discount) / 100) * cashSalesInvoiceDetail.Quantity;
                cashSalesInvoiceDetail.CoGS   = cashSalesInvoiceDetail.Quantity * item.AvgPrice;

                CashSalesInvoice cashSalesInvoice = _cashSalesInvoiceService.GetObjectById(cashSalesInvoiceDetail.CashSalesInvoiceId);
                cashSalesInvoiceDetail.PriceMutationId = item.PriceMutationId;

                cashSalesInvoiceDetail = _repository.CreateObject(cashSalesInvoiceDetail);
                cashSalesInvoice.Total = CalculateTotal(cashSalesInvoice.Id);
                cashSalesInvoice.CoGS  = CalculateCoGS(cashSalesInvoice.Id);
                _cashSalesInvoiceService.GetRepository().Update(cashSalesInvoice);
            }
            return(cashSalesInvoiceDetail);
        }
コード例 #24
0
        public dynamic DeleteDetail(CashSalesInvoiceDetail model)
        {
            decimal total = 0;

            try
            {
                if (!AuthenticationModel.IsAllowed("Edit", Core.Constants.Constant.MenuName.CashSalesInvoice, Core.Constants.Constant.MenuGroupName.Transaction))
                {
                    Dictionary <string, string> Errors = new Dictionary <string, string>();
                    Errors.Add("Generic", "You are Not Allowed to Edit record");

                    return(Json(new
                    {
                        Errors
                    }, JsonRequestBehavior.AllowGet));
                }

                var data = _cashSalesInvoiceDetailService.GetObjectById(model.Id);
                model = _cashSalesInvoiceDetailService.SoftDeleteObject(data, _cashSalesInvoiceService);
                total = _cashSalesInvoiceService.GetObjectById(model.CashSalesInvoiceId).Total;
            }
            catch (Exception ex)
            {
                LOG.Error("Delete Failed", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Errors,
                Total = total
            }));
        }
コード例 #25
0
        public dynamic GetInfoDetail(int Id)
        {
            CashSalesInvoiceDetail model = new CashSalesInvoiceDetail();

            try
            {
                model = _cashSalesInvoiceDetailService.GetObjectById(Id);
            }
            catch (Exception ex)
            {
                LOG.Error("GetInfo", ex);
                Dictionary <string, string> Errors = new Dictionary <string, string>();
                Errors.Add("Generic", "Error " + ex);

                return(Json(new
                {
                    Errors
                }, JsonRequestBehavior.AllowGet));
            }

            return(Json(new
            {
                model.Id,
                model.Code,
                model.CashSalesInvoiceId,
                CashSalesInvoice = _cashSalesInvoiceService.GetObjectById(model.CashSalesInvoiceId).Code,
                model.ItemId,
                Item = _itemService.GetObjectById(model.ItemId).Name,
                model.Quantity,
                model.Discount,
                model.IsManualPriceAssignment,
                model.AssignedPrice,
                model.Amount,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #26
0
 public bool ValidConfirmObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService, IWarehouseItemService _warehouseItemService)
 {
     cashSalesInvoiceDetail.Errors.Clear();
     VConfirmObject(cashSalesInvoiceDetail, _cashSalesInvoiceService, _warehouseItemService);
     return(isValid(cashSalesInvoiceDetail));
 }
コード例 #27
0
 public CashSalesInvoiceDetail VDeleteObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService)
 {
     VIsParentNotConfirmed(cashSalesInvoiceDetail, _cashSalesInvoiceService);
     return(cashSalesInvoiceDetail);
 }
コード例 #28
0
 public bool ValidUnconfirmObject(CashSalesInvoiceDetail cashSalesInvoiceDetail)
 {
     cashSalesInvoiceDetail.Errors.Clear();
     VUnconfirmObject(cashSalesInvoiceDetail);
     return(isValid(cashSalesInvoiceDetail));
 }
コード例 #29
0
 public bool ValidDeleteObject(CashSalesInvoiceDetail cashSalesInvoiceDetail, ICashSalesInvoiceService _cashSalesInvoiceService)
 {
     cashSalesInvoiceDetail.Errors.Clear();
     VDeleteObject(cashSalesInvoiceDetail, _cashSalesInvoiceService);
     return(isValid(cashSalesInvoiceDetail));
 }
コード例 #30
0
        public bool isValid(CashSalesInvoiceDetail obj)
        {
            bool isValid = !obj.Errors.Any();

            return(isValid);
        }