示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("id,Type,ReferenceID,AccountBankAccountID,AmountCredit,AmountDebit,DateTimeModified,DateTimeAdded")] AccountTxn accountTxn)
        {
            if (id != accountTxn.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(accountTxn);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountTxnExists(accountTxn.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(accountTxn));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("id,ReferenceNo,SlipDate,ProviderTradingProfileID,TxnID,AccountBankAccountID,SenderID,SlipAmount,ActualAmount,DateTimeModified,DateTimeAdded")] Slip slip)
        {
            if (ModelState.IsValid)
            {
                slip.DateTimeModified = Utility.GetLocalDateTime();
                slip.DateTimeAdded    = Utility.GetLocalDateTime();
                _context.Add(slip);
                await _context.SaveChangesAsync();

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                //update AccountTxn
                if (slip.ActualAmount != null && slip.ActualAmount > 0)
                {
                    AccountTxn accountTxn = new AccountTxn();
                    accountTxn.Type                 = "S";
                    accountTxn.ReferenceID          = slip.id;
                    accountTxn.AccountBankAccountID = slip.AccountBankAccountID;
                    accountTxn.AmountCredit         = slip.ActualAmount;
                    accountTxn.DateTimeModified     = Utility.GetLocalDateTime();
                    accountTxn.DateTimeAdded        = Utility.GetLocalDateTime();
                    _context.Add(accountTxn);
                    await _context.SaveChangesAsync();
                }
                /////////////////////////////////////////////////////////////////////////////
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.ProviderTradingProfile = new SelectList(_context.TxnView.ToList().Where(x => x.Type != "L").GroupBy(x => x.ProviderTradingProfileID).Select(x => x.First()).OrderBy(x => x.ProviderTradingProfileName), "ProviderTradingProfileID", "ProviderTradingProfileName");
            ViewBag.AccountBankAccount     = new SelectList(_context.AccountBankAccount.OrderBy(x => x.AccountName).ToList(), "id", "AccountName");

            return(View(slip));
        }
示例#3
0
    public async Task MakeReservation(AccountTxn accountTxn)
    {
        await _bankAccount.AddTxn(accountTxn);

        _accountTxns.Add(accountTxn);

        OnAccountTxnMade(accountTxn);
    }
示例#4
0
        public async Task <IActionResult> Create([Bind("id,Type,ReferenceID,AccountBankAccountID,AmountCredit,AmountDebit,DateTimeModified,DateTimeAdded")] AccountTxn accountTxn)
        {
            if (ModelState.IsValid)
            {
                _context.Add(accountTxn);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(accountTxn));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("id,ReferenceNo,AccountBankAccountIDFrom,AccountBankAccountIDTo,Amount,Rate,ActualDate,Reference,DateTimeModified,DateTimeAdded")] AccountTransfer accountTransfer)
        {
            if (ModelState.IsValid)
            {
                accountTransfer.DateTimeModified = Utility.GetLocalDateTime();
                accountTransfer.DateTimeAdded    = Utility.GetLocalDateTime();
                _context.Add(accountTransfer);
                await _context.SaveChangesAsync();

                /////////////////////////////////////////////////////////////////////////////
                //update AccountTxn
                AccountTxn accountTxnFrom = new AccountTxn();
                accountTxnFrom.Type                 = "T";
                accountTxnFrom.ReferenceID          = accountTransfer.id;
                accountTxnFrom.AccountBankAccountID = accountTransfer.AccountBankAccountIDFrom;
                accountTxnFrom.AmountDebit          = accountTransfer.Amount;
                accountTxnFrom.DateTimeModified     = Utility.GetLocalDateTime();
                accountTxnFrom.DateTimeAdded        = Utility.GetLocalDateTime();
                _context.Add(accountTxnFrom);

                AccountTxn accountTxnTo = new AccountTxn();
                accountTxnTo.Type                 = "T";
                accountTxnTo.ReferenceID          = accountTransfer.id;
                accountTxnTo.AccountBankAccountID = accountTransfer.AccountBankAccountIDTo;
                accountTxnTo.AmountCredit         = accountTransfer.Amount * accountTransfer.Rate;
                accountTxnTo.DateTimeModified     = Utility.GetLocalDateTime();
                accountTxnTo.DateTimeAdded        = Utility.GetLocalDateTime();
                _context.Add(accountTxnTo);
                /////////////////////////////////////////////////////////////////////////////

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.AccountBankAccount = new SelectList(_context.AccountBankAccount.OrderBy(m => m.AccountName).ToList(), "id", "AccountName");

            return(View(accountTransfer));
        }
示例#6
0
        public async Task <IActionResult> Create([Bind("id,ReferenceNo,AccountBankAccountID,Amount,ActualDate,Reference,DateTimeModified,DateTimeAdded")] AccountAdjust accountAdjust)
        {
            if (ModelState.IsValid)
            {
                accountAdjust.DateTimeModified = Utility.GetLocalDateTime();// Utility.GetLocalDateTime();
                accountAdjust.DateTimeAdded    = Utility.GetLocalDateTime();
                _context.Add(accountAdjust);
                await _context.SaveChangesAsync();

                /////////////////////////////////////////////////////////////////////////////
                //update AccountTxn
                AccountTxn accountTxn = new AccountTxn();
                accountTxn.Type                 = "A";
                accountTxn.ReferenceID          = accountAdjust.id;
                accountTxn.AccountBankAccountID = accountAdjust.AccountBankAccountID;
                if (accountAdjust.Amount >= 0)
                {
                    accountTxn.AmountCredit = accountAdjust.Amount;
                }
                else
                {
                    accountTxn.AmountDebit = Math.Abs(accountAdjust.Amount);
                }

                accountTxn.DateTimeModified = Utility.GetLocalDateTime();
                accountTxn.DateTimeAdded    = Utility.GetLocalDateTime();
                _context.Add(accountTxn);
                /////////////////////////////////////////////////////////////////////////////

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.AccountBankAccount = new SelectList(_context.AccountBankAccount.OrderBy(m => m.AccountName).ToList(), "id", "AccountName");
            return(View(accountAdjust));
        }
    public override async Task ExecuteAsync(object?parameter)
    {
        var accountTxn = new AccountTxn(
            new TxnTypeID(_makeAcntTxnVM.ID, _makeAcntTxnVM.Name), _makeAcntTxnVM.TxnTime, _makeAcntTxnVM.TxnAmnt.ToString());

        try
        {
            await _bankAccountStore.MakeReservation(accountTxn);

            MessageBox.Show("Success adding Txn");

            _makeAcntTcnViewnavigationService.Navigate();
        }
        catch (TxnConflictException) { WriteLine($"!!> Txn already there "); if (Debugger.IsAttached)
                                       {
                                           Debugger.Break();
                                       }
                                       MessageBox.Show($"!!> Txn already there "); }
        catch (Exception ex) { WriteLine($"!!> {ex}"); if (Debugger.IsAttached)
                               {
                                   Debugger.Break();
                               }
                               MessageBox.Show(ex.Message, "Failed to add Txn"); }
    }
示例#8
0
        public async Task <IActionResult> Edit(int id, [Bind("id,ReferenceNo,AccountBankAccountIDFrom,AccountBankAccountIDTo,Amount,Rate,ActualDate,Reference,DateTimeModified,DateTimeAdded")] AccountTransfer accountTransfer)
        {
            if (id != accountTransfer.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    accountTransfer.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(accountTransfer);

                    /////////////////////////////////////////////////////////////////////////////
                    //update AccountTxn
                    var accountTxn = await _context.AccountTxn.Where(m => m.Type == "T" && m.ReferenceID == id).ToListAsync();

                    if (accountTxn != null)
                    {
                        _context.AccountTxn.RemoveRange(accountTxn);
                    }

                    AccountTxn accountTxnFrom = new AccountTxn();
                    accountTxnFrom.Type                 = "T";
                    accountTxnFrom.ReferenceID          = id;
                    accountTxnFrom.AccountBankAccountID = accountTransfer.AccountBankAccountIDFrom;
                    accountTxnFrom.AmountDebit          = accountTransfer.Amount;
                    accountTxnFrom.DateTimeModified     = Utility.GetLocalDateTime();
                    accountTxnFrom.DateTimeAdded        = Utility.GetLocalDateTime();
                    _context.Add(accountTxnFrom);

                    AccountTxn accountTxnTo = new AccountTxn();
                    accountTxnTo.Type                 = "T";
                    accountTxnTo.ReferenceID          = id;
                    accountTxnTo.AccountBankAccountID = accountTransfer.AccountBankAccountIDTo;
                    accountTxnTo.AmountCredit         = accountTransfer.Amount * accountTransfer.Rate;
                    accountTxnTo.DateTimeModified     = Utility.GetLocalDateTime();
                    accountTxnTo.DateTimeAdded        = Utility.GetLocalDateTime();
                    _context.Add(accountTxnTo);
                    /////////////////////////////////////////////////////////////////////////////

                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountTransferExists(accountTransfer.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.AccountBankAccount = new SelectList(_context.AccountBankAccount.OrderBy(m => m.AccountName).ToList(), "id", "AccountName");

            return(View(accountTransfer));
        }
示例#9
0
 public AccountTxnVM(AccountTxn accountTxn) => _accountTxn = accountTxn;
示例#10
0
        public async Task <IActionResult> Create([Bind("id,ReferenceNo,TxnID,ClientPayoutAmount,ClientPayoutUSDRate,ProviderPayinUSDRate,UsedCurrencyID,UsedAmount,UsedClientPayoutFXRate,UsedUSDRate,AccountBankAccountID,DateTimeModified,DateTimeAdded")] Payout payout)
        {
            if (ModelState.IsValid)
            {
                payout.DateTimeModified = Utility.GetLocalDateTime();
                payout.DateTimeAdded    = Utility.GetLocalDateTime();

                _context.Add(payout);
                await _context.SaveChangesAsync();

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                //check ClientPayoutMissing, update Status
                var reportTxn = await _context.ReportTxnOriginal.AsNoTracking().SingleOrDefaultAsync(m => m.TxnID == payout.TxnID);

                if (reportTxn != null)
                {
                    var txn = await _context.Txn.AsNoTracking().SingleOrDefaultAsync(m => m.id == payout.TxnID);

                    if (txn != null)
                    {
                        if (reportTxn.ClientPayoutMissing < reportTxn.ClientAmountOut && reportTxn.ClientPayoutMissing > 0)
                        {
                            txn.Status = "P";
                        }
                        else if (reportTxn.ClientPayoutMissing <= 0)
                        {
                            txn.Status = "C";
                        }
                        else
                        {
                            txn.Status = "";
                        }

                        _context.Update(txn);
                        await _context.SaveChangesAsync();
                    }
                }
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                //update AccountTxn
                AccountTxn accountTxn = new AccountTxn();
                accountTxn.Type                 = "P";
                accountTxn.ReferenceID          = payout.id;
                accountTxn.AccountBankAccountID = payout.AccountBankAccountID;
                accountTxn.AmountDebit          = payout.ClientPayoutAmount;
                accountTxn.DateTimeModified     = Utility.GetLocalDateTime();
                accountTxn.DateTimeAdded        = Utility.GetLocalDateTime();
                _context.Add(accountTxn);
                await _context.SaveChangesAsync();

                /////////////////////////////////////////////////////////////////////////////
                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.ClientTradingProfile = new SelectList(_context.TxnView.Where(t => t.Type != "D" && t.Status != "C" && t.PayoutDone)
                                                          .Select(t => new
            {
                id   = t.ClientTradingProfileID,
                text = t.ClientTradingProfileName
            }).Distinct().OrderBy(t => t.text).ToList(), "id", "text");

            ViewBag.Txn = new SelectList(_context.TxnView.Where(t => t.Type != "D" && t.Status != "C" && t.PayoutDone).OrderBy(m => m.ReferenceNo)
                                         .Select(t => new
            {
                id   = t.id,
                text = t.ClientTradingProfileName + ", " + t.TradeDate.ToString() + ", " + (t.ClientAmountOut.ToString() ?? "") + ", " + (t.ClientCurrencyNameOut ?? "") + ", " + t.ReferenceNo
            }).ToList(), "id", "text");
            ViewBag.Currency           = new SelectList(_context.Currency.OrderBy(m => m.CurrencyName).ToList(), "id", "CurrencyName");
            ViewBag.AccountBankAccount = new SelectList(_context.AccountBankAccount.OrderBy(x => x.AccountName).ToList(), "id", "AccountName");

            return(View(payout));
        }
 public TxnConflictException(AccountTxn existingAccountTxn, AccountTxn incomingAccountTxn)
 {
     ExistingAccountTxn = existingAccountTxn;
     IncomingAccountTxn = incomingAccountTxn;
 }
示例#12
0
        public async Task <IActionResult> Edit(int id, [Bind("id,ReferenceNo,SlipDate,ProviderTradingProfileID,TxnID,AccountBankAccountID,SenderID,SlipAmount,ActualAmount,DateTimeModified,DateTimeAdded")] Slip slip)
        {
            if (id != slip.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    slip.DateTimeModified = Utility.GetLocalDateTime();
                    _context.Update(slip);

                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////
                    //update AccountTxn
                    var accountTxn = await _context.AccountTxn.AsNoTracking().SingleOrDefaultAsync(m => m.Type == "S" && m.ReferenceID == id);

                    if (accountTxn != null)
                    {
                        _context.AccountTxn.Remove(accountTxn);
                    }

                    if (slip.ActualAmount != null && slip.ActualAmount > 0)
                    {
                        accountTxn                      = new AccountTxn();
                        accountTxn.Type                 = "S";
                        accountTxn.ReferenceID          = id;
                        accountTxn.AccountBankAccountID = slip.AccountBankAccountID;
                        accountTxn.AmountCredit         = slip.ActualAmount;
                        accountTxn.DateTimeModified     = Utility.GetLocalDateTime();
                        accountTxn.DateTimeAdded        = Utility.GetLocalDateTime();
                        _context.Add(accountTxn);
                    }
                    ///////////////////////////////////////////////////////////////////////////////////////////////////////////

                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SlipExists(slip.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.ProviderTradingProfile = new SelectList(_context.TxnView.ToList().Where(x => x.Type != "L").GroupBy(x => x.ProviderTradingProfileID).Select(x => x.First()).OrderBy(x => x.ProviderTradingProfileName), "ProviderTradingProfileID", "ProviderTradingProfileName");
            ViewBag.AccountBankAccount     = new SelectList(_context.AccountBankAccount.OrderBy(x => x.AccountName).ToList(), "id", "AccountName");

            var providerTradingProfile = _context.ProviderTradingProfile.FirstOrDefault(x => x.id == slip.ProviderTradingProfileID);

            ViewBag.Sender = new SelectList(_context.Sender.ToList().Where(x => x.ProviderID == providerTradingProfile.ProviderID).OrderBy(x => x.SenderName), "id", "SenderName");
            ViewBag.Txn    = new SelectList(_context.Txn.ToList().Where(x => x.ProviderTradingProfileID == slip.ProviderTradingProfileID).OrderBy(x => x.ReferenceNo), "id", "ReferenceNo");

            return(View(slip));
        }
示例#13
0
 private void OnAccountTxnMade(AccountTxn accountTxn)
 {
     AccountTxnsMade?.Invoke(accountTxn);
 }
示例#14
0
 public async Task AddTxn(AccountTxn accountTxn) => await _txnBook.AddTxn(accountTxn);
示例#15
0
 public bool Conflicts(AccountTxn accountTxn) => accountTxn.TxnTime - TxnTime < new TimeSpan(24, 0, 0) && // if on the same date
 accountTxn.TxnAmount - TxnAmount < .01m;                                                                 // if of the same value