예제 #1
0
        public async Task <IActionResult> PutPayees([FromRoute] int id, [FromBody] Payees payees)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != payees.Id)
            {
                return(BadRequest());
            }

            _payeesRepository.UpdatePayee(payees);

            try
            {
                await _payeesRepository.Save();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PayeesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        //Update Payer status
        public Boolean DeleteSelectedPayee(Payees payee)
        {
            Boolean update;

            try
            {
                update = false;
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    using (SqlCommand cmd = new SqlCommand("sp_UpdatePayeeStatusById", conn))
                    {
                        cmd.CommandTimeout = 200;

                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.Add("@PayeeID", SqlDbType.NVarChar).Value = payee.PayeeID;


                        cmd.ExecuteNonQuery();
                        update = true;
                    }
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("SQL Error : " + ex.Message);
            }
            return(update);
        }
예제 #3
0
 public TestData()
 {
     Points   = new List <TestPoint>();
     Aliases  = new Aliases();
     Payees   = new Payees();
     Accounts = new Accounts();
 }
예제 #4
0
 public frmMembers(Payees payees)
 {
     InitializeComponent();
     this.payees = payees;
     employeeIds = payees.Employees.Select(x => x.Id).ToList();
     Init();
 }
예제 #5
0
        //Add New Supplier to Database
        public Boolean AddNewPayees(Payees payer)
        {
            Boolean insert;

            try
            {
                insert = false;
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    using (SqlCommand cmd = new SqlCommand("sp_InsertNewPayee", conn))
                    {
                        cmd.CommandTimeout = 200;

                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.Add("@PayeeName", SqlDbType.NVarChar).Value = payer.PayeeName;
                        cmd.Parameters.Add("@Phone", SqlDbType.NVarChar).Value     = payer.Phone;
                        cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value   = payer.Address;
                        cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value     = payer.Email;

                        cmd.ExecuteNonQuery();

                        insert = true;
                    }
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("SQL Error : " + ex.Message);
            }
            return(insert);
        }
예제 #6
0
 protected override void SetNewDraftDefaults(FundRequestDTO draft)
 {
     draft.BankAccountId = AppArgs.AccountId;
     draft.RequestDate   = DB.NextRequestDate();
     draft.SerialNum     = DB.NextRequestSerial();
     Payees.SetItems(DB.GetPayees());
     Allocations.DisplayItems(draft);
 }
예제 #7
0
        public void OnGet()
        {
            ViewData["Title"] = "Explore > Payees";

            Forecast forecast    = null;
            var      accessToken = HttpContext.GetTokenAsync("access_token").Result;
            var      userId      = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            _cache.TryGetValue(userId, out forecast);
            if (forecast == null)
            {
                forecast = Cache.GetForecast(accessToken, userId);
                _cache.Set(userId, forecast);
            }

            ViewData["LastUpdated"] = forecast.LastModifiedOn;
            Date = forecast.CurrentMonthStart;

            var validPayees = forecast.Transactions.Where(t => !t.Deleted).Select(t => t.PayeeId)
                              .Union(forecast.SubTransactions.Where(t => !t.Deleted).Select(t => t.PayeeId))
                              .Distinct()
                              .ToList();

            foreach (var p in forecast.Payees.Where(p => !p.Deleted).OrderBy(p => p.Name))
            {
                // If the payee has no transactions, don't display it.
                if (!validPayees.Contains(p.PayeeId))
                {
                    continue;
                }

                var payee = new PayeeModel
                {
                    PayeeId = p.PayeeId,
                    Name    = p.Name,
                };

                payee.Current = forecast.Transactions.Where(t => t.PayeeId == p.PayeeId)
                                .Where(t => t.Date.Year == forecast.CurrentMonthStart.Year && t.Date.Month == forecast.CurrentMonthStart.Month)
                                .Sum(t => t.Amount).ToDisplay();

                var monthCount = forecast.Months.Count(m => m.Month < forecast.CurrentMonthStart);

                if (monthCount > 0)
                {
                    var previous = forecast.Transactions.Where(t => t.PayeeId == p.PayeeId)
                                   .Where(t => t.Date < forecast.CurrentMonthStart)
                                   .Sum(t => t.Amount);
                    payee.Average = Convert.ToInt64(decimal.Divide(previous, monthCount)).ToDisplay();
                }
                else
                {
                    payee.Average = 0L.ToDisplay();
                }

                Payees.Add(payee);
            }
        }
        public Payee?GetPayeeById(int?id)
        {
            if (id == null)
            {
                return(null);
            }

            return(Payees.FirstOrDefault(item => item.Id == id));
        }
 public void RemovePayee(Payee payee)
 {
     using (DeferEvents())
     {
         ReplacePayee(oldPayee: payee, newPayee: null);
         Payees.Remove(payee);
         RaiseDatabaseChanged();
     }
 }
        public Payee?GetPayeeByName(string?name)
        {
            if (name == null)
            {
                return(null);
            }

            return(Payees.FirstOrDefault(item => item.Name == name));
        }
예제 #11
0
        public string GetDescription(bool allLevelsOfCategories = false)
        {
            string text = "";

            if (AccountId != -1)
            {
                text += Accounts.Get(AccountId).Name + " ";
            }

            if (CategoryIds.Count > 0)
            {
                string categories = "";

                foreach (int id in this.CategoryIds)
                {
                    if (categories != "")
                    {
                        categories += ", ";
                    }
                    categories += Categories.Get(id).Name;
                    if (allLevelsOfCategories == false)
                    {
                        // caller only wants the first Category
                        if (CategoryIds.Count > 1)
                        {
                            categories += "..."; // indicate that descending match is on
                        }
                        break;
                    }
                }

                text += categories + " ";
            }

            if (PayeeId != -1)
            {
                text += "Payee " + Payees.Get(PayeeId).Name + " ";
            }

            if (this.Amount != null)
            {
                text += ((decimal)this.Amount).ToString("C") + " ";
            }

            if (this.Year != null)
            {
                text += this.Year.ToString() + " ";
            }

            if (this.DateText != "")
            {
                text += this.DateText + " ";
            }

            return(text.Trim());
        }
예제 #12
0
        public override void Handle(Post post)
        {
            int count;

            if (!Payees.TryGetValue(post.Payee, out count))
            {
                count = 0;
            }

            Payees[post.Payee] = count + 1;
        }
예제 #13
0
 public frmAddEditPayee(MethodType methodType, Payees payees)
 {
     InitializeComponent();
     this.addEditLoadPayees = new AddEditPayees(this, payees)
     {
         methodType = methodType
     };
     addEditLoadPayees.Init();
     this.methodType = methodType;
     this.payees     = payees;
 }
예제 #14
0
        protected override async void OnWindowLoaded()
        {
            if (Draft.Id != 0)
            {
                return;
            }
            List <string> items = null;
            await Task.Run(() => items = AppArgs.Vouchers.GetPayees());

            UIThread.Run(() => Payees.SetItems(items));
        }
 private void MergePayees()
 {
     foreach (var group in Payees.GroupBy(c => c.Name))
     {
         var first = group.First();
         foreach (var item in group.Skip(1))
         {
             ReplacePayee(oldPayee: item, newPayee: first);
             RemovePayee(item);
         }
     }
 }
예제 #16
0
        private void AssertNoDetachedReferences()
        {
            foreach (var payee in Payees)
            {
                if (payee.DefaultCategory != null)
                {
                    if (!Categories.Any(c => ReferenceEquals(c, payee.DefaultCategory)))
                    {
                        throw new MoneizException($"Database is not valid: category of payee '{payee}' is not valid");
                    }
                }
            }

            foreach (var transaction in Transactions)
            {
                if (transaction.Account != null)
                {
                    if (!Accounts.Any(c => ReferenceEquals(c, transaction.Account)))
                    {
                        throw new MoneizException($"Database is not valid: account of transaction '{transaction.Id}' is not valid");
                    }
                }

                if (transaction.Category != null)
                {
                    if (!Categories.Any(c => ReferenceEquals(c, transaction.Category)))
                    {
                        throw new MoneizException($"Database is not valid: category of transaction '{transaction.Id}' is not valid");
                    }
                }

                if (transaction.Payee != null)
                {
                    if (!Payees.Any(c => ReferenceEquals(c, transaction.Payee)))
                    {
                        throw new MoneizException($"Database is not valid: payee of transaction '{transaction.Id}' is not valid");
                    }
                }

                if (transaction.LinkedTransaction != null)
                {
                    if (!ReferenceEquals(transaction.LinkedTransaction.LinkedTransaction, transaction))
                    {
                        throw new MoneizException($"Database is not valid: linked transaction of transaction '{transaction.Id}' is not valid");
                    }

                    if (!Transactions.Any(c => ReferenceEquals(c, transaction.LinkedTransaction)))
                    {
                        throw new MoneizException($"Database is not valid: linked transaction of transaction '{transaction.Id}' is not valid");
                    }
                }
            }
        }
예제 #17
0
        public async Task <IActionResult> PostPayees([FromBody] Payees payees)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _payeesRepository.CreatePayee(payees);
            await _payeesRepository.Save();

            return(CreatedAtAction("GetPayees", new { id = payees.Id }, payees));
        }
