public static TransactionFormViewModel Create(EnumTransactionStatus enumTransactionStatus, ITTransRepository transRepository, IMWarehouseRepository mWarehouseRepository, IMSupplierRepository mSupplierRepository, IMUnitTypeRepository mUnitTypeRepository, IMJobTypeRepository mJobTypeRepository)
        {
            TransactionFormViewModel viewModel = new TransactionFormViewModel();
            TTrans trans = SetNewTrans(enumTransactionStatus);

            viewModel.Trans = trans;
            Helper.CommonHelper.SetViewModelByStatus(viewModel, enumTransactionStatus);

            viewModel.TransFactur   = trans.TransFactur;
            viewModel.TransDate     = trans.TransDate;
            viewModel.TransId       = trans.Id;
            viewModel.TransStatus   = trans.TransStatus;
            viewModel.WarehouseId   = trans.WarehouseId;
            viewModel.WarehouseIdTo = trans.WarehouseIdTo;
            viewModel.UnitTypeId    = trans.UnitTypeId;
            viewModel.JobTypeId     = trans.JobTypeId;
            viewModel.TransDesc     = trans.TransDesc;

            IList <MWarehouse> list       = mWarehouseRepository.GetAll();
            MWarehouse         mWarehouse = new MWarehouse();

            mWarehouse.WarehouseName = "-Pilih Gudang-";
            list.Insert(0, mWarehouse);
            viewModel.WarehouseList   = new SelectList(list, "Id", "WarehouseName");
            viewModel.WarehouseToList = new SelectList(list, "Id", "WarehouseName");

            IList <MSupplier> listSupplier = mSupplierRepository.GetAll();
            MSupplier         mSupplier    = new MSupplier();

            mSupplier.SupplierName = "-Pilih Supplier-";
            listSupplier.Insert(0, mSupplier);
            viewModel.SupplierList = new SelectList(listSupplier, "Id", "SupplierName");

            IList <MUnitType> listUnitType = mUnitTypeRepository.GetAll();
            MUnitType         mUnitType    = new MUnitType();

            mUnitType.UnitTypeName = "-Pilih Unit-";
            listUnitType.Insert(0, mUnitType);
            viewModel.UnitTypeList = new SelectList(listUnitType, "Id", "UnitTypeName");

            IList <MJobType> listJobType = mJobTypeRepository.GetAll();
            MJobType         mJobType    = new MJobType();

            mJobType.JobTypeName = "-Pilih Jenis Pekerjaan-";
            listJobType.Insert(0, mJobType);
            viewModel.JobTypeList = new SelectList(listJobType, "Id", "JobTypeName");

            //fill payment method
            var values = from EnumPaymentMethod e in Enum.GetValues(typeof(EnumPaymentMethod))
                         select new { ID = e, Name = e.ToString() };

            viewModel.PaymentMethodList = new SelectList(values, "Id", "Name");

            //viewModel.ViewWarehouseTo = false;
            //viewModel.ViewSupplier = false;
            //viewModel.ViewDate = false;
            //viewModel.ViewFactur = false;

            return(viewModel);
        }
Beispiel #2
0
        private TransactionFormViewModel SetViewModelByStatus(EnumTransactionStatus enumTransactionStatus)
        {
            TransactionFormViewModel viewModel = TransactionFormViewModel.CreateTransactionFormViewModel(enumTransactionStatus, _tTransRepository, _mWarehouseRepository, _mSupplierRepository, _mCustomerRepository);

            ViewData["CurrentItem"] = viewModel.Title;
            //ViewData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.NotSaved;

            return(viewModel);
        }
Beispiel #3
0
        private static TTrans SetNewTrans(EnumTransactionStatus enumTransactionStatus)
        {
            TTrans trans = new TTrans();

            trans.TransDate   = DateTime.Today;
            trans.TransFactur = Helper.CommonHelper.GetFacturNo(enumTransactionStatus);
            trans.SetAssignedIdTo(Guid.NewGuid().ToString());
            trans.TransStatus = enumTransactionStatus.ToString();
            return(trans);
        }
