Ejemplo n.º 1
0
        public dynamic GetInfo(int Id)
        {
            SalesOrder model = new SalesOrder();

            try
            {
                model = _salesOrderService.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.ContactId,
                Contact = _contactService.GetObjectById(model.ContactId).Name,
                model.SalesDate,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public dynamic GetList(string _search, long nd, int rows, int?page, string sidx, string sord, string filters = "")
        {
            // Construct where statement

            string strWhere = GeneralFunction.ConstructWhere(filters);

            // Get Data
            var query = _deliveryOrderService.GetAll().Where(d => d.IsDeleted == false);

            var list = query as IEnumerable <DeliveryOrder>;

            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.Id,
                        model.Code,
                        model.SalesOrderId,
                        _salesOrderService.GetObjectById(model.SalesOrderId).Code,
                        model.DeliveryDate,
                        model.WarehouseId,
                        _warehouseService.GetObjectById(model.WarehouseId).Name,
                        model.IsConfirmed,
                        model.ConfirmationDate,
                        model.CreatedAt,
                        model.UpdatedAt,
                    }
                }).ToArray()
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public dynamic GetInfo(int Id)
        {
            DeliveryOrder model = new DeliveryOrder();

            try
            {
                model = _deliveryOrderService.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.SalesOrderId,
                SalesOrder = _salesOrderService.GetObjectById(model.SalesOrderId).Code,
                model.DeliveryDate,
                model.WarehouseId,
                Warehouse = _warehouseService.GetObjectById(model.WarehouseId).Name,
                model.Errors
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public SalesInvoice ConfirmObject(SalesInvoice salesInvoice, DateTime ConfirmationDate, ISalesInvoiceDetailService _salesInvoiceDetailService, ISalesOrderService _salesOrderService,
                                          IDeliveryOrderService _deliveryOrderService, IDeliveryOrderDetailService _deliveryOrderDetailService, IReceivableService _receivableService)
        {
            salesInvoice.ConfirmationDate = ConfirmationDate;
            if (_validator.ValidConfirmObject(salesInvoice, _salesInvoiceDetailService, _deliveryOrderService, _deliveryOrderDetailService))
            {
                // confirm details
                // add all amount into amountreceivable
                IList <SalesInvoiceDetail> details = _salesInvoiceDetailService.GetObjectsBySalesInvoiceId(salesInvoice.Id);
                foreach (var detail in details)
                {
                    detail.Errors = new Dictionary <string, string>();
                    _salesInvoiceDetailService.ConfirmObject(detail, ConfirmationDate, _deliveryOrderDetailService);
                }
                salesInvoice = CalculateAmountReceivable(salesInvoice, _salesInvoiceDetailService);

                // confirm object
                // create receivable
                salesInvoice = _repository.ConfirmObject(salesInvoice);
                DeliveryOrder deliveryOrder = _deliveryOrderService.GetObjectById(salesInvoice.DeliveryOrderId);
                _deliveryOrderService.CheckAndSetInvoiceComplete(deliveryOrder, _deliveryOrderDetailService);
                SalesOrder salesOrder = _salesOrderService.GetObjectById(deliveryOrder.SalesOrderId);
                Receivable receivable = _receivableService.CreateObject(salesOrder.ContactId, Constant.ReceivableSource.SalesInvoice, salesInvoice.Id, salesInvoice.AmountReceivable, salesInvoice.DueDate);
            }
            return(salesInvoice);
        }
Ejemplo n.º 5
0
        public DeliveryOrder VSalesOrderHasBeenConfirmed(DeliveryOrder deliveryOrder, ISalesOrderService _salesOrderService)
        {
            SalesOrder salesOrder = _salesOrderService.GetObjectById(deliveryOrder.SalesOrderId);

            if (!salesOrder.IsConfirmed)
            {
                deliveryOrder.Errors.Add("Generic", "Sales order belum terkonfirmasi");
            }
            return(deliveryOrder);
        }
Ejemplo n.º 6
0
        public DeliveryOrder VHasSalesOrder(DeliveryOrder deliveryOrder, ISalesOrderService _salesOrderService)
        {
            SalesOrder salesOrder = _salesOrderService.GetObjectById(deliveryOrder.SalesOrderId);

            if (salesOrder == null)
            {
                deliveryOrder.Errors.Add("SalesOrderId", "Tidak terasosiasi dengan sales order");
            }
            return(deliveryOrder);
        }
Ejemplo n.º 7
0
        public SalesOrderDetail VHasSalesOrder(SalesOrderDetail salesOrderDetail, ISalesOrderService _salesOrderService)
        {
            SalesOrder so = _salesOrderService.GetObjectById(salesOrderDetail.SalesOrderId);

            if (so == null)
            {
                salesOrderDetail.Errors.Add("SalesOrderId", "Tidak terasosiasi dengan sales order");
            }
            return(salesOrderDetail);
        }
Ejemplo n.º 8
0
        public SalesOrderDetail UnsetDeliveryComplete(SalesOrderDetail salesOrderDetail, int Quantity, ISalesOrderService _salesOrderService)
        {
            SalesOrder salesOrder = _salesOrderService.GetObjectById(salesOrderDetail.SalesOrderId);

            _salesOrderService.UnsetDeliveryComplete(salesOrder);

            salesOrderDetail.IsAllDelivered           = false;
            salesOrderDetail.PendingDeliveryQuantity += Quantity;
            _repository.UpdateObject(salesOrderDetail);
            return(salesOrderDetail);
        }
Ejemplo n.º 9
0
 public DeliveryOrder ConfirmObject(DeliveryOrder deliveryOrder, DateTime ConfirmationDate, IDeliveryOrderDetailService _deliveryOrderDetailService,
                                    ISalesOrderService _salesOrderService, ISalesOrderDetailService _salesOrderDetailService,
                                    IStockMutationService _stockMutationService, IItemService _itemService,
                                    IBarringService _barringService, IWarehouseItemService _warehouseItemService)
 {
     deliveryOrder.ConfirmationDate = ConfirmationDate;
     if (_validator.ValidConfirmObject(deliveryOrder, _deliveryOrderDetailService))
     {
         IList <DeliveryOrderDetail> deliveryOrderDetails = _deliveryOrderDetailService.GetObjectsByDeliveryOrderId(deliveryOrder.Id);
         foreach (var detail in deliveryOrderDetails)
         {
             detail.Errors = new Dictionary <string, string>();
             _deliveryOrderDetailService.ConfirmObject(detail, ConfirmationDate, this, _salesOrderDetailService, _stockMutationService, _itemService,
                                                       _barringService, _warehouseItemService);
         }
         _repository.ConfirmObject(deliveryOrder);
         SalesOrder salesOrder = _salesOrderService.GetObjectById(deliveryOrder.SalesOrderId);
         _salesOrderService.CheckAndSetDeliveryComplete(salesOrder, _salesOrderDetailService);
     }
     return(deliveryOrder);
 }