public ActionResult Insert(MUnitType viewModel, FormCollection formCollection)
        {
            try
            {
                UpdateNumericData(viewModel, formCollection);
                MUnitType unitType = new MUnitType();
                unitType.SetAssignedIdTo(Guid.NewGuid().ToString());
                TransferFormValuesTo(unitType, viewModel);
                unitType.CostCenterId = _mCostCenterRepository.Get(formCollection["CostCenterId"]);
                unitType.CreatedDate  = DateTime.Now;
                unitType.CreatedBy    = User.Identity.Name;

                _mUnitTypeRepository.Save(unitType);

                //GenerateEachUnit(unitType);

                _mUnitTypeRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mUnitTypeRepository.DbContext.RollbackTransaction();

                //throw e.GetBaseException();
                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
        private ReportDataSource GetRecAccount(EnumAccountCatType accountCatType, string costCenterId, string recPeriodId)
        {
            IList <TRecAccount> dets;
            TRecPeriod          recPeriod = _tRecPeriodRepository.Get(recPeriodId);

            if (!string.IsNullOrEmpty(costCenterId))
            {
                MCostCenter costCenter = _mCostCenterRepository.Get(costCenterId);
                dets = _tRecAccountRepository.GetByAccountType(accountCatType.ToString(), costCenter, recPeriod);
            }
            else
            {
                dets = _tRecAccountRepository.GetByAccountType(accountCatType.ToString(), null, recPeriod);
            }

            var list = from det in dets
                       select new
            {
                det.RecAccountStart,
                det.RecAccountEnd,
                det.RecAccountDesc,
                CostCenterId = det.CostCenterId.Id,
                det.CostCenterId.CostCenterName,
                AccountId = det.AccountId.Id,
                det.AccountId.AccountName,
                AccountCatId = det.AccountId.AccountCatId.Id,
                det.AccountId.AccountCatId.AccountCatName,
                AccountParentId = det.AccountId.AccountParentId != null ? det.AccountId.AccountParentId.Id : ""
            }
            ;

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

            return(reportDataSource);
        }
示例#3
0
        public ActionResult Insert(MWarehouse viewModel, FormCollection formCollection)
        {
            RefAddress address = new RefAddress();

            address.AddressLine1 = formCollection["AddressLine1"];
            address.AddressLine2 = formCollection["AddressLine2"];
            address.AddressLine3 = formCollection["AddressLine3"];
            address.AddressPhone = formCollection["AddressPhone"];
            address.AddressCity  = formCollection["AddressCity"];
            address.SetAssignedIdTo(Guid.NewGuid().ToString());
            _refAddressRepository.Save(address);

            MWarehouse mWarehouseToInsert = new MWarehouse();

            TransferFormValuesTo(mWarehouseToInsert, viewModel);
            mWarehouseToInsert.EmployeeId   = _mEmployeeRepository.Get(formCollection["EmployeeId"]);
            mWarehouseToInsert.CostCenterId = _mCostCenterRepository.Get(formCollection["CostCenterId"]);
            mWarehouseToInsert.SetAssignedIdTo(viewModel.Id);
            mWarehouseToInsert.CreatedDate = DateTime.Now;
            mWarehouseToInsert.CreatedBy   = User.Identity.Name;
            mWarehouseToInsert.DataStatus  = EnumDataStatus.New.ToString();
            mWarehouseToInsert.AddressId   = address;
            _mWarehouseRepository.Save(mWarehouseToInsert);

            //save account persediaan barang
            MAccountRef accountRef = new MAccountRef();

            accountRef.SetAssignedIdTo(Guid.NewGuid().ToString());
            accountRef.ReferenceId    = mWarehouseToInsert.Id;
            accountRef.ReferenceTable = EnumReferenceTable.Warehouse.ToString();
            accountRef.ReferenceType  = EnumReferenceTable.Warehouse.ToString();
            accountRef.AccountId      = _mAccountRepository.Get(formCollection["AccountId"]);
            _mAccountRefRepository.Save(accountRef);

            //save account pemakaian barang
            accountRef = new MAccountRef();
            accountRef.SetAssignedIdTo(Guid.NewGuid().ToString());
            accountRef.ReferenceId    = mWarehouseToInsert.Id;
            accountRef.ReferenceTable = EnumReferenceTable.WarehouseUsing.ToString();
            accountRef.ReferenceType  = EnumReferenceTable.WarehouseUsing.ToString();
            accountRef.AccountId      = _mAccountRepository.Get(formCollection["UsingAccountId"]);
            _mAccountRefRepository.Save(accountRef);

            try
            {
                _mWarehouseRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mWarehouseRepository.DbContext.RollbackTransaction();

                //throw e.GetBaseException();
                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
示例#4
0
        public virtual ActionResult List(string sidx, string sord, int page, int rows, string CostCenterId)
        {
            MCostCenter costCenter = _mCostCenterRepository.Get(CostCenterId);

            int totalRecords = 0;
            var reals        = _tRealRepository.GetPagedList(sidx, sord, page, 0, ref totalRecords, costCenter);
            int pageSize     = rows;
            int totalPages   = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

            var jsonData = new
            {
                total   = totalPages,
                page    = page,
                records = totalRecords,
                rows    = (
                    from real in reals
                    select new
                {
                    i = real.Id.ToString(),
                    cell = new string[] {
                        real.Id,
                        real.RealDate.HasValue ? real.RealDate.Value.ToString(CommonHelper.PeriodFormat) : null,
                        real.RealPercentValue.HasValue ? real.RealPercentValue.Value.ToString(CommonHelper.NumberFormat) : null,
                        real.RealDesc
                    }
                }).ToArray()
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Delete(MCostCenter viewModel, FormCollection formCollection)
        {
            MCostCenter mCompanyToDelete = _mCostCenterRepository.Get(viewModel.Id);

            if (mCompanyToDelete != null)
            {
                _mCostCenterRepository.Delete(mCompanyToDelete);
            }

            try
            {
                _mCostCenterRepository.DbContext.CommitChanges();
            }
            catch (Exception e)
            {
                _mCostCenterRepository.DbContext.RollbackTransaction();

                return(Content(e.GetBaseException().Message));
            }

            return(Content("success"));
        }
示例#6
0
        private void SaveJournal(TPayment payment, string transBy, string cashAccountId, string costCenterId, string desc)
        {
            TJournal journal = new TJournal();

            journal.JournalType      = EnumJournalType.GeneralLedger.ToString();
            journal.JournalVoucherNo = Helper.CommonHelper.GetVoucherNo();
            journal.JournalDate      = payment.PaymentDate;
            journal.JournalDesc      = payment.PaymentDesc;
            journal.JournalPic2      = payment.PaymentPic;
            journal.JournalPic       = transBy;

            journal.SetAssignedIdTo(Guid.NewGuid().ToString());
            journal.CostCenterId = _mCostCenterRepository.Get(costCenterId);
            journal.CreatedDate  = DateTime.Now;
            journal.CreatedBy    = User.Identity.Name;
            journal.DataStatus   = Enums.EnumDataStatus.New.ToString();
            journal.JournalDets.Clear();

            MAccount    accountCash = _mAccountRepository.Get(cashAccountId);
            MAccountRef accountRef;

            if (payment.PaymentType == EnumPaymentType.Hutang.ToString())
            {
                //search supplier hutang account
                accountRef = _mAccountRefRepository.GetByRefTableId(EnumReferenceTable.Supplier, transBy);
                //save debet
                SaveJournalDet(journal, EnumJournalStatus.D, accountRef.AccountId, payment.PaymentTotal, desc);
                //save kredit
                SaveJournalDet(journal, EnumJournalStatus.K, accountCash, payment.PaymentTotal, desc);
            }
            else if (payment.PaymentType == EnumPaymentType.Piutang.ToString())
            {
                //search Customer piutang account
                accountRef = _mAccountRefRepository.GetByRefTableId(EnumReferenceTable.Customer, transBy);
                //save debet
                SaveJournalDet(journal, EnumJournalStatus.D, accountCash, payment.PaymentTotal, desc);
                //save kredit
                SaveJournalDet(journal, EnumJournalStatus.K, accountRef.AccountId, payment.PaymentTotal, desc);
            }

            _tJournalRepository.Save(journal);
        }
        private ActionResult SaveJournal(TJournal journal, FormCollection formCollection)
        {
            if (journal == null)
            {
                journal = new TJournal();
            }
            journal.SetAssignedIdTo(formCollection["Journal.Id"]);
            journal.CostCenterId = _mCostCenterRepository.Get(formCollection["Journal.CostCenterId"]);
            journal.CreatedDate  = DateTime.Now;
            journal.CreatedBy    = User.Identity.Name;
            journal.DataStatus   = Enums.EnumDataStatus.New.ToString();
            journal.JournalDets.Clear();

            TJournalDet detToInsert;
            decimal     total = 0;

            foreach (TJournalDet det in ListJournalDet)
            {
                detToInsert = new TJournalDet(journal);
                detToInsert.SetAssignedIdTo(Guid.NewGuid().ToString());
                detToInsert.AccountId = det.AccountId;

                if (journal.JournalType == EnumJournalType.CashIn.ToString())
                {
                    detToInsert.JournalDetStatus = EnumJournalStatus.K.ToString();
                }
                else if (journal.JournalType == EnumJournalType.CashOut.ToString())
                {
                    detToInsert.JournalDetStatus = EnumJournalStatus.D.ToString();
                }
                else if (journal.JournalType == EnumJournalType.GeneralLedger.ToString())
                {
                    detToInsert.JournalDetStatus = det.JournalDetStatus;
                }

                detToInsert.JournalDetAmmount = det.JournalDetAmmount;
                detToInsert.JournalDetNo      = det.JournalDetNo;
                detToInsert.JournalDetDesc    = det.JournalDetDesc;
                detToInsert.CreatedBy         = User.Identity.Name;
                detToInsert.CreatedDate       = DateTime.Now;
                detToInsert.DataStatus        = Enums.EnumDataStatus.New.ToString();
                journal.JournalDets.Add(detToInsert);

                total += det.JournalDetAmmount.Value;
            }

            //add new detail for cash in / out
            if (journal.JournalType == EnumJournalType.CashIn.ToString() || journal.JournalType == EnumJournalType.CashOut.ToString())
            {
                detToInsert = new TJournalDet(journal);
                detToInsert.SetAssignedIdTo(Guid.NewGuid().ToString());
                detToInsert.AccountId = _mAccountRepository.Get(formCollection["CashAccountId"]);

                if (journal.JournalType == EnumJournalType.CashIn.ToString())
                {
                    detToInsert.JournalDetStatus = EnumJournalStatus.D.ToString();
                }
                else if (journal.JournalType == EnumJournalType.CashOut.ToString())
                {
                    detToInsert.JournalDetStatus = EnumJournalStatus.K.ToString();
                }

                detToInsert.JournalDetAmmount = total;
                detToInsert.JournalDetNo      = 0;
                detToInsert.JournalDetDesc    = journal.JournalDesc;
                detToInsert.CreatedBy         = User.Identity.Name;
                detToInsert.CreatedDate       = DateTime.Now;
                detToInsert.DataStatus        = Enums.EnumDataStatus.New.ToString();
                journal.JournalDets.Add(detToInsert);
            }

            try
            {
                _tJournalRepository.Save(journal);
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Success;
            }
            catch (Exception)
            {
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Failed;
            }
            return(View("Status"));

            //return RedirectToAction(journal.JournalType);
        }
        private ActionResult SaveJournal(TJournal journal, FormCollection formCollection)
        {
            string Message   = string.Empty;
            bool   Success   = true;
            string voucherNo = string.Empty;

            try
            {
                _tJournalRepository.DbContext.BeginTransaction();

                //check first
                TJournal journal1 = _tJournalRepository.Get(formCollection["Journal.Id"]);
                voucherNo = journal.JournalVoucherNo;
                if (journal1 != null)
                {
                    _tJournalRepository.Delete(journal1);
                }
                else
                {
                    EnumJournalType journalType = (EnumJournalType)Enum.Parse(typeof(EnumJournalType), journal.JournalType);
                    voucherNo = Helper.CommonHelper.GetVoucherNo(false, journalType);
                }

                if (journal == null)
                {
                    journal = new TJournal();
                }
                journal.SetAssignedIdTo(formCollection["Journal.Id"]);
                journal.CostCenterId     = _mCostCenterRepository.Get(formCollection["Journal.CostCenterId"]);
                journal.JournalVoucherNo = voucherNo;
                journal.CreatedDate      = DateTime.Now;
                journal.CreatedBy        = User.Identity.Name;
                journal.DataStatus       = Enums.EnumDataStatus.New.ToString();
                journal.JournalDets.Clear();

                TJournalDet detToInsert;
                decimal     total = 0;
                foreach (TJournalDet det in ListJournalDet)
                {
                    detToInsert = new TJournalDet(journal);
                    detToInsert.SetAssignedIdTo(Guid.NewGuid().ToString());
                    detToInsert.AccountId = det.AccountId;

                    if (journal.JournalType == EnumJournalType.CashIn.ToString())
                    {
                        detToInsert.JournalDetStatus = EnumJournalStatus.K.ToString();
                    }
                    else if (journal.JournalType == EnumJournalType.CashOut.ToString())
                    {
                        detToInsert.JournalDetStatus = EnumJournalStatus.D.ToString();
                    }
                    else if (journal.JournalType == EnumJournalType.GeneralLedger.ToString())
                    {
                        detToInsert.JournalDetStatus = det.JournalDetStatus;
                    }

                    detToInsert.JournalDetAmmount    = det.JournalDetAmmount;
                    detToInsert.JournalDetNo         = det.JournalDetNo;
                    detToInsert.JournalDetEvidenceNo = det.JournalDetEvidenceNo;
                    detToInsert.JournalDetDesc       = det.JournalDetDesc;
                    detToInsert.CreatedBy            = User.Identity.Name;
                    detToInsert.CreatedDate          = DateTime.Now;
                    detToInsert.DataStatus           = Enums.EnumDataStatus.New.ToString();
                    journal.JournalDets.Add(detToInsert);

                    total += det.JournalDetAmmount.Value;
                }

                //add new detail for cash in / out
                if (journal.JournalType == EnumJournalType.CashIn.ToString() || journal.JournalType == EnumJournalType.CashOut.ToString())
                {
                    detToInsert = new TJournalDet(journal);
                    detToInsert.SetAssignedIdTo(Guid.NewGuid().ToString());
                    detToInsert.AccountId = _mAccountRepository.Get(formCollection["CashAccountId"]);

                    if (journal.JournalType == EnumJournalType.CashIn.ToString())
                    {
                        detToInsert.JournalDetStatus = EnumJournalStatus.D.ToString();
                    }
                    else if (journal.JournalType == EnumJournalType.CashOut.ToString())
                    {
                        detToInsert.JournalDetStatus = EnumJournalStatus.K.ToString();
                    }

                    detToInsert.JournalDetAmmount = total;
                    detToInsert.JournalDetNo      = 0;
                    detToInsert.JournalDetDesc    = journal.JournalDesc;
                    detToInsert.CreatedBy         = User.Identity.Name;
                    detToInsert.CreatedDate       = DateTime.Now;
                    detToInsert.DataStatus        = Enums.EnumDataStatus.New.ToString();
                    journal.JournalDets.Add(detToInsert);
                }
                _tJournalRepository.Save(journal);

                _tJournalRepository.DbContext.CommitTransaction();
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Success;
                Message = "Data berhasil disimpan.";
            }
            catch (Exception ex)
            {
                _tJournalRepository.DbContext.RollbackTransaction();
                Success = false;
                Message = ex.GetBaseException().Message;
                TempData[EnumCommonViewData.SaveState.ToString()] = EnumSaveState.Failed;
            }
            var e = new
            {
                Success,
                Message,
                voucherNo
            };

            return
                (Json(e, JsonRequestBehavior.AllowGet));
            //View("Status");
            //return RedirectToAction(journal.JournalType);
        }