129 lines
3.7 KiB
Python
129 lines
3.7 KiB
Python
from django.db import models
|
|
from Base.models import (
|
|
Base,
|
|
PayMethod,
|
|
Professional ,
|
|
ServiceList,
|
|
ProductList,
|
|
ChartOfAccount,
|
|
BankAccount,
|
|
)
|
|
from Client.models import Client
|
|
|
|
# Movimento do Dia
|
|
class Calendar(Base):
|
|
client = models.ForeignKey(
|
|
Client,
|
|
on_delete=models.PROTECT,
|
|
related_name='CalendarClient'
|
|
)
|
|
date = models.DateField()
|
|
time = models.TimeField()
|
|
service = models.ForeignKey(
|
|
ServiceList,
|
|
on_delete=models.PROTECT,
|
|
related_name='CalendarService'
|
|
)
|
|
pay_method = models.ForeignKey(
|
|
PayMethod,
|
|
on_delete=models.PROTECT,
|
|
related_name='CalendarPayMethod'
|
|
)
|
|
professional = models.ForeignKey(
|
|
Professional,
|
|
on_delete=models.PROTECT,
|
|
related_name='CalendarProfessional'
|
|
)
|
|
first_time = models.BooleanField(default=False)
|
|
# Value
|
|
gross_value = models.DecimalField(max_digits=10, decimal_places=2)
|
|
net_value = models.DecimalField(max_digits=10, decimal_places=2)
|
|
value_cash = models.DecimalField(max_digits=10, decimal_places=2)
|
|
prof_money = models.DecimalField(max_digits=10, decimal_places=2)
|
|
|
|
class Meta:
|
|
ordering = ['date','time','professional',]
|
|
def __str__(self):
|
|
return f'{self.date} - {self.professional} - {self.time}'
|
|
|
|
# Estoque Entrada
|
|
class Stock(models.Model):
|
|
date = models.DateField()
|
|
product = models.ForeignKey(
|
|
ProductList,
|
|
on_delete=models.PROTECT,
|
|
related_name='StockProduct',
|
|
)
|
|
quantity = models.DecimalField(max_digits=10, default=1, decimal_places=0 )
|
|
unit_value = models.DecimalField(max_digits=10, decimal_places=2)
|
|
gross_value = models.DecimalField(max_digits=10, decimal_places=2)
|
|
bank = models.ForeignKey(
|
|
BankAccount,
|
|
on_delete=models.PROTECT,
|
|
related_name='StockBank',
|
|
)
|
|
notes = models.TextField(null=True, blank=True)
|
|
class Meta:
|
|
ordering = ['product']
|
|
def __str__(self):
|
|
return self.product
|
|
|
|
# Venda de Produtos
|
|
class Product(Base):
|
|
client = models.ForeignKey(
|
|
Client,
|
|
on_delete=models.PROTECT,
|
|
related_name='ProductClient',
|
|
)
|
|
date = models.DateField()
|
|
product = models.ForeignKey(
|
|
ProductList,
|
|
on_delete=models.PROTECT,
|
|
related_name='ProductProduct',
|
|
)
|
|
pay_method = models.ForeignKey(
|
|
PayMethod,
|
|
on_delete=models.PROTECT,
|
|
related_name='ProductPayMethod',
|
|
)
|
|
professional = models.ForeignKey(
|
|
Professional,
|
|
on_delete=models.PROTECT,
|
|
related_name='ProductProfessional',
|
|
)
|
|
quantity = models.DecimalField(max_digits=10, default=1 ,decimal_places=0)
|
|
# Value
|
|
gross_value = models.DecimalField(max_digits=10, decimal_places=2)
|
|
net_value = models.DecimalField(max_digits=10, decimal_places=2)
|
|
|
|
class Meta:
|
|
ordering = ['date','product',]
|
|
def __str__(self):
|
|
return f'{self.date} - {self.product} '
|
|
|
|
# Despesas
|
|
class Expense(Base):
|
|
date = models.DateField()
|
|
chart_of_account = models.ForeignKey(
|
|
ChartOfAccount,
|
|
on_delete=models.PROTECT,
|
|
related_name='ExpenseChartOfAccount'
|
|
)
|
|
bank = models.ForeignKey(
|
|
BankAccount,
|
|
on_delete=models.PROTECT,
|
|
related_name='ExpenseBank',
|
|
)
|
|
firm = models.BooleanField(default=True)
|
|
professional = models.ForeignKey(
|
|
Professional,
|
|
on_delete=models.PROTECT,
|
|
related_name='ExpenseProfessional',
|
|
null=True, blank=True,
|
|
)
|
|
gross_value = models.DecimalField(max_digits=10, decimal_places=2)
|
|
|
|
class Meta:
|
|
ordering = ['date','chart_of_account',]
|
|
def __str__(self):
|
|
return f'{self.date} - {self.chart_of_account} ' |