Ejemplo n.º 1
0
        public async Task Payment_CreateDebt()
        {
            //Create a payment of 10GBP from 0 -> 1
            await _db.InsertUnconfirmedPayment(0, 1, 10, "gbp", "note", "guid");

            //Confirm that payment
            var confirmed = await _db.ConfirmPending("guid", 1);

            Assert.IsTrue(confirmed.HasValue);
            Assert.AreEqual(10, (int)confirmed.Value.Amount);
            Assert.AreEqual(0, (int)confirmed.Value.PayerId);
            Assert.AreEqual(1, (int)confirmed.Value.ReceiverId);

            //Now check that the balance between 0 and 1 is correct (1 owes 10GBP to 0)
            var owed1 = (await _db.GetOwed(1)).ToArray();

            Assert.AreEqual(1, owed1.Length);
            var owedSingle = owed1.Single();

            Assert.AreEqual(10, owedSingle.Amount);
            Assert.AreEqual(1, (int)owedSingle.BorrowerId);
            Assert.AreEqual(0, (int)owedSingle.LenderId);
            Assert.AreEqual("gbp", owedSingle.Unit);
        }
Ejemplo n.º 2
0
Archivo: Iou.cs Proyecto: sachgits/Mute
        public async Task ConfirmPendingPayment(string id)
        {
            using (Context.Channel.EnterTypingState())
            {
                var result = await _database.ConfirmPending(id);

                if (result.HasValue)
                {
                    await ReplyAsync($"{Context.User.Mention} Confirmed transaction of {FormatCurrency(result.Value.Amount, result.Value.Unit)} from {Context.Client.GetUser(result.Value.PayerId).Mention} to {Context.Client.GetUser(result.Value.ReceiverId).Mention}");
                }
                else
                {
                    await ReplyAsync($"{Context.User.Mention} I can't find a pending payment with that ID");
                }
            }
        }