Skip to content

Commit

Permalink
fix errors pointed by IDE
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmurilo75 committed Mar 6, 2024
1 parent 0cdbfa6 commit 9edb502
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 9 deletions.
33 changes: 33 additions & 0 deletions development_notebook/2024-03-06.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Current State

See [[2024-03-05]] for previous log.

To perform tasks required in the previous log some environment configuration was nedded - namedly, configure code completion and go to definiton.

# Today

The environment has been further configured. Add relevant information to [[Configuration Work]].
Most relevant usage of tools are in [[tools]]. This is to be updated as commands become trivial and new commands are learned.

Work continued on from last log.

## Work Log

__InProgress__
~~* Implement improved solution.~~
~~- It does not - Requires change from timezone to datetime~~

* Define balance property, as well as relevant new db fields - assuming fields defined in Transaction.

__ToDo__
* Define fields and functions in Transaction. Check FieldTracker in model\_utils.
* Migrate.
* Test on admin.

__Done__
* Fix errors called out by IDE.


# To Do
[[Configuration Work]] Configure git actions to not lint these logs.
[[tools]]
16 changes: 16 additions & 0 deletions development_notebook/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,27 @@ tmux attach-session -t \<session name\>

## NVim

:sp \<filepath\>
? Split vertical

:vsp \<filepath\>
? Split horizontal

### TODO -> Include plugin commands

## Bash

`w`
? Shows processes running

`ESC + b`
? Equivalent to `Ctrl + \<left arrow\>`

`ESC + l`
? Equivalent to `Ctrl + \<right arrow\>`

`ESC + \<Backspace\>`
? Equivalent to `Ctrl + \<Backspace\>`

`Ctrl + R` then `Enter`
? Search command history. Press `Enter` for next result.
19 changes: 10 additions & 9 deletions negligent_octopus/core/models.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
from datetime import datetime
from django.db import models
from django.utils import timezone
from model_utils.models import SoftDeletableModel
from model_utils.models import TimeStampedModel


from negligent_octopus.users.models import User


class Account(TimeStampedModel, SoftDeletableModel):
owner = models.ForeignKey(User, on_delete=models.CASCADE)
name = models.CharField(max_length=255)
calculated_balance = models.FloatField(default=0.0, editable=False)
calculated_at = models.DateTimeField(default=datetime.now) # Uses datetime.datetime instead of auto_add_now because the latter uses django.timezone
calculated_at = models.DateTimeField(auto_now_add=True)

@propery
@property
def balance(self):
# Set calculated_at to now (now_at)
# Get relevant transaction (Get creation or modified after now_at)
# For each do a running sum, taking in consideration delta of all modifications after now_at
# Check for any modification on is_removed and consider into the delta (just negative of last calculation - is this correct?)
# For each do a running sum
# taking in consideration delta of all modifications after now_at
# Check for any modification on is_removed (just negative of last calculation?)
# Update calculated_balance and return it
# #IMPROVE : Evaluate using atomic or another techinique to prevent conflicts on reading and updating
# #IMPROVE : Evaluate using atomic or another techinique to prevent conflicts
pass

def __str__(self):
return self.name

class Meta:
class Meta(TimeStampedModel.Meta, SoftDeletableModel.Meta):
verbose_name = "Account"
verbose_name_plural = "Accounts"
ordering = ["-modified", "name"]
Expand All @@ -44,7 +45,7 @@ def get_account_owner(self):
def __str__(self):
return self.title

class Meta:
class Meta(TimeStampedModel.Meta):
verbose_name = "Transaction"
verbose_name_plural = "Transactions"
ordering = ["date", "-modified"]

0 comments on commit 9edb502

Please sign in to comment.