Пример #1
0
        public static void DisplayFinancialPeriod(FinancialPeriod period)
        {
            Console.Clear();
            Console.WriteLine($" - PAY PERIOD: {period.Start.ToString("D")} to {period.End.ToString("D")}");
            Console.WriteLine(new string('-', 56));

            Console.WriteLine($" - TOTAL INCOMINGS: \t\t\t{period.TotalIncomings.ToString("C")}");
            Console.WriteLine($" - TOTAL OUTGOINGS: \t\t\t{period.TotalOutgoings.ToString("C")}");
            Console.WriteLine($" - NET POSITION: \t\t\t{period.NetPosition.ToString("C")}");
            Console.WriteLine(new string('-', 56));

            Console.WriteLine(" - INCOMINGS:");
            foreach (var payment in period.Incomings)
            {
                Console.WriteLine($"\t{payment.Date.ToString("D")} - {payment.Name}");
                Console.WriteLine($"\t\t\t\t\t{payment.Amount.ToString("C")}");
            }

            Console.WriteLine(" - OUTGOINGS:");
            foreach (var payment in period.Outgoings)
            {
                Console.WriteLine($"\t{payment.Date.ToString("D")} - {payment.Name}");
                Console.WriteLine($"\t\t\t\t\t{payment.Amount.ToString("C")}");
            }
        }
        public async Task <IActionResult> Post([FromBody] AddFinancialPeriodViewModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }

            var company = await _companyRepository.GetAsync(model.CompanyId);

            if (company == null)
            {
                return(NotFound(Resources.Companies.CompanyResource.CompanyNotFound));
            }

            if (await _financialPeriodRepo.IsExistNameAsync(model.Name))
            {
                ModelState.AddModelError("Name", Resources.Global.Common.ThisNameExist);
                return(BadRequest(ModelState.GetWithErrorsKey()));
            }

            var financialPeriod = new FinancialPeriod(model.Name, company.Id, model.StartDate, model.EndtDate);

            var affectedRows = await _financialPeriodRepo.AddAsync(financialPeriod);

            if (affectedRows > 0)
            {
                _financialPeriodRepo.LoadReferences(financialPeriod);
                var viewModel = AutoMapper.Mapper.Map <FinancialPeriodViewModel>(financialPeriod);

                return(CreatedAtRoute("GetFinancialPeriod", new { id = financialPeriod.Number }, viewModel));
            }
            return(BadRequest());
        }
        private void BindFinancialPeriod()
        {
            DropDownListFinancialPeriod.DataSource     = FinancialPeriod.GetFinancialPeriodList(Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId);
            DropDownListFinancialPeriod.DataTextField  = "Description";
            DropDownListFinancialPeriod.DataValueField = "FinancialPeriodId";
            DropDownListFinancialPeriod.DataBind();

            if (DropDownListFinancialPeriod.Items.Count > 1)
            {
                DropDownListFinancialPeriod.Items.Insert(0, new ListItem("Please select", "0"));
            }
        }
Пример #4
0
        public bool CloseFinancialPeriod(int Id, FinancialPeriod financialperiod)
        {
            FinancialPeriod existfinancialperiod = GetFinancialPeriodById(Id);

            if (existfinancialperiod == null)
            {
                return(false);
            }
            existfinancialperiod.FinancialPeriodStatusId = financialperiod.FinancialPeriodStatusId;
            _context.Update(existfinancialperiod);
            _context.SaveChanges();

            return(true);
        }
        private void BindFinancialPeriod()
        {
            DropDownListFinancialPeriod.DataSource     = FinancialPeriod.GetFinancialPeriodList(Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).CompanyId);
            DropDownListFinancialPeriod.DataTextField  = "Description";
            DropDownListFinancialPeriod.DataValueField = "FinancialPeriodId";
            DropDownListFinancialPeriod.DataBind();

            //if (DropDownListFinancialPeriod.Items.Count > 1)
            //{
            //    DropDownListFinancialPeriod.Items.Insert(0, new ListItem("Please select", "0"));
            //}
            //else
            //{
            this.financialPeriodId = Convert.ToInt32(DropDownListFinancialPeriod.SelectedValue);
            //}
        }
Пример #6
0
        public bool UpdateFinancialPeriod(int Id, FinancialPeriod financialperiod)
        {
            FinancialPeriod existFinancialPeriod = GetFinancialPeriodById(Id);

            if (existFinancialPeriod == null)
            {
                return(false);
            }
            existFinancialPeriod.Month    = financialperiod.Month;
            existFinancialPeriod.FromData = financialperiod.FromData;
            existFinancialPeriod.ToDate   = financialperiod.ToDate;

            _context.Update(existFinancialPeriod);
            _context.SaveChanges();

            return(true);
        }
