XH_Digital_Management/application/fin_tbl/models.py

54 lines
3.4 KiB
Python
Raw Normal View History

from django.db import models
2024-06-06 15:08:38 +08:00
class DepartmentOperationalData(models.Model):
department = models.CharField(max_length=255, verbose_name="一级部门", help_text="部门名称")
year_month = models.CharField(max_length=7, verbose_name="年月", help_text="格式为'YYYY-MM',表示统计数据的年月")
current_month_revenue = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="当月收入",
help_text="当月总收入")
current_month_new_revenue = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="当月新增收入",
help_text="当月新增的收入")
current_month_existing_revenue = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="当月存量收入",
help_text="当月存量收入")
current_month_cost = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="当月成本",
help_text="当月总成本")
gross_profit = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="毛利润",
help_text="当月收入减去当月成本")
taxes_and_surcharges = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="税金及附加",
help_text="根据税额累计后乘以1.12得到的税金及附加总额")
expenses = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="费用",
help_text="毛利润减去税金及附加和营业利润得到的费用")
operating_profit = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="营业利润",
help_text="当月收入减去成本、税金及附加和费用后的利润")
operational_cash_flow = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="经营性现金流",
help_text="经营活动产生的现金流量,需手动添加")
class Meta:
2024-06-06 15:08:38 +08:00
verbose_name = "各一级部门经营情况"
verbose_name_plural = "各一级部门经营情况"
# 添加模型注释
db_table_comment = '存储各一级部门经营情况数据,包括一级部门、年月、当月收入、当月新增收入、当月存量收入、当月成本、毛利润、税金及附加、费用、营业利润和经营性现金流等'
def __str__(self):
2024-06-06 15:08:38 +08:00
return f"Operational Data for {self.department} in {self.year_month}"
@staticmethod
def get_field_labels():
return {
'department': '一级部门',
'year_month': '年月',
'current_month_revenue': '当月收入',
'current_month_new_revenue': '当月新增收入',
'current_month_existing_revenue': '当月存量收入',
'current_month_cost': '当月成本',
'gross_profit': '毛利润',
'taxes_and_surcharges': '税金及附加',
'expenses': '费用',
'operating_profit': '营业利润',
'operational_cash_flow': '经营性现金流',
}
def get_field_label(self, field_name):
field_labels = self.get_field_labels()
return field_labels.get(field_name, field_name)