Beispiel #4
0
        public IList <TTransDet> GetListByDate(DateTime dateFrom, DateTime dateTo, EnumTransactionStatus transactionStatus)
        {
            StringBuilder sql = new StringBuilder();

            sql.AppendLine(@"   select det
                                from TTransDet as det
                                    left outer join det.TransId trans 
                                        where trans.TransStatus = :TransStatus and trans.TransDate between :dateFrom and :dateTo ");
            IQuery q = Session.CreateQuery(sql.ToString());

            q.SetString("TransStatus", transactionStatus.ToString());
            q.SetDateTime("dateFrom", dateFrom);
            q.SetDateTime("dateTo", dateTo);
            return(q.List <TTransDet>());
        }
Beispiel #5
0
        private ActionResult GetTotalQty(string itemId, string warehouseId, EnumTransactionStatus transactionStatus)
        {
            if (!string.IsNullOrEmpty(itemId) && !string.IsNullOrEmpty(warehouseId))
            {
                MItem      mItem     = _mItemRepository.Get(itemId);
                MWarehouse warehouse = _mWarehouseRepository.Get(warehouseId);
                decimal?   totalUsed = _tTransDetRepository.GetTotalUsed(mItem, warehouse, null, null, transactionStatus.ToString());
                if (totalUsed.HasValue)
                {
                    return(Content(totalUsed.Value.ToString(Helper.CommonHelper.NumberFormat)));
                }
            }

            return(Content("0"));
        }
Beispiel #6
0
        internal static void GetIsCalculateStock(EnumTransactionStatus status, out bool addStock, out bool calculateStock)
        {
            addStock       = true;
            calculateStock = false;
            switch (status)
            {
            case EnumTransactionStatus.Received:
                addStock       = true;
                calculateStock = true;
                break;

            case EnumTransactionStatus.Adjusment:
                addStock       = true;
                calculateStock = true;
                break;

            case EnumTransactionStatus.ReturPurchase:
                addStock       = false;
                calculateStock = true;
                break;

            case EnumTransactionStatus.ReturSales:
                addStock       = true;
                calculateStock = true;
                break;

            case EnumTransactionStatus.Sales:
                addStock       = false;
                calculateStock = true;
                break;

            case EnumTransactionStatus.Using:
                addStock       = false;
                calculateStock = true;
                break;

            case EnumTransactionStatus.Mutation:
                addStock       = false;
                calculateStock = true;
                break;

            case EnumTransactionStatus.Purchase:
                addStock       = true;
                calculateStock = true;
                break;
            }
        }
        public IList <TTransDet> GetListByRoomDateOut(EnumTransactionStatus TransStatus, DateTime?dateFrom, DateTime?dateTo)
        {
            StringBuilder sql = new StringBuilder();

            sql.AppendLine(@"   select det
                                from TTransDet as det, TTransRoom as troom
                                    where det.TransId = troom.TransId  
                                        and troom.RoomOutDate between :dateFrom and :dateTo 
                                     ");

            IQuery q = Session.CreateQuery(sql.ToString());

            //q.SetString("TransStatus", TransStatus.ToString());
            q.SetDateTime("dateFrom", dateFrom.Value);
            q.SetDateTime("dateTo", dateTo.Value);
            return(q.List <TTransDet>());
        }
Beispiel #8
0
        public static string GetFacturNo(EnumTransactionStatus transactionStatus, bool automatedIncrease)
        {
            TReference refer = GetReference((EnumReferenceType)Enum.Parse(typeof(EnumReferenceType), transactionStatus.ToString()));
            decimal    no    = Convert.ToDecimal(refer.ReferenceValue) + 1;

            //reset factur no to 1 every month
            //if (DateTime.Today.Day == 1 && refer.ModifiedDate < DateTime.Today)
            if (refer.ModifiedDate < DateTime.Today)
            {
                no = 1;
            }

            refer.ReferenceValue = no.ToString();
            if (automatedIncrease)
            {
                ITReferenceRepository referenceRepository = new TReferenceRepository();
                refer.ModifiedDate = DateTime.Now;
                referenceRepository.Update(refer);
                referenceRepository.DbContext.CommitChanges();
            }

            string tipeTrans = string.Empty;

            char[] charTransArray = transactionStatus.ToString().ToCharArray();
            char   charTrans;

            for (int i = 0; i < transactionStatus.ToString().Length; i++)
            {
                charTrans = charTransArray[i];
                if (char.IsUpper(transactionStatus.ToString(), i))
                {
                    tipeTrans += transactionStatus.ToString().Substring(i, 1);
                }
            }

            StringBuilder result = new StringBuilder();

            result.Append(CONST_FACTURFORMAT);
            result.Replace("[TRANS]", tipeTrans);
            result.Replace("[XXX]", GetFactur(5, no));
            result.Replace("[DAY]", DateTime.Today.Day.ToString());
            result.Replace("[MONTH]", DateTime.Today.ToString("MMM").ToUpper());
            result.Replace("[YEAR]", DateTime.Today.Year.ToString());
            return(result.ToString());
        }
Beispiel #9
0
        private ReportDataSource ConvertToReportDatasource(IList <TTransDet> dets, EnumTransactionStatus transStatus)
        {
            var list = from det in dets
                       select new
            {
                det.TransDetNo,
                det.TransDetQty,
                det.TransDetDesc,
                det.TransDetTotal,
                det.TransDetPrice,
                det.TransDetDisc,
                ItemId = det.ItemId.Id,
                det.ItemId.ItemName,
                SupplierName = det.TransId.TransBy,
                det.TransId.TransFactur,
                det.TransId.TransDate,
                WarehouseId = det.TransId.WarehouseId.Id,
                det.TransId.WarehouseId.WarehouseName,
                WarehouseToName =
                    det.TransId.WarehouseIdTo != null ? det.TransId.WarehouseIdTo.WarehouseName : null,
                det.TransId.TransStatus,
                det.TransId.TransDesc,
                det.TransId.TransSubTotal,
                det.TransId.TransPaymentMethod,
                TransId           = det.TransId.Id,
                ViewWarehouse     = SetView(det.TransId.TransStatus, EnumViewTrans.ViewWarehouse),
                ViewWarehouseTo   = SetView(det.TransId.TransStatus, EnumViewTrans.ViewWarehouseTo),
                ViewSupplier      = SetView(det.TransId.TransStatus, EnumViewTrans.ViewSupplier),
                ViewDate          = SetView(det.TransId.TransStatus, EnumViewTrans.ViewDate),
                ViewFactur        = SetView(det.TransId.TransStatus, EnumViewTrans.ViewFactur),
                ViewPrice         = SetView(det.TransId.TransStatus, EnumViewTrans.ViewPrice),
                ViewPaymentMethod =
                    SetView(det.TransId.TransStatus, EnumViewTrans.ViewPaymentMethod),
                TransName = Helper.CommonHelper.GetStringValue(transStatus)
            }
            ;

            ReportDataSource reportDataSource = new ReportDataSource("TransTotalViewModel", list.ToList());

            return(reportDataSource);
        }
Beispiel #10
0
        public static string GetFacturNo(EnumTransactionStatus transactionStatus, bool automatedIncrease)
        {
            TReference refer = GetReference((EnumReferenceType)Enum.Parse(typeof(EnumReferenceType), transactionStatus.ToString()));
            decimal    no    = Convert.ToDecimal(refer.ReferenceValue) + 1;

            refer.ReferenceValue = no.ToString();
            if (automatedIncrease)
            {
                ITReferenceRepository referenceRepository = new TReferenceRepository();
                referenceRepository.Update(refer);
                referenceRepository.DbContext.CommitChanges();
            }

            string tipeTrans = string.Empty;

            char[] charTransArray = transactionStatus.ToString().ToCharArray();
            char   charTrans;

            for (int i = 0; i < transactionStatus.ToString().Length; i++)
            {
                charTrans = charTransArray[i];
                if (char.IsUpper(transactionStatus.ToString(), i))
                {
                    tipeTrans += transactionStatus.ToString().Substring(i, 1);
                }
            }
            string        formatFactur = "GRAHA/[TRANS]/[XXX]/[MONTH]/[YEAR]";
            StringBuilder result       = new StringBuilder();

            result.Append(formatFactur);
            result.Replace("[TRANS]", tipeTrans);
            result.Replace("[XXX]", GetFactur(5, no));
            result.Replace("[MONTH]", DateTime.Today.ToString("MMM").ToUpper());
            result.Replace("[YEAR]", DateTime.Now.Year.ToString());
            return(result.ToString());
        }
Beispiel #11
0
        public ActionResult Report(EnumReports reports, ReportParamViewModel viewModel, FormCollection formCollection)
        {
            bool   Success = true;
            string Message = "redirect";

            try
            {
                EnumTransactionStatus stat =
                    (EnumTransactionStatus)Enum.Parse(typeof(EnumTransactionStatus), formCollection["TransStatus"]);
                ReportDataSource[] repCol = new ReportDataSource[1];
                switch (reports)
                {
                case EnumReports.RptBrand:
                    repCol[0] = GetBrand();
                    break;

                case EnumReports.RptStockCard:
                    repCol[0] = GetStockCard(viewModel.DateFrom, viewModel.DateTo, viewModel.ItemId, viewModel.WarehouseId);
                    break;

                case EnumReports.RptStockItem:
                    repCol[0] = GetStockItem(viewModel.ItemId, viewModel.WarehouseId);
                    break;

                case EnumReports.RptAnalyzeBudgetDetail:
                    repCol[0] = GetTransDetForBudget(viewModel.ItemId, viewModel.WarehouseId);
                    break;

                case EnumReports.RptTransDetail:
                    repCol[0] = GetTransTotal(viewModel.DateFrom, viewModel.DateTo, viewModel.WarehouseId, stat);
                    break;

                case EnumReports.RptTransDetailByTransBy:
                    repCol[0] = GetTransTotal(viewModel.DateFrom, viewModel.DateTo, viewModel.WarehouseId, viewModel.SupplierId, stat);
                    break;

                case EnumReports.RptLRDetailSales:
                    repCol[0] = GetTransTotalAndRef(viewModel.DateFrom, viewModel.DateTo, null, viewModel.CustomerId, stat);
                    break;

                case EnumReports.RptMostItemSales:
                    repCol[0] = GetTransDetail(viewModel.DateFrom, viewModel.DateTo, viewModel.WarehouseId, stat);
                    break;
                }
                Session["ReportData"] = repCol;
            }
            catch (Exception ex)
            {
                Success = false;
                Message = "Error :\n " + ex.GetBaseException().Message;
            }


            var e = new
            {
                Success,
                Message,
                UrlReport = string.Format("{0}", reports.ToString())
            };

            return(Json(e, JsonRequestBehavior.AllowGet));
        }
Beispiel #12
0
        private ReportDataSource GetTransTotal(DateTime?dateFrom, DateTime?dateTo, string supplierId, string warehouseId, EnumTransactionStatus transStatus)
        {
            Check.Require(transStatus != EnumTransactionStatus.None, "transStatus may not be None");
            IList <TTransDet> dets = _tTransDetRepository.GetByDateWarehouseTransBy(dateFrom, dateTo, supplierId, warehouseId, transStatus.ToString());

            return(ConvertToReportDatasource(dets, transStatus));
        }
Beispiel #13
0
 public static string GetFacturNo(EnumTransactionStatus transactionStatus)
 {
     return(GetFacturNo(transactionStatus, true));
 }
Beispiel #14
0
        //private ReportDataSource GetTransDetByDate(DateTime? dateFrom, DateTime? dateTo)
        //{
        //    IList<TTransDet> dets = _tTransDetRepository.GetListByDate(EnumTransactionStatus.Service, dateFrom, dateTo);

        //    var list = from det in dets
        //               select new
        //               {
        //                   EmployeeId = det.EmployeeId.Id,
        //                   EmployeeName = det.EmployeeId.PersonId.PersonName,
        //                   det.TransDetCommissionService,
        //                   det.TransId.TransFactur,
        //                   det.TransId.TransDate,
        //                   det.TransDetQty,
        //                   det.TransDetTotal
        //               }
        //    ;

        //    ReportDataSource reportDataSource = new ReportDataSource("TransDetViewModel", list.ToList());
        //    return reportDataSource;
        //}

        //  private ReportDataSource GetShiftViewModel(TShift s)
        //  {
        //      IList<TShift> listShift = new List<TShift>();
        //      listShift.Add(s);
        //      var listRoom = from shift in listShift
        //                     select new
        //                     {
        //                         shift.ShiftNo,
        //                         shift.ShiftDate,
        //                         shift.ShiftDateFrom,
        //                         shift.ShiftDateTo
        //                     }
        //;
        //      ReportDataSource reportDataSource = new ReportDataSource("ShiftViewModel", listRoom.ToList());
        //      return reportDataSource;
        //  }

        private ReportDataSource GetTransTotal(DateTime?dateFrom, DateTime?dateTo, string warehouseId, EnumTransactionStatus transStatus)
        {
            return(GetTransTotal(dateFrom, dateTo, string.Empty, warehouseId, transStatus));
            //Check.Require(transStatus != EnumTransactionStatus.None, "transStatus may not be None");
            //IList<TTransDet> dets;
            //MWarehouse warehouse = null;
            //if (!string.IsNullOrEmpty(warehouseId))
            //    warehouse = _mWarehouseRepository.Get(warehouseId);
            //dets = _tTransDetRepository.GetByDateWarehouse(dateFrom, dateTo, warehouse, transStatus.ToString());

            //var list = from det in dets
            //           select new
            //           {
            //               det.TransDetNo,
            //               det.TransDetQty,
            //               det.TransDetDesc,
            //               det.TransDetTotal,
            //               det.TransDetPrice,
            //               det.TransDetDisc,
            //               ItemId = det.ItemId.Id,
            //               det.ItemId.ItemName,
            //               SupplierName = det.TransId.TransBy,
            //               det.TransId.TransFactur,
            //               det.TransId.TransDate,
            //               WarehouseId = det.TransId.WarehouseId.Id,
            //               det.TransId.WarehouseId.WarehouseName,
            //               WarehouseToName =
            //    det.TransId.WarehouseIdTo != null ? det.TransId.WarehouseIdTo.WarehouseName : null,
            //               det.TransId.TransStatus,
            //               det.TransId.TransDesc,
            //               det.TransId.TransSubTotal,
            //               det.TransId.TransPaymentMethod,
            //               TransId = det.TransId.Id,
            //               ViewWarehouse = SetView(det.TransId.TransStatus, EnumViewTrans.ViewWarehouse),
            //               ViewWarehouseTo = SetView(det.TransId.TransStatus, EnumViewTrans.ViewWarehouseTo),
            //               ViewSupplier = SetView(det.TransId.TransStatus, EnumViewTrans.ViewSupplier),
            //               ViewDate = SetView(det.TransId.TransStatus, EnumViewTrans.ViewDate),
            //               ViewFactur = SetView(det.TransId.TransStatus, EnumViewTrans.ViewFactur),
            //               ViewPrice = SetView(det.TransId.TransStatus, EnumViewTrans.ViewPrice),
            //               ViewPaymentMethod =
            //    SetView(det.TransId.TransStatus, EnumViewTrans.ViewPaymentMethod),
            //               TransName = Helper.CommonHelper.GetStringValue(transStatus)
            //           }
            //;

            //ReportDataSource reportDataSource = new ReportDataSource("TransTotalViewModel", list.ToList());
            //return reportDataSource;
        }
Beispiel #15
0
        private ReportDataSource GetTransTotalAndRef(DateTime?dateFrom, DateTime?dateTo, string supplierId, string warehouseId, EnumTransactionStatus transStatus)
        {
            Check.Require(transStatus != EnumTransactionStatus.None, "transStatus may not be None");
            IList dets = _tTransDetRepository.GetRefStockByDateWarehouseTransBy(dateFrom, dateTo, supplierId, warehouseId, transStatus.ToString());

            Array arr;
            IList <TransDetWithRef> listResult = new List <TransDetWithRef>();
            TransDetWithRef         detWithRef = new TransDetWithRef();

            for (int i = 0; i < dets.Count; i++)
            {
                arr = dets[i] as Array;
                if (arr != null)
                {
                    detWithRef             = new TransDetWithRef();
                    detWithRef.TransDet    = arr.GetValue(0) as TTransDet;
                    detWithRef.StockPrice  = arr.GetValue(1) as decimal?;
                    detWithRef.StockRefQty = arr.GetValue(2) as decimal?;
                    listResult.Add(detWithRef);
                }
            }

            string TransName = Helper.CommonHelper.GetStringValue(transStatus);
            var    list      = from det in listResult
                               select new
            {
                det.TransDet.Id,
                det.TransDet.TransDetNo,
                det.TransDet.TransDetQty,
                det.TransDet.TransDetDesc,
                det.TransDet.TransDetTotal,
                det.TransDet.TransDetPrice,
                det.TransDet.TransDetDisc,
                ItemId = det.TransDet.ItemId.Id,
                det.TransDet.ItemId.ItemName,
                SupplierName = det.TransDet.TransId.TransBy,
                CustomerName = det.TransDet.TransId.TransBy,
                det.TransDet.TransId.TransFactur,
                det.TransDet.TransId.TransDate,
                WarehouseId = det.TransDet.TransId.WarehouseId.Id,
                det.TransDet.TransId.WarehouseId.WarehouseName,
                WarehouseToName =
                    det.TransDet.TransId.WarehouseIdTo != null ? det.TransDet.TransId.WarehouseIdTo.WarehouseName : null,
                det.TransDet.TransId.TransStatus,
                det.TransDet.TransId.TransDesc,
                det.TransDet.TransId.TransSubTotal,
                det.TransDet.TransId.TransPaymentMethod,
                TransId           = det.TransDet.TransId.Id,
                ViewWarehouse     = SetView(det.TransDet.TransId.TransStatus, EnumViewTrans.ViewWarehouse),
                ViewWarehouseTo   = SetView(det.TransDet.TransId.TransStatus, EnumViewTrans.ViewWarehouseTo),
                ViewSupplier      = SetView(det.TransDet.TransId.TransStatus, EnumViewTrans.ViewSupplier),
                ViewDate          = SetView(det.TransDet.TransId.TransStatus, EnumViewTrans.ViewDate),
                ViewFactur        = SetView(det.TransDet.TransId.TransStatus, EnumViewTrans.ViewFactur),
                ViewPrice         = SetView(det.TransDet.TransId.TransStatus, EnumViewTrans.ViewPrice),
                ViewPaymentMethod =
                    SetView(det.TransDet.TransId.TransStatus, EnumViewTrans.ViewPaymentMethod),
                TransName,
                StockRefPrice = det.StockPrice,
                det.StockRefQty
            }
            ;

            ReportDataSource reportDataSource = new ReportDataSource("TransTotalViewModel", list.ToList());

            return(reportDataSource);
        }
Beispiel #16
0
        public IList <TTransDet> GetByDateWarehouse(DateTime?dateFrom, DateTime?dateTo, string warehouseId, EnumTransactionStatus transStatus)
        {
            StringBuilder sql = new StringBuilder();

            sql.AppendLine(
                @"   select det
                        from TTransDet as det
                            left outer join det.TransId trans
                        where det.DataStatus <> :dataStatus 
                            and trans.TransStatus = :TransStatus ");
            if (dateFrom.HasValue && dateTo.HasValue)
            {
                sql.AppendLine(@"   and trans.TransDate between :dateFrom and :dateTo");
            }
            if (!string.IsNullOrEmpty(warehouseId))
            {
                sql.AppendLine(@"   and trans.WarehouseId.Id = :warehouseId");
            }

            sql.AppendLine(@"   order by trans.TransDate, trans.TransFactur, det.TransDetNo ");

            IQuery q = Session.CreateQuery(sql.ToString());

            q.SetString("dataStatus", EnumDataStatus.Deleted.ToString());
            q.SetString("TransStatus", transStatus.ToString());
            if (dateFrom.HasValue && dateTo.HasValue)
            {
                q.SetDateTime("dateFrom", dateFrom.Value);
                q.SetDateTime("dateTo", dateTo.Value);
            }

            if (!string.IsNullOrEmpty(warehouseId))
            {
                q.SetString("warehouseId", warehouseId);
            }
            return(q.List <TTransDet>());
        }
Beispiel #17
0
        public static TransactionFormViewModel CreateTransactionFormViewModel(EnumTransactionStatus enumTransactionStatus, ITTransRepository transRepository, IMWarehouseRepository mWarehouseRepository, IMSupplierRepository mSupplierRepository, IMCustomerRepository mCustomerRepository)
        {
            TransactionFormViewModel viewModel = new TransactionFormViewModel();

            viewModel.Trans = SetNewTrans(enumTransactionStatus);

            switch (enumTransactionStatus)
            {
            case EnumTransactionStatus.PurchaseOrder:
                viewModel.ViewWarehouse     = true;
                viewModel.Title             = "Order Pembelian";
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewTransBy       = true;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = true;
                viewModel.ViewPaymentMethod = false;
                viewModel.TransByText       = "Supplier :";
                viewModel.TransByList       = GetSupplierList();
                viewModel.UsePrice          = EnumPrice.Purchase;
                break;

            case EnumTransactionStatus.Purchase:
                viewModel.ViewWarehouse     = true;
                viewModel.Title             = "Pembelian";
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewTransBy       = true;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = true;
                viewModel.ViewPaymentMethod = true;
                viewModel.TransByText       = "Supplier :";
                viewModel.TransByList       = GetSupplierList();
                viewModel.UsePrice          = EnumPrice.Purchase;
                break;

            case EnumTransactionStatus.ReturPurchase:
                viewModel.ViewWarehouse     = true;
                viewModel.Title             = "Retur Pembelian";
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewTransBy       = true;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = true;
                viewModel.ViewPaymentMethod = true;
                viewModel.TransByText       = "Supplier :";
                viewModel.TransByList       = GetSupplierList();
                viewModel.UsePrice          = EnumPrice.Purchase;
                break;

            case EnumTransactionStatus.Sales:
                viewModel.ViewWarehouse     = true;
                viewModel.Title             = "Penjualan";
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewTransBy       = true;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = true;
                viewModel.ViewPaymentMethod = true;
                viewModel.TransByText       = "Konsumen :";
                viewModel.TransByList       = GetCustomerList();
                viewModel.UsePrice          = EnumPrice.Sale;
                break;

            case EnumTransactionStatus.ReturSales:
                viewModel.ViewWarehouse     = true;
                viewModel.Title             = "Retur Penjualan";
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewTransBy       = true;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = true;
                viewModel.ViewPaymentMethod = true;
                viewModel.TransByText       = "Konsumen :";
                viewModel.TransByList       = GetCustomerList();
                viewModel.UsePrice          = EnumPrice.Sale;
                break;

            case EnumTransactionStatus.Using:
                viewModel.ViewWarehouse     = true;
                viewModel.Title             = "Pemakaian Material";
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewTransBy       = false;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = false;
                viewModel.ViewPaymentMethod = false;
                viewModel.UsePrice          = EnumPrice.None;
                break;

            case EnumTransactionStatus.Mutation:
                viewModel.ViewWarehouse     = true;
                viewModel.Title             = "Mutasi Stok";
                viewModel.ViewWarehouseTo   = true;
                viewModel.ViewTransBy       = false;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = false;
                viewModel.ViewPaymentMethod = false;
                viewModel.UsePrice          = EnumPrice.None;
                break;

            case EnumTransactionStatus.Adjusment:
                viewModel.ViewWarehouse     = true;
                viewModel.Title             = "Penyesuaian Stok";
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewTransBy       = false;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = false;
                viewModel.ViewPaymentMethod = false;
                viewModel.UsePrice          = EnumPrice.None;
                break;

            case EnumTransactionStatus.Received:
                viewModel.ViewWarehouse     = true;
                viewModel.Title             = "Penerimaan Stok";
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewTransBy       = true;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPaymentMethod = false;
                viewModel.UsePrice          = EnumPrice.None;
                break;

            case EnumTransactionStatus.Budgeting:
                viewModel.ViewWarehouse     = true;
                viewModel.Title             = "Rencana Anggaran Belanja";
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewTransBy       = false;
                viewModel.ViewDate          = false;
                viewModel.ViewFactur        = false;
                viewModel.ViewPrice         = true;
                viewModel.ViewPaymentMethod = false;
                viewModel.UsePrice          = EnumPrice.Purchase;
                break;
            }

            //get if not add stock
            bool calculateStock = false;
            bool addStock       = false;

            GetIsCalculateStock(enumTransactionStatus, out addStock, out calculateStock);
            viewModel.IsAddStock = addStock;

            //fill warehouse if it visible
            if (viewModel.ViewWarehouse || viewModel.ViewWarehouseTo)
            {
                IList <MWarehouse> list       = mWarehouseRepository.GetAll();
                MWarehouse         mWarehouse = new MWarehouse();
                mWarehouse.WarehouseName = "-Pilih Gudang-";
                list.Insert(0, mWarehouse);
                viewModel.WarehouseList = new SelectList(list, "Id", "WarehouseName");
                if (viewModel.ViewWarehouseTo)
                {
                    viewModel.WarehouseToList = new SelectList(list, "Id", "WarehouseName");
                }
            }


            //IList<MSupplier> listSupplier = mSupplierRepository.GetAll();
            //MSupplier mSupplier = new MSupplier();
            //mSupplier.SupplierName = "-Pilih Supplier-";
            //listSupplier.Insert(0, mSupplier);
            //viewModel.SupplierList = new SelectList(listSupplier, "Id", "SupplierName");

            //var listCustomer = mCustomerRepository.GetAll();
            //MCustomer mCustomer = new MCustomer();
            ////mCustomer.SupplierName = "-Pilih Supplier-";
            //listCustomer.Insert(0, mCustomer);
            //var custs = from cust in listCustomer
            //            select new { Id = cust.Id, Name =cust.PersonId.PersonName };
            //viewModel.TransByList = new SelectList(custs, "Id", "Name");

            //fill payment method
            var values = from EnumPaymentMethod e in Enum.GetValues(typeof(EnumPaymentMethod))
                         select new { ID = e, Name = e.ToString() };

            viewModel.PaymentMethodList = new SelectList(values, "Id", "Name");

            //viewModel.MinusStock = GetIsCalculateStock(sta)
            return(viewModel);
        }
Beispiel #18
0
        private ActionResult SaveTransaction(TTrans Trans, FormCollection formCollection)
        {
            _tTransRepository.DbContext.BeginTransaction();
            if (Trans == null)
            {
                Trans = new TTrans();
            }
            Trans.SetAssignedIdTo(formCollection["Trans.Id"]);
            Trans.WarehouseId = _mWarehouseRepository.Get(formCollection["Trans.WarehouseId"]);
            if (!string.IsNullOrEmpty(formCollection["Trans.WarehouseIdTo"]))
            {
                Trans.WarehouseIdTo = _mWarehouseRepository.Get(formCollection["Trans.WarehouseIdTo"]);
            }
            Trans.CreatedDate = DateTime.Now;
            Trans.CreatedBy   = User.Identity.Name;
            Trans.DataStatus  = Enums.EnumDataStatus.New.ToString();

            Trans.TransDets.Clear();

            //save stock card
            bool addStock                = true;
            bool calculateStock          = false;
            EnumTransactionStatus status = (EnumTransactionStatus)Enum.Parse(typeof(EnumTransactionStatus), Trans.TransStatus);

            TransactionFormViewModel.GetIsCalculateStock(status, out addStock, out calculateStock);


            TTransDet         detToInsert;
            IList <TTransDet> listDet = new List <TTransDet>();
            decimal           total   = 0;

            foreach (TTransDet det in ListDetTrans)
            {
                detToInsert = new TTransDet(Trans);
                detToInsert.SetAssignedIdTo(Guid.NewGuid().ToString());
                detToInsert.ItemId        = det.ItemId;
                detToInsert.ItemUomId     = det.ItemUomId;
                detToInsert.TransDetQty   = det.TransDetQty;
                detToInsert.TransDetPrice = det.TransDetPrice;
                detToInsert.TransDetDisc  = det.TransDetDisc;
                detToInsert.TransDetTotal = det.TransDetTotal;
                detToInsert.CreatedBy     = User.Identity.Name;
                detToInsert.CreatedDate   = DateTime.Now;
                detToInsert.DataStatus    = Enums.EnumDataStatus.New.ToString();
                Trans.TransDets.Add(detToInsert);
                total += det.TransDetTotal.HasValue ? det.TransDetTotal.Value : 0;
                listDet.Add(detToInsert);
            }
            Trans.TransSubTotal = total;
            _tTransRepository.Save(Trans);
            //_tTransRepository.DbContext.CommitTransaction();

            //_tStockCardRepository.DbContext.BeginTransaction();
            if (calculateStock)
            {
                decimal totalHpp = 0;
                foreach (TTransDet det in listDet)
                {
                    //save stock
                    if (Trans.TransStatus.Equals(EnumTransactionStatus.Mutation.ToString()))
                    {
                        SaveStockItem(Trans.TransDate, Trans.TransDesc, det.ItemId, det.TransDetQty, false, Trans.WarehouseId);
                        SaveStockItem(Trans.TransDate, Trans.TransDesc, det.ItemId, det.TransDetQty, true, Trans.WarehouseIdTo);

                        //still to do, for mutation, price of stock must recalculate per stock,
                        //sum hpp for each stock for stock out
                        totalHpp += UpdateStock(Trans.TransDate, Trans.TransDesc, Trans.TransStatus, det.ItemId, det.TransDetPrice, det.TransDetQty, det, false, Trans.WarehouseId);
                        UpdateStock(Trans.TransDate, Trans.TransDesc, Trans.TransStatus, det.ItemId, det.TransDetPrice, det.TransDetQty, det, true, Trans.WarehouseIdTo);
                    }
                    else
                    {
                        SaveStockItem(Trans.TransDate, Trans.TransDesc, det.ItemId, det.TransDetQty, addStock, Trans.WarehouseId);

                        //sum hpp for each stock
                        totalHpp += UpdateStock(Trans.TransDate, Trans.TransDesc, Trans.TransStatus, det.ItemId, det.TransDetPrice, det.TransDetQty, det, addStock, Trans.WarehouseId);
                    }
                }
                //UPDATE  20150629 : no linked to accounting
                ////save journal
                //SaveJournal(Trans, totalHpp);
            }


            try
            {
                _tTransRepository.DbContext.CommitTransaction();
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Success;
            }
            catch (Exception)
            {
                _tTransRepository.DbContext.RollbackTransaction();
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Failed;
            }
            //if (!Trans.TransStatus.Equals(EnumTransactionStatus.PurchaseOrder.ToString()))
            //{
            //    return RedirectToAction(Trans.TransStatus.ToString());
            //}
            //return RedirectToAction("Index");
            return(View("Status"));
        }
Beispiel #19
0
        private ActionResult SaveTransaction(TTrans Trans, FormCollection formCollection, bool isDelete)
        {
            string Message = string.Empty;
            bool   Success = true;

            try
            {
                _tTransRepository.DbContext.BeginTransaction();

                //get stock add or calculated
                bool addStock                = true;
                bool calculateStock          = false;
                EnumTransactionStatus status = (EnumTransactionStatus)Enum.Parse(typeof(EnumTransactionStatus), Trans.TransStatus);
                switch (status)
                {
                case EnumTransactionStatus.Purchase:
                    addStock       = true;
                    calculateStock = true;
                    break;

                case EnumTransactionStatus.Received:
                    addStock       = true;
                    calculateStock = true;
                    break;

                case EnumTransactionStatus.Adjusment:
                    addStock       = true;
                    calculateStock = true;
                    break;

                case EnumTransactionStatus.ReturPurchase:
                    addStock       = false;
                    calculateStock = true;
                    break;

                case EnumTransactionStatus.ReturSales:
                    addStock       = true;
                    calculateStock = true;
                    break;

                case EnumTransactionStatus.Sales:
                    addStock       = false;
                    calculateStock = true;
                    break;

                case EnumTransactionStatus.Using:
                    addStock       = false;
                    calculateStock = true;
                    break;

                case EnumTransactionStatus.Mutation:
                    addStock       = false;
                    calculateStock = true;
                    break;
                }

                //check first
                TTrans tr = _tTransRepository.Get(formCollection["Trans.Id"]);
                if (!isDelete)
                {
                    bool isEdit = false;
                    if (tr == null)
                    {
                        isEdit = false;
                        //if
                        tr = new TTrans();
                        tr.SetAssignedIdTo(formCollection["Trans.Id"]);
                        tr.CreatedDate = DateTime.Now;
                        tr.CreatedBy   = User.Identity.Name;
                        tr.DataStatus  = Enums.EnumDataStatus.New.ToString();
                    }
                    else
                    {
                        isEdit          = true;
                        tr.ModifiedDate = DateTime.Now;
                        tr.ModifiedBy   = User.Identity.Name;
                        tr.DataStatus   = Enums.EnumDataStatus.Updated.ToString();
                    }
                    tr.WarehouseId = _mWarehouseRepository.Get(formCollection["Trans.WarehouseId"]);
                    if (!string.IsNullOrEmpty(formCollection["Trans.WarehouseIdTo"]))
                    {
                        tr.WarehouseIdTo = _mWarehouseRepository.Get(formCollection["Trans.WarehouseIdTo"]);
                    }
                    tr.TransStatus        = Trans.TransStatus;
                    tr.TransFactur        = Trans.TransFactur;
                    tr.TransDate          = Trans.TransDate;
                    tr.TransDueDate       = Trans.TransDueDate;
                    tr.TransBy            = Trans.TransBy;
                    tr.TransPaymentMethod = Trans.TransPaymentMethod;
                    SaveTransaction(tr, formCollection, addStock, calculateStock, isEdit);
                }
                else
                {
                    if (tr != null)
                    {
                        //do delete
                        DeleteTransaction(tr, addStock, calculateStock);
                    }
                }


                _tTransRepository.DbContext.CommitTransaction();
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Success;
                if (!isDelete)
                {
                    Message = "Data berhasil disimpan.";
                }
                else
                {
                    Message = "Data berhasil dihapus.";
                }
            }
            catch (Exception ex)
            {
                Success = false;
                if (!isDelete)
                {
                    Message = "Data gagal disimpan.";
                }
                else
                {
                    Message = "Data gagal dihapus.";
                }
                Message += "Error : " + ex.GetBaseException().Message;
                _tTransRepository.DbContext.RollbackTransaction();
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Failed;
            }
            var e = new
            {
                Success,
                Message
            };

            return(Json(e, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Report(EnumReports reports, ReportParamViewModel viewModel, FormCollection formCollection, EnumReportGroupBy?groupBy = null)
        {
            //LocalReport localReport = new LocalReport();
            //localReport.ReportPath = Server.MapPath(string.Format("~/Views/Transaction/Report/{0}.rdlc", reports.ToString()));

            ReportDataSource[] repCol     = new ReportDataSource[1];
            ReportParameter[]  parameters = null;
            switch (reports)
            {
            case EnumReports.RptBrand:
                repCol[0] = GetBrand();
                break;

            case EnumReports.RptCostCenter:
                repCol[0] = GetCostCenter();
                break;

            case EnumReports.RptNeraca:
                repCol[0] = GetRecAccount(EnumAccountCatType.NERACA, viewModel.CostCenterId, viewModel.RecPeriodId, viewModel.GenerateDetail);
                break;

            case EnumReports.RptLR:
                repCol[0] = GetRecAccount(EnumAccountCatType.LR, viewModel.CostCenterId, viewModel.RecPeriodId, viewModel.GenerateDetail);
                break;

            case EnumReports.RptNeracaSum:
                repCol[0] = GetRecAccount(EnumAccountCatType.NERACA, viewModel.CostCenterId, viewModel.RecPeriodId, viewModel.GenerateDetail);
                break;

            case EnumReports.RptLRSum:
                repCol[0] = GetRecAccount(EnumAccountCatType.LR, viewModel.CostCenterId, viewModel.RecPeriodId, viewModel.GenerateDetail);
                break;

            case EnumReports.RptStockCard:
                repCol[0] = GetStockCard(viewModel.DateFrom, viewModel.DateTo, viewModel.ItemId, viewModel.WarehouseId);
                break;

            case EnumReports.RptStockItem:
                repCol[0] = GetStockItem(viewModel.ItemId, viewModel.WarehouseId);
                break;

            case EnumReports.RptAnalyzeBudgetDetail:
                repCol[0] = GetTransDetForBudget(viewModel.ItemId, viewModel.WarehouseId, viewModel.DateFrom.Value, viewModel.DateTo.Value);
                break;

            case EnumReports.RptTransDetail:
                EnumTransactionStatus stat =
                    (EnumTransactionStatus)Enum.Parse(typeof(EnumTransactionStatus), formCollection["TransStatus"]);
                repCol[0] = GetTransTotal(viewModel.DateFrom, viewModel.DateTo, viewModel.WarehouseId, stat);
                break;

            case EnumReports.RptTransRecap:
                stat =
                    (EnumTransactionStatus)Enum.Parse(typeof(EnumTransactionStatus), formCollection["TransStatus"]);
                parameters    = new ReportParameter[3];
                parameters[0] = new ReportParameter("ParamTitle", string.Format(CommonHelper.GetStringValue(EnumReports.RptTransRecap), CommonHelper.GetStringValue(stat), CommonHelper.GetStringValue(groupBy)));
                parameters[1] = new ReportParameter("ParamGroupBy", groupBy.ToString());
                parameters[2] = new ReportParameter("ParamGroupByTitle", CommonHelper.GetStringValue(groupBy));
                repCol[0]     = GetTransTotal(viewModel.DateFrom, viewModel.DateTo, viewModel.WarehouseId, stat);
                break;

            case EnumReports.RptItem:
                repCol[0] = GetItemViewModel();
                break;

            case EnumReports.RptJournal:
                repCol[0] = GetJournalDet(viewModel.DateFrom, viewModel.DateTo, viewModel.CostCenterId, viewModel.AccountId);
                break;

            case EnumReports.RptBukuBesar:
                repCol[0] = GetJournalDetFlow(viewModel.DateFrom, viewModel.DateTo, viewModel.CostCenterId, viewModel.AccountId, viewModel.AccountIdTo);
                break;

            case EnumReports.RptJournalByCostCenter:
                repCol[0] = GetJournalDet(viewModel.DateFrom, viewModel.DateTo, viewModel.CostCenterId, viewModel.AccountId);
                break;

            case EnumReports.RptBukuBesarByCostCenter:
                repCol[0] = GetJournalDetFlow(viewModel.DateFrom, viewModel.DateTo, viewModel.CostCenterId, viewModel.AccountId, viewModel.AccountIdTo);
                break;
            }
            Session["ReportData"]  = repCol;
            Session["ReportParam"] = parameters;

            var e = new
            {
                Success   = true,
                Message   = "redirect",
                UrlReport = string.Format("{0}", reports.ToString())
            };

            return(Json(e, JsonRequestBehavior.AllowGet));
        }
Beispiel #21
0
        public ActionResult ReportTrans(EnumReports reports, EnumTransactionStatus TransStatus)
        {
            ReportParamViewModel viewModel = ReportParamViewModel.CreateReportParamViewModel(_mWarehouseRepository, _mSupplierRepository, _mItemRepository);
            string title = string.Empty;

            switch (reports)
            {
            case EnumReports.RptBrand:
                title = "Daftar Master Merek";

                break;

            case EnumReports.RptStockCard:
                title = "Kartu Stok";
                viewModel.ShowDateFrom  = true;
                viewModel.ShowDateTo    = true;
                viewModel.ShowItem      = true;
                viewModel.ShowWarehouse = true;
                break;

            case EnumReports.RptStockItem:
                title = "Lap. Stok Per Gudang";
                viewModel.ShowItem      = true;
                viewModel.ShowWarehouse = true;
                break;

            case EnumReports.RptAnalyzeBudgetDetail:
                title = "Lap. Analisa Budget";
                viewModel.ShowItem      = true;
                viewModel.ShowWarehouse = true;
                break;

            case EnumReports.RptTransDetail:
                title = "Lap. Detail";
                viewModel.ShowDateFrom  = true;
                viewModel.ShowDateTo    = true;
                viewModel.ShowWarehouse = true;
                break;

            case EnumReports.RptTransDetailByTransBy:
                title = "Lap. Rekap Detail Transaksi";
                viewModel.ShowDateFrom = true;
                viewModel.ShowDateTo   = true;
                viewModel.ShowSupplier = true;
                break;

            case EnumReports.RptLRDetailSales:
                title = "Lap. Detail Laba Kotor";
                viewModel.ShowDateFrom = true;
                viewModel.ShowDateTo   = true;
                viewModel.ShowCustomer = true;
                break;

            case EnumReports.RptMostItemSales:
                title = "Lap. Penjualan Terbanyak";
                viewModel.ShowDateFrom  = true;
                viewModel.ShowDateTo    = true;
                viewModel.ShowWarehouse = true;
                break;
            }
            ViewData["CurrentItem"] = title;


            ViewData["ExportFormat"] = new SelectList(Enum.GetValues(typeof(EnumExportFormat)));

            return(View(viewModel));
        }
        private ReportDataSource GetTransTotal(DateTime?dateFrom, DateTime?dateTo, string warehouseId, EnumTransactionStatus transStatus)
        {
            Check.Require(transStatus != EnumTransactionStatus.None, "transStatus may not be None");
            IList <TTransDet> dets      = _tTransDetRepository.GetByDateWarehouse(dateFrom, dateTo, warehouseId, transStatus);
            string            TransName = Helper.CommonHelper.GetStringValue(transStatus);

            TransactionFormViewModel viewModel = new TransactionFormViewModel();

            Helper.CommonHelper.SetViewModelByStatus(viewModel, transStatus);

            var list = from det in dets
                       select new
            {
                det.Id,
                det.TransDetNo,
                det.TransDetQty,
                det.TransDetDesc,
                det.TransDetTotal,
                det.TransDetPrice,
                det.TransDetDisc,
                ItemId = det.ItemId.Id,
                det.ItemId.ItemName,
                ItemUom      = det.ItemId.ItemUom.ItemUomName,
                SupplierName = GetSupplierName(det.TransId.TransBy),
                det.TransId.TransFactur,
                det.TransId.TransDate,
                WarehouseId = det.TransId.WarehouseId.Id,
                det.TransId.WarehouseId.WarehouseName,
                WarehouseToName =
                    det.TransId.WarehouseIdTo != null ? det.TransId.WarehouseIdTo.WarehouseName : null,
                det.TransId.TransStatus,
                det.TransId.TransDesc,
                det.TransId.TransSubTotal,
                det.TransId.TransPaymentMethod,
                TransId = det.TransId.Id,
                viewModel.ViewWarehouse,
                viewModel.ViewWarehouseTo,
                viewModel.ViewSupplier,
                viewModel.ViewDate,
                viewModel.ViewFactur,
                viewModel.ViewPrice,
                viewModel.ViewPaymentMethod,
                viewModel.ViewJobType,
                viewModel.ViewUnitType,
                TransName,
                JobTypeId    = det.TransId.JobTypeId != null ? det.TransId.JobTypeId.Id : null,
                JobTypeName  = det.TransId.JobTypeId != null ? det.TransId.JobTypeId.JobTypeName : null,
                UnitTypeId   = det.TransId.UnitTypeId != null ? det.TransId.UnitTypeId.Id : null,
                UnitTypeName = det.TransId.UnitTypeId != null ? det.TransId.UnitTypeId.UnitTypeName : null
            }
            ;

            ReportDataSource reportDataSource = new ReportDataSource("TransTotalViewModel", list.ToList());

            return(reportDataSource);
        }
Beispiel #23
0
        private ReportDataSource GetTransDetail(DateTime?dateFrom, DateTime?dateTo, string warehouseId, EnumTransactionStatus transStatus)
        {
            Check.Require(transStatus != EnumTransactionStatus.None, "transStatus may not be None");
            IList <TTransDet> dets = _tTransDetRepository.GetByDateWarehouseTransBy(dateFrom, dateTo, string.Empty, warehouseId, transStatus.ToString());

            var list = from det in dets
                       select new
            {
                det.TransDetNo,
                det.TransDetQty,
                det.TransDetDesc,
                det.TransDetTotal,
                det.TransDetPrice,
                det.TransDetDisc,
                ItemId = det.ItemId.Id,
                det.ItemId.ItemName
            }
            ;

            ReportDataSource reportDataSource = new ReportDataSource("TransDetViewModel", list.ToList());

            return(reportDataSource);
        }
Beispiel #24
0
        public static void SetViewModelByStatus(TransactionFormViewModel viewModel, EnumTransactionStatus enumTransactionStatus)
        {
            switch (enumTransactionStatus)
            {
            case EnumTransactionStatus.PurchaseOrder:
                viewModel.ViewWarehouse     = true;
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewSupplier      = true;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = true;
                viewModel.ViewPaymentMethod = false;
                viewModel.IsGenerateFactur  = true;
                viewModel.IsCalculateStock  = false;
                viewModel.IsAddStock        = true;
                break;

            case EnumTransactionStatus.Purchase:
                viewModel.ViewWarehouse     = true;
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewSupplier      = true;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = true;
                viewModel.ViewPaymentMethod = true;
                viewModel.IsGenerateFactur  = false;
                viewModel.IsCalculateStock  = false;
                viewModel.IsAddStock        = true;
                break;

            case EnumTransactionStatus.ReturPurchase:
                viewModel.ViewWarehouse     = true;
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewSupplier      = true;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = true;
                viewModel.ViewPaymentMethod = true;
                viewModel.IsGenerateFactur  = true;
                viewModel.IsCalculateStock  = false;
                viewModel.IsAddStock        = true;
                break;

            case EnumTransactionStatus.Sales:
                break;

            case EnumTransactionStatus.ReturSales:
                break;

            case EnumTransactionStatus.Using:
                viewModel.ViewWarehouse     = true;
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewSupplier      = false;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = false;
                viewModel.ViewPaymentMethod = false;
                viewModel.ViewUnitType      = true;
                viewModel.ViewJobType       = true;
                viewModel.IsGenerateFactur  = true;
                viewModel.IsCalculateStock  = true;
                viewModel.IsAddStock        = false;
                break;

            case EnumTransactionStatus.Mutation:
                viewModel.ViewWarehouse     = true;
                viewModel.ViewWarehouseTo   = true;
                viewModel.ViewSupplier      = false;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = false;
                viewModel.ViewPaymentMethod = false;
                viewModel.IsGenerateFactur  = true;
                viewModel.IsCalculateStock  = true;
                viewModel.IsAddStock        = false;
                break;

            case EnumTransactionStatus.Adjusment:
                viewModel.ViewWarehouse     = true;
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewSupplier      = false;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = false;
                viewModel.ViewPaymentMethod = false;
                viewModel.IsGenerateFactur  = true;
                viewModel.IsCalculateStock  = true;
                viewModel.IsAddStock        = false;
                break;

            case EnumTransactionStatus.Received:
                viewModel.ViewWarehouse     = true;
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewSupplier      = true;
                viewModel.ViewDate          = true;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = true;
                viewModel.ViewPaymentMethod = false;
                viewModel.IsGenerateFactur  = true;
                viewModel.IsCalculateStock  = true;
                viewModel.IsAddStock        = true;
                break;

            case EnumTransactionStatus.Budgeting:
                viewModel.ViewWarehouse     = true;
                viewModel.ViewWarehouseTo   = false;
                viewModel.ViewSupplier      = false;
                viewModel.ViewDate          = false;
                viewModel.ViewFactur        = true;
                viewModel.ViewPrice         = true;
                viewModel.ViewPaymentMethod = false;
                viewModel.ViewUnitType      = true;
                viewModel.ViewJobType       = true;
                viewModel.IsGenerateFactur  = true;
                viewModel.IsCalculateStock  = false;
                viewModel.IsAddStock        = true;
                break;
            }
            viewModel.Title = GetStringValue(enumTransactionStatus);
        }
        public ActionResult ReportTrans(EnumReports reports, EnumTransactionStatus TransStatus, EnumReportGroupBy?groupBy = null)
        {
            ReportParamViewModel viewModel = ReportParamViewModel.CreateReportParamViewModel(_mCostCenterRepository, _mWarehouseRepository, _mSupplierRepository, _tRecPeriodRepository, _mItemRepository);

            if (TransStatus != EnumTransactionStatus.None)
            {
                viewModel.TransStatus = TransStatus;
            }
            string title = Helper.CommonHelper.GetStringValue(reports);

            switch (reports)
            {
            case EnumReports.RptBrand:

                break;

            case EnumReports.RptCostCenter:
                break;

            case EnumReports.RptNeraca:
                viewModel.ShowCostCenter     = true;
                viewModel.ShowRecPeriod      = true;
                viewModel.ShowGenerateDetail = true;
                break;

            case EnumReports.RptLR:
                viewModel.ShowCostCenter     = true;
                viewModel.ShowRecPeriod      = true;
                viewModel.ShowGenerateDetail = true;
                break;

            case EnumReports.RptNeracaSum:
                viewModel.ShowRecPeriod      = true;
                viewModel.ShowGenerateDetail = true;
                break;

            case EnumReports.RptLRSum:
                viewModel.ShowRecPeriod      = true;
                viewModel.ShowGenerateDetail = true;
                break;

            case EnumReports.RptStockCard:
                viewModel.ShowDateFrom  = true;
                viewModel.ShowDateTo    = true;
                viewModel.ShowItem      = true;
                viewModel.ShowWarehouse = true;
                break;

            case EnumReports.RptStockItem:
                viewModel.ShowItem      = true;
                viewModel.ShowWarehouse = true;
                break;

            case EnumReports.RptAnalyzeBudgetDetail:
                viewModel.ShowDateFrom  = true;
                viewModel.ShowDateTo    = true;
                viewModel.ShowItem      = true;
                viewModel.ShowWarehouse = true;
                break;

            case EnumReports.RptTransDetail:
                title = string.Format(title, Helper.CommonHelper.GetStringValue(viewModel.TransStatus));
                switch (viewModel.TransStatus)
                {
                case EnumTransactionStatus.PurchaseOrder:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    viewModel.ShowSupplier  = true;
                    break;

                case EnumTransactionStatus.Received:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    viewModel.ShowSupplier  = true;
                    break;

                case EnumTransactionStatus.Purchase:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    viewModel.ShowSupplier  = true;
                    break;

                case EnumTransactionStatus.ReturPurchase:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    viewModel.ShowSupplier  = true;
                    break;

                case EnumTransactionStatus.Using:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    break;

                case EnumTransactionStatus.Mutation:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    break;

                case EnumTransactionStatus.Budgeting:
                    //viewModel.ShowDateFrom = true;
                    //viewModel.ShowDateTo = true;
                    viewModel.ShowWarehouse = true;
                    break;
                }

                break;

            case EnumReports.RptTransRecap:

                string groupByTitle = groupBy != null?Helper.CommonHelper.GetStringValue(groupBy) : string.Empty;

                title = string.Format(title, Helper.CommonHelper.GetStringValue(viewModel.TransStatus), groupByTitle);
                switch (viewModel.TransStatus)
                {
                case EnumTransactionStatus.PurchaseOrder:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    viewModel.ShowSupplier  = true;
                    break;

                case EnumTransactionStatus.Received:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    viewModel.ShowSupplier  = true;
                    break;

                case EnumTransactionStatus.Purchase:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    viewModel.ShowSupplier  = true;
                    break;

                case EnumTransactionStatus.ReturPurchase:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    viewModel.ShowSupplier  = true;
                    break;

                case EnumTransactionStatus.Using:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    break;

                case EnumTransactionStatus.Mutation:
                    viewModel.ShowDateFrom  = true;
                    viewModel.ShowDateTo    = true;
                    viewModel.ShowWarehouse = true;
                    break;

                case EnumTransactionStatus.Budgeting:
                    //viewModel.ShowDateFrom = true;
                    //viewModel.ShowDateTo = true;
                    viewModel.ShowWarehouse = true;
                    break;
                }

                break;

            case EnumReports.RptItem:

                break;

            case EnumReports.RptJournal:
                viewModel.ShowDateFrom  = true;
                viewModel.ShowDateTo    = true;
                viewModel.ShowAccount   = false;
                viewModel.ShowAccountTo = false;
                break;

            case EnumReports.RptBukuBesar:
                viewModel.ShowDateFrom  = true;
                viewModel.ShowDateTo    = true;
                viewModel.ShowAccount   = true;
                viewModel.ShowAccountTo = true;
                break;

            case EnumReports.RptJournalByCostCenter:
                viewModel.ShowDateFrom   = true;
                viewModel.ShowDateTo     = true;
                viewModel.ShowCostCenter = true;
                viewModel.ShowAccount    = false;
                viewModel.ShowAccountTo  = false;
                break;

            case EnumReports.RptBukuBesarByCostCenter:
                viewModel.ShowDateFrom   = true;
                viewModel.ShowDateTo     = true;
                viewModel.ShowCostCenter = true;
                viewModel.ShowAccount    = true;
                viewModel.ShowAccountTo  = true;
                break;
            }
            ViewData["CurrentItem"]  = title;
            ViewData["ExportFormat"] = new SelectList(Enum.GetValues(typeof(EnumExportFormat)));

            return(View(viewModel));
        }
Beispiel #26
0
        public IList <TTransDet> GetListByDateAndCustomer(DateTime?dateFrom, DateTime?dateTo, EnumTransactionStatus transactionStatus, string customerId)
        {
            StringBuilder sql = new StringBuilder();

            sql.AppendLine(@"   select det
                                from TTransDet as det
                                    left outer join det.TransId trans 
                                        where trans.TransStatus = :TransStatus");
            if (dateFrom.HasValue && dateTo.HasValue)
            {
                sql.AppendLine("and trans.TransDate between :dateFrom and :dateTo");
            }
            sql.AppendLine(@"and trans.TransBy like :customerId 
                             order by trans.TransDate ");
            IQuery q = Session.CreateQuery(sql.ToString());

            q.SetString("TransStatus", transactionStatus.ToString());
            if (dateFrom.HasValue)
            {
                q.SetDateTime("dateFrom", dateFrom.Value);
            }
            if (dateTo.HasValue)
            {
                q.SetDateTime("dateTo", dateTo.Value);
            }
            q.SetString("customerId", customerId);
            return(q.List <TTransDet>());
        }