Пример #7
0
        public bool ActivatedFinancialPeriod(int Id, FinancialPeriod financialperiod)
        {
            var checkIFSomeActive = GetFinancialPeriods().Where(x => x.Year == financialperiod.Year &&
                                                                x.FinancialPeriodStatusId == (int)EnumHelper.FinancPeriodStatus.CURRENT).ToList();

            if (checkIFSomeActive.Count() == 0)
            {
                FinancialPeriod existfinancialperiod = GetFinancialPeriodById(Id);
                if (existfinancialperiod == null)
                {
                    return(false);
                }
                existfinancialperiod.FinancialPeriodStatusId = financialperiod.FinancialPeriodStatusId;
                _context.Update(existfinancialperiod);
                _context.SaveChanges();
            }
            return(true);
        }
Пример #8
0
        public int AddFinancialByYear(int year)
        {
            FinancialPeriod obj = new FinancialPeriod();

            for (int month = 1; month <= 12; month++)
            {
                obj.Year  = year;
                obj.Month = month;
                var firstday = new DateTime(obj.Year, (int)obj.Month, 1);
                obj.FromData = new DateTime(obj.Year, (int)obj.Month, 1).ToString("dd/MM/yyyy",
                                                                                  CultureInfo.InvariantCulture);
                obj.ToDate = firstday.AddMonths(1).AddDays(-1).ToString("dd/MM/yyyy",
                                                                        CultureInfo.InvariantCulture);
                obj.FinancialPeriodStatusId = (int)EnumHelper.FinancPeriodStatus.OPEN;
                _context.FinancialPeriods.Add(obj);
                _context.SaveChanges();
                obj = new FinancialPeriod();
            }

            return(obj.Id);
        }
    public async Task Post()
    {
        var data = new FinancialPeriod
        {
            Name        = "Second",
            PeriodBegin = new DateTime(2022, 1, 1),
            PeriodEnd   = new DateTime(2022, 6, 30),
            Incomes     = new List <Income>
            {
                new Income
                {
                    Name              = "First",
                    Value             = 12,
                    FinancialPeriodId = 2
                }
            },
            Expenditures = new List <Expenditure>()
        };

        await _financialPeriodService.Save(data);
    }
Пример #10
0
 public async Task Save(FinancialPeriod period)
 {
     await _repository.AddAsync(period);
 }
Пример #11
0
        public async Task <IActionResult> Init(InitConfigViewModel model)
        {
            // check if it's initialized
            if (_defaultKeysOptions.Value.Initialized)
            {
                return(BadRequest("Already Initialized!"));
            }
            // 1. create company 2. finanital period
            string financialPeriodName = string.Format(Resources.Global.Common.FinancialPeriodName, DateTime.Now.Year, model.CompanyName);
            var    financialPeriod     = new FinancialPeriod(financialPeriodName, model.StartDate, model.EndtDate);

            financialPeriod.Company = new Company(model.CompanyName);
            _financialPeriodRepo.Add(financialPeriod, false);
            // 3. currency
            Currency currency = new Currency();

            if (model.CurrencyId.HasValue)
            {
                var preDefinedCurrency = _predefinedGuideService.GetCurrecny(model.CurrencyId.Value);
                currency = new Currency(preDefinedCurrency.Code, preDefinedCurrency.GetName(_language), 1, preDefinedCurrency.GetPartName(_language), preDefinedCurrency.PartRate, preDefinedCurrency.ISOCode);
            }
            else
            {
                var preDefinedCurrency = _predefinedGuideService.GetCurrecny(1); // USD
                currency = new Currency(preDefinedCurrency.Code, preDefinedCurrency.GetName(_language), 1, preDefinedCurrency.GetPartName(_language), preDefinedCurrency.PartRate, preDefinedCurrency.ISOCode);
            }

            _currencyRepo.Add(currency, false);

            // 4. accounts
            var accounts = _predefinedGuideService.GetGuideAccounts(model.AccoutGuideId);

            foreach (var accountModel in accounts)
            {
                var finalAccountId  = accountModel.FinalAccountId == Guid.Empty ? null : accountModel.FinalAccountId;
                var parentAccountId = accountModel.ParentId == Guid.Empty ? null : accountModel.ParentId;
                var account         =
                    new Account(accountModel.GetName(_language), accountModel.Code, parentAccountId, finalAccountId,
                                (AccountType)accountModel.Type, AccountDirectionType.Both, currency.Id);
                account.Id = accountModel.Id;
                _accountRepo.Add(account, false);
            }

            // 5. billTypes

            // 6. payTypes

            // 7. check and complete defulat items accountId and default cash accountId in predefienedGuides file

            var affectedRows = await _accountRepo.SaveAllAsync();

            if (affectedRows > 0)
            {
                // update appSettings
                //      1. update initialized prop
                _defaultKeysOptions.Update(a => a.Initialized = true);
                //      2. update default currency
                _defaultKeysOptions.Update(a => a.CurrencyId = currency.Id);

                return(Ok());
            }
            return(BadRequest());
        }
Пример #12
0
 public int AddFinancialPeriod(FinancialPeriod financialperiod)
 {
     _context.FinancialPeriods.Add(financialperiod);
     _context.SaveChanges();
     return(financialperiod.Id);
 }