(lazy_original_balance, report_type, quantity)
return LedgerValues(new_balance, new_delta)
lazy_original_balance:
        a zero-argument function returning original balance
        the original_balance is only used in the case of a transfer
        and it may be computationally expensive for the caller to provide
        putting it behind a function lets compute_ledger_values decide
        whether it's necessary to do that work
    report_type:
        REPORT_TYPE_BALANCE or REPORT_TYPE_TRANSFER
    quantity:
        the associated quantity, interpreted as a delta for transfers
        and a total balance for balances
lazy_original_balance:
        a zero-argument function returning original balance
        the original_balance is only used in the case of a transfer
        and it may be computationally expensive for the caller to provide
        putting it behind a function lets compute_ledger_values decide
        whether it's necessary to do that work
    report_type:
        REPORT_TYPE_BALANCE or REPORT_TYPE_TRANSFER
    quantity:
        the associated quantity, interpreted as a delta for transfers
        and a total balance for balances
lazy_original_balance : a zero - argument function returning original balance the original_balance is only used in the case of a transfer and it may be computationally expensive for the caller to provide putting it behind a function lets compute_ledger_values decide whether it s necessary to do that work report_type : REPORT_TYPE_BALANCE or REPORT_TYPE_TRANSFER quantity : the associated quantity interpreted as a delta for transfers and a total balance for balances
def compute_ledger_values(lazy_original_balance, report_type, quantity):
    """
    lazy_original_balance:
        a zero-argument function returning original balance
        the original_balance is only used in the case of a transfer
        and it may be computationally expensive for the caller to provide
        putting it behind a function lets compute_ledger_values decide
        whether it's necessary to do that work
    report_type:
        REPORT_TYPE_BALANCE or REPORT_TYPE_TRANSFER
    quantity:
        the associated quantity, interpreted as a delta for transfers
        and a total balance for balances

    """
    if report_type == stockconst.REPORT_TYPE_BALANCE:
        new_balance = quantity
        # this is currently always 0 because of inferred transactions
        new_delta = 0
    elif report_type == stockconst.REPORT_TYPE_TRANSFER:
        original_balance = lazy_original_balance()
        new_delta = quantity
        new_balance = new_delta + (original_balance if original_balance else 0)
    else:
        raise ValueError()
    return LedgerValues(new_balance, new_delta)
def compute_ledger_values ( lazy_original_balance , report_type , quantity ) : if report_type == stockconst . REPORT_TYPE_BALANCE : new_balance = quantity # this is currently always 0 because of inferred transactions new_delta = 0 elif report_type == stockconst . REPORT_TYPE_TRANSFER : original_balance = lazy_original_balance ( ) new_delta = quantity new_balance = new_delta + ( original_balance if original_balance else 0 ) else : raise ValueError ( ) return LedgerValues ( new_balance , new_delta )