Skip to content

Commit

Permalink
added new app for brokers note
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardochaves committed Jun 11, 2020
1 parent 839c797 commit 61c959a
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 0 deletions.
Empty file.
53 changes: 53 additions & 0 deletions base_site/brokes_note/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from django.contrib import admin

from base_site.brokes_note.models import Broker
from base_site.brokes_note.models import BrokersNote
from base_site.brokes_note.models import BrokersNoteItem
from base_site.brokes_note.models import Company


class BrokerAdmin(admin.ModelAdmin):
pass


class CompanyAdmin(admin.ModelAdmin):
pass


class BrokersNoteItemInline(admin.TabularInline):
model = BrokersNoteItem


class BrokersNoteAdmin(admin.ModelAdmin):

inlines = [
BrokersNoteItemInline,
]


class BrokersNoteItemAdmin(admin.ModelAdmin):
list_display = (
"note",
"company",
"unit",
"value",
)


admin.site.register(Broker, BrokerAdmin)
admin.site.register(Company, CompanyAdmin)
admin.site.register(BrokersNote, BrokersNoteAdmin)
admin.site.register(BrokersNoteItem, BrokersNoteItemAdmin)

# list_display = (
# "db_included_date_time",
# "category",
# "name",
# "description",
# "debit",
# "credit",
# "payment_date_time",
# "create_date_time",
# )
# readonly_fields = ("db_included_date_time",)
# list_filter = ("category", "name", "type_entry", "payment_date_time", "create_date_time")
5 changes: 5 additions & 0 deletions base_site/brokes_note/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class BrokesNoteConfig(AppConfig):
name = "base_site.brokes_note"
Empty file.
47 changes: 47 additions & 0 deletions base_site/brokes_note/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from django.db import models


class Broker(models.Model):
name = models.CharField(max_length=70)

def __str__(self):
return self.name


class Company(models.Model):
name = models.CharField(max_length=300)
paper = models.CharField(max_length=20)

def __str__(self):
return self.paper


class BrokersNote(models.Model):
date = models.DateField()
broker = models.ForeignKey(Broker, on_delete=models.CASCADE)
number = models.CharField(max_length=30)
link = models.URLField()
brokerage_fee = models.DecimalField(max_digits=9, decimal_places=2, default=0)
settlement_fee = models.DecimalField(max_digits=9, decimal_places=2, default=0)
Emonuments_fee = models.DecimalField(max_digits=9, decimal_places=2, default=0)
irrf = models.DecimalField(max_digits=9, decimal_places=2, default=0)
final_value = models.DecimalField(max_digits=9, decimal_places=2, default=0)

def __str__(self):
return self.date.strftime("%d/%m/%Y")

class Meta:
unique_together = [["broker", "number"]]


class BrokersNoteItem(models.Model):
note = models.ForeignKey(BrokersNote, on_delete=models.CASCADE)
company = models.ForeignKey(Company, on_delete=models.CASCADE)
unit = models.IntegerField()
buy_or_sell = models.CharField(max_length=1)
credit_or_debit = models.CharField(max_length=1)
value = models.DecimalField(max_digits=9, decimal_places=2, default=0)
total_value = models.DecimalField(max_digits=9, decimal_places=2, default=0)

def __str__(self):
return self.company.paper
3 changes: 3 additions & 0 deletions base_site/brokes_note/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions base_site/brokes_note/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
2 changes: 2 additions & 0 deletions base_site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from typing import Optional

import sentry_sdk

# SECURITY WARNING: keep the secret key used in production secret!
from base_site.setup.log import JsonFormatter
from sentry_sdk.integrations.django import DjangoIntegration
Expand Down Expand Up @@ -57,6 +58,7 @@
"request_id_django_log",
"base_site.nubank",
"base_site.alelo",
"base_site.brokes_note",
]

MIDDLEWARE = [
Expand Down

0 comments on commit 61c959a

Please sign in to comment.