コード例 #1
0
        public dynamic GetInfoDetail(int Id)
        {
            SalesOrderDetail model = new SalesOrderDetail();

            try
            {
                model = _salesOrderDetailService.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.ItemId,
                Item = _itemService.GetObjectById(model.ItemId).Name,
                model.Quantity,
                model.Price,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public dynamic GetListDetail(string _search, long nd, int rows, int?page, string sidx, string sord, int id, string filters = "")
        {
            // Construct where statement

            string strWhere = GeneralFunction.ConstructWhere(filters);

            // Get Data
            var query = _deliveryOrderDetailService.GetObjectsByDeliveryOrderId(id).Where(d => d.IsDeleted == false);

            var list = query as IEnumerable <DeliveryOrderDetail>;

            var pageIndex    = Convert.ToInt32(page) - 1;
            var pageSize     = rows;
            var totalRecords = query.Count();
            var totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            // default last page
            if (totalPages > 0)
            {
                if (!page.HasValue)
                {
                    pageIndex = totalPages - 1;
                    page      = totalPages;
                }
            }

            list = list.Skip(pageIndex * pageSize).Take(pageSize);

            return(Json(new
            {
                total = totalPages,
                page = page,
                records = totalRecords,
                rows = (
                    from model in list
                    select new
                {
                    id = model.Id,
                    cell = new object[] {
                        model.Code,
                        model.SalesOrderDetailId,
                        _salesOrderDetailService.GetObjectById(model.SalesOrderDetailId).Code,
                        model.ItemId,
                        _itemService.GetObjectById(model.ItemId).Name,
                        model.Quantity,
                    }
                }).ToArray()
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public DeliveryOrderDetail ConfirmObject(DeliveryOrderDetail deliveryOrderDetail, DateTime ConfirmationDate, IDeliveryOrderService _deliveryOrderService, ISalesOrderDetailService _salesOrderDetailService,
                                                 IStockMutationService _stockMutationService, IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
        {
            deliveryOrderDetail.ConfirmationDate = ConfirmationDate;
            if (_validator.ValidConfirmObject(deliveryOrderDetail, _deliveryOrderService, this, _salesOrderDetailService, _itemService, _warehouseItemService))
            {
                deliveryOrderDetail = _repository.ConfirmObject(deliveryOrderDetail);

                DeliveryOrder         deliveryOrder  = _deliveryOrderService.GetObjectById(deliveryOrderDetail.DeliveryOrderId);
                WarehouseItem         warehouseItem  = _warehouseItemService.FindOrCreateObject(deliveryOrder.WarehouseId, deliveryOrderDetail.ItemId);
                Item                  item           = _itemService.GetObjectById(deliveryOrderDetail.ItemId);
                IList <StockMutation> stockMutations = _stockMutationService.CreateStockMutationForDeliveryOrder(deliveryOrderDetail, warehouseItem);
                foreach (var stockMutation in stockMutations)
                {
                    //item.PendingDelivery -= deliveryOrderDetail.Quantity;
                    //item.Quantity -= deliveryOrderDetail.Quantity;
                    _stockMutationService.StockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
                }

                SalesOrderDetail salesOrderDetail = _salesOrderDetailService.GetObjectById(deliveryOrderDetail.SalesOrderDetailId);
                _salesOrderDetailService.SetDeliveryComplete(salesOrderDetail, deliveryOrderDetail.Quantity);
            }
            return(deliveryOrderDetail);

            ;
        }
コード例 #4
0
        public DeliveryOrderDetail VSalesOrderDetailHasBeenConfirmed(DeliveryOrderDetail deliveryOrderDetail, ISalesOrderDetailService _salesOrderDetailService)
        {
            SalesOrderDetail salesOrderDetail = _salesOrderDetailService.GetObjectById(deliveryOrderDetail.SalesOrderDetailId);

            if (!salesOrderDetail.IsConfirmed)
            {
                deliveryOrderDetail.Errors.Add("Generic", "Sales Order Detail belum dikonfirmasi");
            }
            return(deliveryOrderDetail);
        }
コード例 #5
0
        public DeliveryOrderDetail VHasSalesOrderDetail(DeliveryOrderDetail deliveryOrderDetail, ISalesOrderDetailService _salesOrderDetailService)
        {
            SalesOrderDetail salesOrderDetail = _salesOrderDetailService.GetObjectById(deliveryOrderDetail.SalesOrderDetailId);

            if (salesOrderDetail == null)
            {
                deliveryOrderDetail.Errors.Add("SalesOrderDetail", "Tidak boleh tidak ada");
            }
            return(deliveryOrderDetail);
        }
コード例 #6
0
        public DeliveryOrderDetail VDeliveryOrderAndSalesOrderDetailHaveTheSameSalesOrder(DeliveryOrderDetail deliveryOrderDetail, IDeliveryOrderService _purchaseReceivalService, ISalesOrderDetailService _salesOrderDetailService)
        {
            DeliveryOrder    deliveryOrder    = _purchaseReceivalService.GetObjectById(deliveryOrderDetail.DeliveryOrderId);
            SalesOrderDetail salesOrderDetail = _salesOrderDetailService.GetObjectById(deliveryOrderDetail.SalesOrderDetailId);

            if (deliveryOrder.SalesOrderId != salesOrderDetail.SalesOrderId)
            {
                deliveryOrderDetail.Errors.Add("Generic", "Sales order dari sales order detail dan delivery order tidak sama");
                return(deliveryOrderDetail);
            }
            return(deliveryOrderDetail);
        }
コード例 #7
0
 public SalesInvoiceDetail UpdateObject(SalesInvoiceDetail salesInvoiceDetail, ISalesInvoiceService _salesInvoiceService,
                                        ISalesOrderDetailService _salesOrderDetailService, IDeliveryOrderDetailService _deliveryOrderDetailService)
 {
     if (_validator.ValidUpdateObject(salesInvoiceDetail, _salesInvoiceService, this, _deliveryOrderDetailService))
     {
         DeliveryOrderDetail deliveryOrderDetail = _deliveryOrderDetailService.GetObjectById(salesInvoiceDetail.DeliveryOrderDetailId);
         SalesOrderDetail    salesOrderDetail    = _salesOrderDetailService.GetObjectById(deliveryOrderDetail.SalesOrderDetailId);
         salesInvoiceDetail.Amount = salesInvoiceDetail.Quantity * salesOrderDetail.Price;
         _repository.UpdateObject(salesInvoiceDetail);
         SalesInvoice salesInvoice = _salesInvoiceService.GetObjectById(salesInvoiceDetail.SalesInvoiceId);
         _salesInvoiceService.CalculateAmountReceivable(salesInvoice, this);
     }
     return(salesInvoiceDetail);
 }
コード例 #8
0
 public SalesInvoiceDetail CreateObject(SalesInvoiceDetail salesInvoiceDetail, ISalesInvoiceService _salesInvoiceService,
                                        ISalesOrderDetailService _salesOrderDetailService, IDeliveryOrderDetailService _deliveryOrderDetailService)
 {
     salesInvoiceDetail.Errors = new Dictionary <String, String>();
     if (_validator.ValidCreateObject(salesInvoiceDetail, _salesInvoiceService, this, _deliveryOrderDetailService))
     {
         DeliveryOrderDetail deliveryOrderDetail = _deliveryOrderDetailService.GetObjectById(salesInvoiceDetail.DeliveryOrderDetailId);
         SalesOrderDetail    salesOrderDetail    = _salesOrderDetailService.GetObjectById(deliveryOrderDetail.SalesOrderDetailId);
         salesInvoiceDetail.Amount = salesInvoiceDetail.Quantity * salesOrderDetail.Price;
         salesInvoiceDetail        = _repository.CreateObject(salesInvoiceDetail);
         SalesInvoice salesInvoice = _salesInvoiceService.GetObjectById(salesInvoiceDetail.SalesInvoiceId);
         _salesInvoiceService.CalculateAmountReceivable(salesInvoice, this);
     }
     return(salesInvoiceDetail);
 }
コード例 #9
0
        public DeliveryOrderDetail VQuantityOfDeliveryOrderDetailsIsLessThanOrEqualSalesOrderDetail(DeliveryOrderDetail deliveryOrderDetail,
                                                                                                    IDeliveryOrderDetailService _deliveryOrderDetailService, ISalesOrderDetailService _salesOrderDetailService)
        {
            SalesOrderDetail            salesOrderDetail = _salesOrderDetailService.GetObjectById(deliveryOrderDetail.SalesOrderDetailId);
            IList <DeliveryOrderDetail> details          = _deliveryOrderDetailService.GetObjectsBySalesOrderDetailId(deliveryOrderDetail.SalesOrderDetailId);

            int totalReceivalQuantity = 0;

            foreach (var detail in details)
            {
                totalReceivalQuantity += detail.Quantity;
            }
            if (totalReceivalQuantity > salesOrderDetail.Quantity)
            {
                int maxquantity = totalReceivalQuantity - deliveryOrderDetail.Quantity;
                deliveryOrderDetail.Errors.Add("Generic", "Hanya boleh maksimum " + maxquantity);
            }
            return(deliveryOrderDetail);
        }
コード例 #10
0
 public DeliveryOrderDetail UnconfirmObject(DeliveryOrderDetail deliveryOrderDetail, IDeliveryOrderService _deliveryOrderService,
                                            ISalesOrderService _salesOrderService, ISalesOrderDetailService _salesOrderDetailService,
                                            ISalesInvoiceDetailService _salesInvoiceDetailService, IStockMutationService _stockMutationService,
                                            IItemService _itemService, IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     if (_validator.ValidUnconfirmObject(deliveryOrderDetail, _salesInvoiceDetailService))
     {
         deliveryOrderDetail = _repository.UnconfirmObject(deliveryOrderDetail);
         DeliveryOrder         deliveryOrder  = _deliveryOrderService.GetObjectById(deliveryOrderDetail.DeliveryOrderId);
         WarehouseItem         warehouseItem  = _warehouseItemService.FindOrCreateObject(deliveryOrder.WarehouseId, deliveryOrderDetail.ItemId);
         Item                  item           = _itemService.GetObjectById(deliveryOrderDetail.ItemId);
         IList <StockMutation> stockMutations = _stockMutationService.SoftDeleteStockMutationForDeliveryOrder(deliveryOrderDetail, warehouseItem);
         foreach (var stockMutation in stockMutations)
         {
             //item.PendingDelivery += deliveryOrderDetail.Quantity;
             //item.Quantity += deliveryOrderDetail.Quantity;
             _stockMutationService.ReverseStockMutateObject(stockMutation, _itemService, _barringService, _warehouseItemService);
         }
         SalesOrderDetail salesOrderDetail = _salesOrderDetailService.GetObjectById(deliveryOrderDetail.SalesOrderDetailId);
         _salesOrderDetailService.UnsetDeliveryComplete(salesOrderDetail, deliveryOrderDetail.Quantity, _salesOrderService);
     }
     return(deliveryOrderDetail);
 }