예제 #18
0
        /// <summary>
        /// Validate a Payee entity
        /// </summary>
        /// <param name="entityEntry">The Payee entity to be validated.</param>
        /// <param name="result">The collection of results to add new errors to.</param>
        private void ValidatePayeeEntry(DbEntityEntry entityEntry, DbEntityValidationResult result)
        {
            Payee payee = entityEntry.Entity as Payee;

            // Check for uniqueness of Name
            if ((entityEntry.State == EntityState.Added && Payees.Count(p => (p.Name == payee.Name)) > 0) ||
                (entityEntry.State == EntityState.Modified && Payees.Count(p => p.Name == payee.Name && (p.Id != payee.Id)) >= 1))
            {
                result.ValidationErrors.Add(
                    new DbValidationError("Name", "Payee name must be unique."));
            }
        }
        private void btnCreateObR_Click(object sender, EventArgs e)
        {
            {
                item.AppropriationId = frmAddEditPurchaseRequest.cboAccountCode.EditValue.ToInt();
                if (item.AppropriationId == 0 || item.AppropriationId == null)
                {
                    MessageBox.Show("Enter Account Code", "Incomplete Data", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }

                //var pr = new UnitOfWork().ObligationsRepo.Fetch(m => m.PRNo == item.Id);
                //if (pr.Any())
                //{
                //    MessageBox.Show($@"Purchase request has already an obligation request with control no {pr.FirstOrDefault()?.ControlNo }.", @"Existing", MessageBoxButtons.OK,
                //        MessageBoxIcon.Error);
                //    return;
                //}

                var unitOfWork = new UnitOfWork();
                var payee      = unitOfWork.PayeesRepo.Find(m => m.Name == "Earmarked PR");
                if (payee == null)
                {
                    payee = new Payees()
                    {
                        Name = "Earmarked PR",
                    };
                    unitOfWork.PayeesRepo.Insert(payee);
                    unitOfWork.Save();
                }
                frmAddEditObligation frmOBR = new frmAddEditObligation(MethodType.Add, new Obligations()
                {
                    Earmarked = true,
                    ORDetails = new List <ORDetails>()
                    {
                        new ORDetails()
                        {
                            AppropriationId = item.AppropriationId, Particulars = "PR Description"
                        }
                    },
                    PayeeId      = payee?.Id,
                    PayeeAddress = payee?.Address,
                    PayeeOffice  = payee?.Office,
                    PRNo         = item.Id,
                });
                this.Save();
                frmOBR.ShowDialog();
                ((ITransactions <PurchaseRequests>) this).Detail();
            };
        }
예제 #20
0
        public Payee DeletePayee(Payee p)
        {
            Payees payees = myMoney.Payees;

            if (myMoney.GetUsedPayees().Contains(p))
            {
                p = Rename(p);
            }
            else
            {
                payees.RemovePayee(p);
            }
            return(p);
        }
        public void SavePayee(Payee payee)
        {
            using (DeferEvents())
            {
                var existingPayee = Payees.FirstOrDefault(item => item.Id == payee.Id);
                if (existingPayee == null)
                {
                    payee.Id = GenerateId(Payees, item => item.Id);
                }

                AddOrReplace(Payees, existingPayee, payee);
                MergePayees();
                RaiseDatabaseChanged();
            }
        }
예제 #22
0
        public static Guid GetPayeeId()
        {
            Payees payees     = null;
            var    controller = GetClient().Payees;

            try
            {
                payees = controller.GetPayees();
            }
            catch (APIException) { };

            Assert.IsTrue(payees != null);
            Assert.IsTrue(payees.PayeesProp.Count > 0);
            return((Guid)payees.PayeesProp.First().PayeeUid);
        }
예제 #23
0
        public Core.Database ToDatabase2()
        {
            var db = new Core.Database
            {
                Accounts   = Accounts,
                Categories = Categories,
            };

            db.Payees.AddRange(Payees.Select(p => new Core.Payee
            {
                Id   = p.Id,
                Name = p.Name,
                DefaultCategoryId = p.DefaultCategory?.Id,
            }));

            db.Transactions.AddRange(Transactions.Select(t => new Core.Transaction
            {
                AccountId           = t.Account?.Id,
                Amount              = t.Amount,
                CategoryId          = t.Category?.Id,
                CheckedDate         = t.CheckedDate,
                Comment             = t.Comment,
                Id                  = t.Id,
                LinkedTransactionId = t.LinkedTransaction?.Id,
                PayeeId             = t.Payee?.Id,
                ReconciliationDate  = t.ReconciliationDate,
                ValueDate           = t.ValueDate,
            }));

            db.ScheduledTransactions.AddRange(ScheduledTransactions.Select(t => new Core.ScheduledTransaction
            {
                AccountId         = t.Account?.Id,
                Amount            = t.Amount,
                CategoryId        = t.Category?.Id,
                CreditedAccountId = t.CreditedAccount?.Id,
                Id   = t.Id,
                Name = t.Name,
                NextOccurenceDate  = t.NextOccurenceDate,
                PayeeId            = t.Payee?.Id,
                RecurrenceRuleText = t.RecurrenceRuleText,
                StartDate          = t.StartDate,
                Comment            = t.Comment,
            }));

            return(db);
        }
예제 #24
0
        Payee Rename(Payee fromPayee, Payee renameToThisPayee)
        {
            RenamePayeeDialog dialog = RenamePayeeDialog.ShowDialogRenamePayee(this.Site, this.myMoney, fromPayee, renameToThisPayee);

            dialog.Owner = App.Current.MainWindow;
            if (dialog.ShowDialog() == true)
            {
                HashSet <Payee> used = myMoney.GetUsedPayees();
                if (!used.Contains(fromPayee))
                {
                    // remove it now so that our list UI is updated...
                    Payees payees = myMoney.Payees;
                    payees.RemovePayee(fromPayee);
                }
            }
            return(dialog.Payee);
        }
예제 #25
0
        UpdatePayeeAsync(Payees objPayee)
        {
            var ExistingPayee = _context.Payees
                                .Where(x => x.PayeeId == objPayee.PayeeId)
                                .FirstOrDefault();

            if (ExistingPayee != null)
            {
                ExistingPayee.PayeeName = objPayee.PayeeName;
                _context.SaveChanges();
            }
            else
            {
                return(Task.FromResult(false));
            }
            return(Task.FromResult(true));
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        ScheduledPayments.ItemDataBound += new DataGridItemEventHandler(ScheduledPayments_ItemDataBound);

        WeavverMaster.FormTitle = "OFX Bill Pay";
        Guid accountId = new Guid(Request["id"]);

        using (WeavverEntityContainer data = new WeavverEntityContainer())
        {
            Accounting_Accounts financialAccount = (from x in data.Accounting_Accounts
                                                    where x.Id == accountId
                                                    select x).FirstOrDefault();
            if (financialAccount.OrganizationId == LoggedInUser.OrganizationId)
            {
                Accounting_OFXSettings ofxBank = financialAccount.GetOFXSettings();

                Logistics_Addresses address = null;

                billPayment.OFXAppId       = "QWIN";
                billPayment.OFXAppVersion  = "1700";
                billPayment.FIUrl          = ofxBank.Url;
                billPayment.FIId           = ofxBank.FinancialInstitutionId.ToString();
                billPayment.FIOrganization = ofxBank.FinancialInstitutionName;
                billPayment.OFXUser        = ofxBank.Username;
                billPayment.OFXPassword    = ofxBank.Password;

                billPayment.Payment.FromBankId    = ofxBank.BankId;
                billPayment.Payment.FromAccountId = financialAccount.AccountNumber;
                LedgerType lType = (LedgerType)Enum.Parse(typeof(LedgerType), financialAccount.LedgerType);
                billPayment.Payment.FromAccountType = Accounting_OFXSettings.ConvertWeavverLedgerTypeToEbankingAccountType(lType);

                billPayment.SynchronizePayments("REFRESH");
                billPayment.SynchronizePayees("REFRESH");     // do these together so we can poll the info in ItemDataBound

                var items = from x in billPayment.SyncPayments
                            orderby x.DateDue descending
                            select x;
                ScheduledPayments.DataSource = items;
                ScheduledPayments.DataBind();
                Payees.DataSource = billPayment.SyncPayees;
                Payees.DataBind();
            }
        }
    }
        public Payee?GetOrCreatePayeeByName(string?name)
        {
            if (name == null)
            {
                return(null);
            }

            var payee = Payees.FirstOrDefault(item => item.Name == name);

            if (payee == null)
            {
                payee = new Payee {
                    Name = name
                };
                SavePayee(payee);
            }

            return(payee);
        }
예제 #28
0
        //Populate GridView
        public List <Payees> GetPayeesDetails()
        {
            List <Payees> Payeeslist = null;

            try
            {
                Payeeslist = new List <Payees>();
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    using (SqlCommand cmd = new SqlCommand("sp_getAllPayees", conn))
                    {
                        cmd.CommandTimeout = 200;
                        cmd.CommandType    = CommandType.StoredProcedure;
                        dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                        while (dr.Read())
                        {
                            Payees payee = new Payees();

                            payee.Address = (string)dr["Address"];

                            payee.Email     = (string)dr["Email"];
                            payee.Phone     = (string)dr["Phone"];
                            payee.PayeeID   = (string)dr["PayeeID"];
                            payee.PayeeName = (string)dr["PayeeName"];

                            Payeeslist.Add(payee);
                        }
                        dr.Close();
                    }
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("SQL Error : " + ex.Message);
            }
            return(Payeeslist);
        }
예제 #29
0
        private async void OnItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (e.Item == null)
            {
                return;
            }


            //Deselect Item
            ((ListView)sender).SelectedItem = null;

            Payees payee = (Payees)e.Item;

            if (payee != null)
            {
                var filter = new Filter
                {
                    PayeeId = payee.Id
                };
                await Navigation.PushAsync(new PageTransactions(filter));
            }
        }
        public void DeleteItem()
        {
            Payee itemToDelete;

            //1. Get Account from DB
            using (var ctx = new EntitySaveItContext())
            {
                itemToDelete =
                    ctx.Payees.FirstOrDefault(s => s.Id == SelectedItem.Id);
            }

            //Create new context for disconnected scenario
            using (var newContext = new EntitySaveItContext())
            {
                newContext.Entry(itemToDelete).State = System.Data.Entity.EntityState.Deleted;

                try
                {
                    newContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    // TODO review this exception
                    Console.WriteLine(ex);
                    MessageBox.Show("Cannot delete this item");
                }
            }

            // remove the item to be deleted from the list
            if (SelectedItem.IsPayee)
            {
                Payees.Remove(SelectedItem);
            }
            else
            {
                Payers.Remove(SelectedItem);
            }
        }