Ejemplo n.º 1
0
    def test_merge(self):
        r1 = refund()
        r2 = refund()

        merged = Refund.merge([r1, r2])

        self.assertEqual(len(merged), 1)
        self.assertEqual(merged[0].title, r1.title)
        self.assertEqual(merged[0].quantity, 4)
        self.assertEqual(merged[0].total_refund_amount, 47800000)
        self.assertEqual(merged[0].refund_amount, 43600000)
        self.assertEqual(merged[0].refund_tax_amount, 4200000)
Ejemplo n.º 2
0
    def test_sum_total_refunds(self):
        self.assertEqual(Refund.sum_total_refunds([]), 0)

        r1 = refund(refund_amount='$0.43', refund_tax_amount='$0.40')
        self.assertEqual(Refund.sum_total_refunds([r1]), 830000)

        r2 = refund(refund_amount='$0.00', refund_tax_amount='$0.00')
        self.assertEqual(Refund.sum_total_refunds([r1, r2]), 830000)
        self.assertEqual(Refund.sum_total_refunds([r2, r1]), 830000)

        r3 = refund(refund_amount='$2.11', refund_tax_amount='$1.40')
        self.assertEqual(Refund.sum_total_refunds([r2, r1, r3]), 4340000)
    def test_get_mint_updates_simple_match_refund(self):
        r1 = refund(
            title='Cool item',
            refund_amount='$10.95',
            refund_tax_amount='$1.00',
            refund_date='3/12/14')
        t1 = transaction(amount='$11.95', is_debit=False, date='3/12/14')

        stats = Counter()
        updates, _ = tagger.get_mint_updates(
            [], [], [r1],
            [t1],
            get_args(), stats)

        self.assertEqual(len(updates), 1)
        orig_t, new_trans = updates[0]
        self.assertTrue(orig_t is t1)
        self.assertEqual(len(new_trans), 1)
        self.assertEqual(new_trans[0].merchant, 'Amazon.com: 2x Cool item')
        self.assertEqual(new_trans[0].category, 'Clothing')
        self.assertEqual(new_trans[0].amount, -11950000)
        self.assertFalse(new_trans[0].is_debit)
        self.assertFalse(new_trans[0].is_child)

        self.assertEqual(stats['new_tag'], 1)
Ejemplo n.º 4
0
    def test_get_note(self):
        r = refund()

        self.assertTrue(
            'Amazon refund for order id: 123-3211232-7655671' in r.get_note())
        self.assertTrue('Buyer: Some Great Buyer' in r.get_note())
        self.assertTrue('Order date: 2014-02-26' in r.get_note())
        self.assertTrue('Refund date: 2014-03-16' in r.get_note())
        self.assertTrue('Refund reason: Customer Return' in r.get_note())
Ejemplo n.º 5
0
    def test_to_mint_transaction(self):
        r = refund(title='Duracell Procell AA 24 Pack')
        t = transaction(amount='$11.95', is_debit=False)

        new_trans = r.to_mint_transaction(t)

        self.assertEqual(new_trans.id, t.id)
        self.assertEqual(new_trans.amount, t.amount)
        self.assertEqual(new_trans.merchant, '2x Duracell Procell AA 24 Pack')
        self.assertFalse(new_trans.is_debit)
Ejemplo n.º 6
0
    def test_match(self):
        r = refund()

        self.assertFalse(r.matched)
        self.assertEqual(r.trans_id, None)

        r.match(transaction(id='ABC'))

        self.assertTrue(r.matched)
        self.assertEqual(r.trans_id, 'ABC')
Ejemplo n.º 7
0
    def test_constructor(self):
        r = refund()

        self.assertEqual(r.order_id, '123-3211232-7655671')
        self.assertEqual(r.quantity, 2)

        # Currency fields are all in microusd.
        self.assertEqual(r.refund_amount, 10900000)
        self.assertEqual(r.refund_tax_amount, 1050000)

        # Dates are parsed:
        self.assertEqual(r.order_date, date(2014, 2, 26))
        self.assertEqual(r.refund_date, date(2014, 3, 16))
Ejemplo n.º 8
0
 def test_get_title(self):
     self.assertEqual(
         refund(title='Great item').get_title(), '2x Great item')
Ejemplo n.º 9
0
 def test_transact_amount(self):
     self.assertEqual(refund().transact_amount(), -11950000)
Ejemplo n.º 10
0
 def test_transact_date(self):
     self.assertEqual(refund().transact_date(), date(2014, 3, 16))