private void SaveCreditor(int ClientId)
        {
            if (SelectedCreditor.CreditorId == 0)
            {
                int CreditorNumber = CostAccounts.GetNextCreditorNumber();
                SelectedCreditor.RefClientId = CompanyViewModel.Client.ClientId;
                SelectedCreditor.CostAccount.RefTaxTypeId             = CompanyViewModel.SelectedTaxTypeId;
                SelectedCreditor.CostAccount.AccountNumber            = CreditorNumber;
                SelectedCreditor.CostAccount.RefCostAccountCategoryId =
                    CostAccountCategories.GetCreditorId();
                SelectedCreditor.CostAccount.Description = CompanyViewModel.Client.Name;
                SelectedCreditor.CostAccount.IsVisible   = true;
                SelectedCreditor.RefCostAccountId        =
                    CostAccounts.Insert(SelectedCreditor.CostAccount);
                Creditors.Insert(SelectedCreditor);
            }
            else
            {
                Clients.Update(CompanyViewModel.Client);
                if (CompanyViewModel.SelectedClientType == ClientType.Business)
                {
                    Companies.Update(CompanyViewModel.Client.Company);
                }

                CostAccounts.Update(SelectedCreditor.CostAccount);
                Creditors.Update(SelectedCreditor);
            }
        }
Esempio n. 2
0
        //Load a specified Creditor's information
        private void metroButton2_Click(object sender, EventArgs e)
        {
            Exception IBANorNameNotFound = new Exception("The Creditor was not found.\nCheck the IBAN/Name and try again");
            string    exceptionText      = "";

            try
            {
                if (Access.GetCreditors(id).Where(x => (x.name.Trim() == IBANTextBox.Text || x.IBAN.Trim() == IBANTextBox.Text)).Count() != 0)
                {
                    changed                 = Access.GetCreditors(id).Where(x => (x.name.Trim() == IBANTextBox.Text || x.IBAN.Trim() == IBANTextBox.Text)).First();
                    lendTextBox.Text        = changed.lend.ToString();
                    interestTextBox.Text    = changed.interest.ToString();
                    lendTextBox.Enabled     = true;
                    interestTextBox.Enabled = true;
                    metroButton1.Enabled    = true;
                    metroButton3.Enabled    = true;
                }
                else
                {
                    exceptionText = IBANorNameNotFound.Message;
                    throw IBANorNameNotFound;
                }
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, exceptionText, "Error", MessageBoxButtons.OK);
            }
        }
Esempio n. 3
0
        public void NewCreditor()
        {
            DateTime  dateTime = new DateTime(DateTime.Now.Year + 1, DateTime.Now.Month, DateTime.Now.Day);
            Creditors creditor = new Creditors("1111-2222-3333", "Petur Petrov", 200, dateTime, 2, 123123);

            Assert.AreEqual(Math.Round(208.08, 2), creditor.guarantee);
        }
Esempio n. 4
0
        public IActionResult Claim(Guid id)
        {
            Creditors creditors = creditorRepo.GetByIdCreditDebit(id);

            creditors.status = true;
            creditorRepo.Update(creditors);
            return(RedirectToAction("index", "Home"));
        }
        private void DeleteCreditor()
        {
            if (SelectedCreditor.CreditorId != 0)
            {
                Creditors.Delete(SelectedCreditor.CreditorId);
            }

            FilteredCreditors.Remove(SelectedCreditor);
        }
        private bool ValidateDelete()
        {
            if (SelectedCreditor == null && SelectedDebitor == null)
            {
                return(false);
            }

            if (SelectedCreditor != null)
            {
                return(!Creditors.IsCreditorInUse(SelectedCreditor.CreditorId));
            }

            if (SelectedDebitor != null)
            {
                return(!Debitors.IsDebitorInUse(SelectedDebitor.DebitorId));
            }

            return(false);
        }
Esempio n. 7
0
        public ActionResult Details(Guid id)
        {
            Creditors creditors = creditorRepo.GetByIdCreditDebit(id);
            int       day1      = creditors.DateOwed.Day;
            int       day2      = creditors.DueDate.Day;
            int       day       = day2 - day1;

            //calculate interest
            double interest = creditors.percentageInterest * day;

            DashBoardViewModel model = new DashBoardViewModel()
            {
                creditor = creditors,
                total    = (interest * creditors.MoneyOwed) + creditors.MoneyOwed,
                day      = day
            };

            return(View(model));
        }
Esempio n. 8
0
        public ActionResult Edit(Guid id)
        {
            Creditors         creditors = creditorRepo.GetByIdCreditDebit(id);
            CreditorViewModel model     = new CreditorViewModel()
            {
                id             = creditors.Id,
                userId         = creditors.userId,
                FirstName      = creditors.FirstName,
                LastName       = creditors.LastName,
                Address        = creditors.Address,
                Phone          = creditors.Phone,
                Email          = creditors.Email,
                Description    = creditors.Description,
                DueDate        = creditors.DueDate,
                interestPerDay = creditors.percentageInterest,
                MoneyOwed      = creditors.MoneyOwed
            };

            return(View(model));
        }
Esempio n. 9
0
        public IActionResult Edit(CreditorViewModel model)
        {
            Creditors creditors = creditorRepo.GetByIdCreditDebit(model.id);

            if (ModelState.IsValid)
            {
                creditors.FirstName          = model.FirstName;
                creditors.LastName           = model.LastName;
                creditors.Address            = model.Address;
                creditors.MoneyOwed          = model.MoneyOwed;
                creditors.percentageInterest = model.interestPerDay;
                creditors.Description        = model.Description;
                creditors.Phone   = model.Phone;
                creditors.Email   = model.Email;
                creditors.DueDate = model.DueDate;

                creditorRepo.Update(creditors);
                return(RedirectToAction("index"));
            }
            return(View());
        }
Esempio n. 10
0
 public IActionResult Create(CreditorViewModel model)
 {
     if (ModelState.IsValid)
     {
         Creditors creditors = new Creditors()
         {
             FirstName          = model.FirstName,
             LastName           = model.LastName,
             Phone              = model.Phone,
             Address            = model.Address,
             Description        = model.Description,
             DateOwed           = model.DateOwed,
             DueDate            = model.DueDate,
             percentageInterest = model.interestPerDay,
             status             = false,
             Email              = model.Email,
             MoneyOwed          = model.MoneyOwed,
             userId             = Userid()
         };
         creditorRepo.Insert(creditors);
         return(RedirectToAction("index", "Creditors"));
     }
     return(View());
 }
 private void RefreshData()
 {
     FilteredCreditors = CreditorList = Creditors.GetAll().ToSvenTechCollection();
     FilteredDebitors  = DebitorList = Debitors.GetAll().ToSvenTechCollection();
 }