Code Duplication    Length = 14-16 lines in 2 locations

chezbetty/models/transaction.py 2 locations

@@ 745-760 (lines=16) @@
742
        safe_c = account.get_cash_account("safe")
743
        Transaction.__init__(self, event, None, None, cashbox_c, safe_c, amount)
744
745
746
class EmptySafe(Transaction):
747
    __mapper_args__ = {'polymorphic_identity': 'emptysafe'}
748
    def __init__(self, event, amount):
749
        safe_c = account.get_cash_account("safe")
750
        chezbetty_c = account.get_cash_account("chezbetty")
751
        Transaction.__init__(self, event, None, None, safe_c, chezbetty_c, amount)
752
753
754
class EmptyBitcoin(Transaction):
755
    __mapper_args__ = {'polymorphic_identity': 'emptybitcoin'}
756
    def __init__(self, event, amount):
757
        btnbox_c = account.get_cash_account("btcbox")
758
        chezbetty_c = account.get_cash_account("chezbetty")
759
        Transaction.__init__(self, event, None, None, btnbox_c, chezbetty_c, amount)
760
761
762
class Lost(Transaction):
763
    __mapper_args__ = {'polymorphic_identity': 'lost'}
@@ 424-437 (lines=14) @@
421
                            Transaction.type == 'ccdeposit',
422
                            Transaction.type == 'btcdeposit')))\
423
            .filter(event.Event.deleted==False).one().total or Decimal(0.0)
424
account.Account.total_deposits = __total_deposit_amount
425
426
# This is in a stupid place due to circular input problems
427
@property
428
def __total_purchase_amount(self):
429
    return object_session(self).query(func.sum(Transaction.amount).label("total"))\
430
            .join(event.Event)\
431
            .filter(and_(
432
                        Transaction.fr_account_virt_id == self.id,
433
                        Transaction.type == 'purchase'))\
434
            .filter(event.Event.deleted==False).one().total or Decimal(0.0)
435
account.Account.total_purchases = __total_purchase_amount
436
437
# This is in a stupid place due to circular input problems
438
@classmethod
439
@limitable_all
440
def __get_events_by_type(cls, event_type):