Exemplo n.º 1
0
def delete_transaction(request, account, transaction):
    transaction = get_object_or_404(Transaction, pk=transaction, account=account, account__user=request.user)
    
    transaction.delete()

    messages.add_message(request, messages.SUCCESS, _('Your transaction was succesfully deleted'))

    return redirect(reverse('moneydj.accounts.views.view', args=[account]))
Exemplo n.º 2
0
 def delete(self, request, transaction_id):
   transaction = Transaction.objects.get(
       id=transaction_id)
   if transaction.reconciled:
     return {'success': False}
   else:
     transaction.delete()
     return {'success': True}
Exemplo n.º 3
0
 def delete(self, request, order_id):
   order = Order.objects.get(
       id=order_id)
   if order.reconciled:
     return {'success': False}
   else:
     transaction = Transaction.objects.get(order=order)
     transaction.delete()
     return {'success': True}
Exemplo n.º 4
0
def main():
    print "Resetting all account balances to 0"
    print "to cancel and not reset anything, press Ctrl-C NOW"
    accounts = models.Account.objects.all()
    for account in accounts:
        account.balance = 0
        account.deposit = 0
        account.save()

    print "Deleting all transaction history"
    transactions = a_models.Transaction.objects.all()
    for transaction in transactions:
        transaction.delete()
Exemplo n.º 5
0
    def delete_transaction(self, transaction: models.Transaction) -> None:
        position = transaction.position
        account = position.account
        if transaction.events.count():
            raise CantModifyTransactionWithEvent(
                "Can't delete a transaction associated with an event, without deleting the event first."
            )

        # This assumes no splits and merges support.
        position.quantity -= transaction.quantity
        position.save()
        account.balance -= transaction.total_in_account_currency
        account.save()
        transaction.delete()
        gains.update_lots(position)
        position.quantity_history.cache_clear()
        position.value_history.cache_clear()
Exemplo n.º 6
0
def delete_transaction(request, id):
    """
    Delete a transaction.
    """
    transaction = get_object_or_404(Transaction, pk=id, user=request.user)
    if request.method == 'POST':
        form = DeleteForm(data=request.POST)
        if form.is_valid():
            transaction.delete()
            return redirect(transaction.account)
    else:
        form = DeleteForm()
    return render(
        request, 'pages/delete.html', {
            'title': "Delete Transaction",
            'description': "You are about to delete {}.".format(transaction),
            'breadcrumbs': [transaction.account, transaction],
            'form': form,
        })
Exemplo n.º 7
0
def delete_transaction(request, id):
    """
    Delete a transaction.
    """
    transaction = get_object_or_404(Transaction, pk=id, user=request.user)
    if request.method == 'POST':
        form = DeleteForm(data=request.POST)
        if form.is_valid():
            transaction.delete()
            return redirect(transaction.account)
    else:
        form = DeleteForm()
    return render(request, 'ledger/pages/delete.html', {
        'title': "Delete Transaction",
        'description': "You are about to delete {}.".format(transaction),
        'breadcrumbs': [transaction.account, transaction],
        'form': form,
        'related': (transaction.linked,) if transaction.linked else (),
    })
Exemplo n.º 8
0
 def DeleteTransaction(transaction: Transaction):
     transaction.delete()
     return transaction
Exemplo n.º 9
0
 def delete(self, using=None, keep_parents=False):
     if (transaction := self.transaction) is not None:
         transaction.delete()