Ejemplo n.º 1
0
 def __repr__(self):
     return '{qty} of Item: Total {total}\tSubtotal {subtotal}\tTax {tax} {desc}'.format(
         qty=self.quantity,
         total=micro_usd_to_usd_string(self.item_total),
         subtotal=micro_usd_to_usd_string(self.item_subtotal),
         tax=micro_usd_to_usd_string(self.item_subtotal_tax),
         desc=self.title)
Ejemplo n.º 2
0
 def __repr__(self):
     return '{qty} of Refund: Total {total}\tSubtotal {subtotal}\tTax {tax} {desc}'.format(
         qty=self.quantity,
         total=micro_usd_to_usd_string(self.total_refund_amount),
         subtotal=micro_usd_to_usd_string(self.refund_amount),
         tax=micro_usd_to_usd_string(self.refund_tax_amount),
         desc=self.title)
Ejemplo n.º 3
0
 def __repr__(self):
     return 'Order ({id}): {date} Total {total}\tSubtotal {subtotal}\tTax {tax}\tPromo {promo}\tShip {ship}\tItems: \n{items}'.format(
         id=self.order_id,
         date=(self.shipment_date or self.order_date),
         total=micro_usd_to_usd_string(self.total_charged),
         subtotal=micro_usd_to_usd_string(self.subtotal),
         tax=micro_usd_to_usd_string(self.tax_charged),
         promo=micro_usd_to_usd_string(self.total_promotions),
         ship=micro_usd_to_usd_string(self.shipping_charge),
         items=pformat(self.items))
Ejemplo n.º 4
0
 def get_compare_tuple(self):
     """Returns a 3-tuple used to determine if 2 transactions are equal."""
     # TODO: Add the 'note' field once itemized transactions include notes.
     return (
         self.merchant,
         micro_usd_to_usd_string(self.amount),  # str avoids float cmp
         self.category)
Ejemplo n.º 5
0
 def __repr__(self):
     has_note = 'with note' if self.note else ''
     return 'Mint Trans({id}): {amount} {date} {merchant} {category} {has_note}'.format(
         id=self.id,
         amount=micro_usd_to_usd_string(self.amount),
         date=self.date,
         merchant=self.merchant,
         category=self.category,
         has_note=has_note)
Ejemplo n.º 6
0
def print_unmatched(amzn_obj):
    proposed_mint_desc = mint.summarize_title(
        [i.get_title() for i in amzn_obj.items]
        if amzn_obj.is_debit else [amzn_obj.get_title()],
        '{}{}: '.format(amzn_obj.website,
                        '' if amzn_obj.is_debit else ' refund'))
    logger.warning('{}'.format(proposed_mint_desc))
    logger.warning('\t{}\t{}\t{}'.format(
        amzn_obj.transact_date()
        if amzn_obj.transact_date() else 'Never shipped!',
        micro_usd_to_usd_string(amzn_obj.transact_amount()),
        amazon.get_invoice_url(amzn_obj.order_id)))
    logger.warning('')
Ejemplo n.º 7
0
def log_amazon_stats(items, orders, refunds):
    logger.info('\nAmazon Stats:')
    first_order_date = min([o.order_date for o in orders])
    last_order_date = max([o.order_date for o in orders])
    logger.info('\n{} orders with {} matching items'.format(
        len([o for o in orders if o.items_matched]),
        len([i for i in items if i.matched])))
    logger.info('{} unmatched orders and {} unmatched items'.format(
        len([o for o in orders if not o.items_matched]),
        len([i for i in items if not i.matched])))
    logger.info('Orders ranging from {} to {}'.format(first_order_date,
                                                      last_order_date))

    per_item_totals = [i.item_total for i in items]
    per_order_totals = [o.total_charged for o in orders]

    logger.info('{} total spend'.format(
        micro_usd_to_usd_string(sum(per_order_totals))))

    logger.info('{} avg order total (range: {} - {})'.format(
        micro_usd_to_usd_string(sum(per_order_totals) / len(orders)),
        micro_usd_to_usd_string(min(per_order_totals)),
        micro_usd_to_usd_string(max(per_order_totals))))
    logger.info('{} avg item price (range: {} - {})'.format(
        micro_usd_to_usd_string(sum(per_item_totals) / len(items)),
        micro_usd_to_usd_string(min(per_item_totals)),
        micro_usd_to_usd_string(max(per_item_totals))))

    if refunds:
        first_refund_date = min(
            [r.refund_date for r in refunds if r.refund_date])
        last_refund_date = max(
            [r.refund_date for r in refunds if r.refund_date])
        logger.info('\n{} refunds dating from {} to {}'.format(
            len(refunds), first_refund_date, last_refund_date))

        per_refund_totals = [r.total_refund_amount for r in refunds]

        logger.info('{} total refunded'.format(
            micro_usd_to_usd_string(sum(per_refund_totals))))
Ejemplo n.º 8
0
 def dry_run_str(self, ignore_category=False):
     return '{} \t {} \t {} \t {}'.format(
         self.date.strftime('%m/%d/%y'),
         micro_usd_to_usd_string(self.amount),
         '--IGNORED--' if ignore_category else '{}({})'.format(
             self.category, self.category_id), self.merchant)
Ejemplo n.º 9
0
 def get_compare_tuple(self, ignore_category=False):
     """Returns a 3-tuple used to determine if 2 transactions are equal."""
     # TODO: Add the 'note' field once itemized transactions include notes.
     # Use str to avoid float cmp.
     base = (self.merchant, micro_usd_to_usd_string(self.amount), self.note)
     return base if ignore_category else base + (self.category, )
 def test_micro_usd_to_usd_string(self):
     self.assertEqual(currency.micro_usd_to_usd_string(1230040), '$1.23')
     self.assertEqual(currency.micro_usd_to_usd_string(-123000), '-$0.12')
     self.assertEqual(currency.micro_usd_to_usd_string(-1900), '$0.00')
     self.assertEqual(currency.micro_usd_to_usd_string(-10000), '-$0.01')
Ejemplo n.º 11
0
 def dry_run_str(self):
     return '{} \t {} \t {} \t {}'.format(
         self.date.strftime('%m/%d/%y'),
         micro_usd_to_usd_string(self.amount), self.category, self.merchant)