Skip to content

Commit

Permalink
Merge pull request #229 from edelgm6/je-refactor
Browse files Browse the repository at this point in the history
Je refactor
  • Loading branch information
edelgm6 authored Jul 25, 2024
2 parents 039125a + 5f79b04 commit 9a9906c
Show file tree
Hide file tree
Showing 13 changed files with 438 additions and 381 deletions.
4 changes: 3 additions & 1 deletion api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class PrefillAdmin(admin.ModelAdmin):
def description(self, obj):
return obj.name

class PaystubAdmin(admin.ModelAdmin):
list_display = ('title', 'journal_entry')

# Register your models here
admin.site.register(Prefill, PrefillAdmin)
Expand All @@ -84,5 +86,5 @@ def description(self, obj):
admin.site.register(PrefillItem)
admin.site.register(S3File)
admin.site.register(DocSearch)
admin.site.register(Paystub)
admin.site.register(Paystub, PaystubAdmin)
admin.site.register(PaystubValue)
10 changes: 8 additions & 2 deletions api/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ def save(self):
hero_transaction.create_link(linked_transaction)
return hero_transaction

class JournalEntryMetadataForm(forms.Form):
index = forms.IntegerField(min_value=0, widget=forms.HiddenInput())
paystub_id = forms.CharField(widget=forms.HiddenInput(), required=False)


class BaseJournalEntryItemFormset(BaseModelFormSet):

Expand All @@ -299,7 +303,10 @@ def __init__(self, *args, **kwargs):
def get_entry_total(self):
total = 0
for form in self.forms:
amount = form.cleaned_data.get('amount')
try:
amount = form.cleaned_data.get('amount')
except AttributeError:
amount = form.initial.get('amount', None)
total += (amount if amount is not None else 0)

return total
Expand Down Expand Up @@ -331,7 +338,6 @@ def save(self, transaction, type, commit=True):

return instances


class JournalEntryItemForm(forms.ModelForm):
amount = CommaDecimalField(
initial=0.00,
Expand Down
6 changes: 6 additions & 0 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,9 @@ class JournalEntry(models.Model):
on_delete=models.CASCADE
)

class Meta:
verbose_name_plural = 'journal entries'

def __str__(self):
return str(self.pk) + ': ' + str(self.date) + ' ' + self.description

Expand Down Expand Up @@ -769,6 +772,9 @@ class DocSearch(models.Model):
]
selection = models.CharField(max_length=20, choices=STRING_CHOICES, null=True, blank=True)

class Meta:
verbose_name_plural = 'doc searches'

def __str__(self):
account_name = self.account.name if self.account is not None else None
selection_value = self.selection if self.selection is not None else ''
Expand Down
Loading

0 comments on commit 9a9906c

Please sign in to comment.