XH_Digital_Management/application/exec_tbl/models.py

399 lines
24 KiB
Python
Raw Normal View History

from django.db import models
2024-06-06 15:08:38 +08:00
class FinancialData(models.Model):
year = models.IntegerField(verbose_name="年份", help_text="财务数据对应的年份")
annual_revenue = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="年度营业收入",
help_text="当年总收入")
annual_new_revenue = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="年度新增收入",
help_text="当年新增的收入")
annual_existing_revenue = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="年度存量收入",
help_text="当年开始就已存在的持续收入")
annual_operating_costs = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="年度营业成本",
help_text="当年的总营业成本")
annual_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="当年的营业利润(营业收入 - 营业成本 - 费用开销)")
unfinished_annual_revenue = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="年未完成收入",
help_text="当年尚未完成的收入目标")
daily_income_target_remaining = models.DecimalField(max_digits=15, decimal_places=2,
2024-06-06 15:08:38 +08:00
verbose_name="剩余日均收入目标",
help_text="当年剩余天数内每天需要完成的收入目标")
class Meta:
2024-05-29 09:27:39 +08:00
verbose_name = "公司整体经营情况"
verbose_name_plural = "公司整体经营情况"
def __str__(self):
2024-05-29 09:27:39 +08:00
return f"{self.year} 年的经营情况"
2024-06-06 15:08:38 +08:00
@staticmethod
def get_field_labels():
return {
'year': '年份',
'annual_revenue': '年度营业收入',
'annual_new_revenue': '年度新增收入',
'annual_existing_revenue': '年度存量收入',
'annual_operating_costs': '年度营业成本',
'annual_expenses': '年度费用开销',
'operating_profit': '营业利润',
'unfinished_annual_revenue': '年未完成收入',
'daily_income_target_remaining': '剩余日均收入目标'
}
def get_field_label(self, field_name):
field_labels = self.get_field_labels()
return field_labels.get(field_name, field_name)
class MonthlyFinancialData(models.Model):
year_month = models.CharField(max_length=7, verbose_name="年月", help_text="格式为'YYYY-MM',表示统计数据的年月")
current_month_income = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="当月收入",
help_text="该月的总收入")
monthly_income_target = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="月收入目标",
help_text="该月的收入目标")
monthly_target_completion_rate = models.DecimalField(max_digits=5, decimal_places=2, verbose_name="月目标完成率",
help_text="该月收入完成目标的百分比")
current_month_new_income = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="当月新增收入",
help_text="当月新增的收入")
monthly_new_income_target = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="月新增收入目标",
help_text="当月新增收入的目标")
monthly_new_income_completion_rate = models.DecimalField(max_digits=5, decimal_places=2,
2024-06-06 15:08:38 +08:00
verbose_name="月新增收入完成率",
help_text="当月新增收入完成目标的百分比")
current_month_existing_income = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="当月存量收入",
help_text="当月存量收入")
monthly_existing_income_target = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="月存量收入目标",
help_text="当月存量收入的目标")
monthly_existing_income_completion_rate = models.DecimalField(max_digits=5, decimal_places=2,
2024-06-06 15:08:38 +08:00
verbose_name="月存量收入完成率",
help_text="当月存量收入完成目标的百分比")
annual_accumulated_income = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="年累计收入",
help_text="年度累计收入")
accumulated_target_completion_rate = models.DecimalField(max_digits=5, decimal_places=2,
2024-06-06 15:08:38 +08:00
verbose_name="累计目标完成率",
help_text="年度收入目标完成率的百分比")
class Meta:
verbose_name = "公司整体收入情况"
verbose_name_plural = "公司整体收入情况"
2024-06-06 15:08:38 +08:00
# 添加模型注释
db_table_comment = '存储公司整体收入情况,包括收入、目标和完成率等'
def __str__(self):
2024-05-29 09:27:39 +08:00
return f"{self.year_month} 的收入情况"
2024-06-06 15:08:38 +08:00
@staticmethod
def get_field_labels():
return {
'year_month': '年月',
'current_month_income': '当月收入',
'monthly_income_target': '月收入目标',
'monthly_target_completion_rate': '月目标完成率',
'current_month_new_income': '当月新增收入',
'monthly_new_income_target': '月新增收入目标',
'monthly_new_income_completion_rate': '月新增收入完成率',
'current_month_existing_income': '当月存量收入',
'monthly_existing_income_target': '月存量收入目标',
'monthly_existing_income_completion_rate': '月存量收入完成率',
'annual_accumulated_income': '年累计收入',
'accumulated_target_completion_rate': '累计目标完成率',
}
def get_field_label(self, field_name):
field_labels = self.get_field_labels()
return field_labels.get(field_name, field_name)
class ReceivablesData(models.Model):
total_receivables = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="应收账款总额",
help_text="所有未结清的应收账款总额")
receivables_0_3_months = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="0-3个月",
help_text="应收账款中开票日期距今0-3个月的金额总计")
receivables_3_6_months = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="3-6个月",
help_text="应收账款中开票日期距今3-6个月的金额总计")
receivables_6_12_months = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="6-12个月",
help_text="应收账款中开票日期距今6-12个月的金额总计")
receivables_1_2_years = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="1-2年",
help_text="应收账款中开票日期距今1-2年的金额总计")
receivables_2_3_years = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="2-3年",
help_text="应收账款中开票日期距今2-3年的金额总计")
receivables_3_5_years = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="3-5年",
help_text="应收账款中开票日期距今3-5年的金额总计")
receivables_over_5_years = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="5年以上",
help_text="应收账款中开票日期超过5年的金额总计")
class Meta:
verbose_name = "公司应收账款情况"
verbose_name_plural = "公司应收账款情况"
2024-06-06 15:08:38 +08:00
# 添加模型注释
db_table_comment = '存储公司应收账款数据,包括各时间段的应收账款金额总计'
def __str__(self):
2024-06-06 15:08:38 +08:00
return f"Receivables Data with total receivables: {self.total_receivables}"
@staticmethod
def get_field_labels():
return {
'total_receivables': '应收账款总额',
'receivables_0_3_months': '0-3个月',
'receivables_3_6_months': '3-6个月',
'receivables_6_12_months': '6-12个月',
'receivables_1_2_years': '1-2年',
'receivables_2_3_years': '2-3年',
'receivables_3_5_years': '3-5年',
'receivables_over_5_years': '5年以上',
}
def get_field_label(self, field_name):
field_labels = self.get_field_labels()
return field_labels.get(field_name, field_name)
class ReceivablesDetail(models.Model):
project_name = models.CharField(max_length=255, verbose_name="项目名称", help_text="非空,一致性验证")
primary_department = models.CharField(max_length=255, verbose_name="一级部门", help_text="非空,一致性验证")
project_manager = models.CharField(max_length=255, verbose_name="项目负责人", help_text="非空,一致性验证")
outstanding_amount = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="待回款金额",
help_text="当前仍待回款的金额大于0")
class Meta:
verbose_name = "公司应收账款明细"
verbose_name_plural = "公司应收账款明细"
2024-06-06 15:08:38 +08:00
# 添加模型注释
db_table_comment = '存储公司应收账款明细数据,包括项目名称、一级部门、项目负责人和待回款金额等'
def __str__(self):
2024-06-06 15:08:38 +08:00
return f"Receivables Detail for project: {self.project_name}"
@staticmethod
def get_field_labels():
return {
'project_name': '项目名称',
'primary_department': '一级部门',
'project_manager': '项目负责人',
'outstanding_amount': '待回款金额',
}
def get_field_label(self, field_name):
field_labels = self.get_field_labels()
return field_labels.get(field_name, field_name)
class EmployeeStatus(models.Model):
total_employees = models.IntegerField(verbose_name="员工总数", help_text="全职和试用,状态为在职的员工总数")
new_employees_current_year = models.IntegerField(verbose_name="当年新入职员工数",
help_text="当年新入职的员工数(全职和试用)")
regularized_employees = models.IntegerField(verbose_name="转正人数", help_text="当年转正的员工总数")
probation_failed = models.IntegerField(verbose_name="试用期未通过人数", help_text="当年试用期未通过的离职员工数")
employees_left_current_year = models.IntegerField(verbose_name="当年离职员工数", help_text="当年离职的员工总数")
intern_employees = models.IntegerField(verbose_name="实习人数", help_text="在职的实习生总数")
part_time_employees = models.IntegerField(verbose_name="兼职人数", help_text="在职的兼职员工总数")
class Meta:
verbose_name = "公司人员情况"
verbose_name_plural = "公司人员情况"
2024-06-06 15:08:38 +08:00
# 添加模型注释
db_table_comment = '存储公司人员情况数据,包括员工总数、当年新入职员工数、转正人数、试用期未通过人数、当年离职员工数、实习人数和兼职人数等'
def __str__(self):
2024-06-06 15:08:38 +08:00
return f"Employee Status for {self.total_employees} employees"
@staticmethod
def get_field_labels():
return {
'total_employees': '员工总数',
'new_employees_current_year': '当年新入职员工数',
'regularized_employees': '转正人数',
'probation_failed': '试用期未通过人数',
'employees_left_current_year': '当年离职员工数',
'intern_employees': '实习人数',
'part_time_employees': '兼职人数',
}
def get_field_label(self, field_name):
field_labels = self.get_field_labels()
return field_labels.get(field_name, field_name)
class EmployeePerformance(models.Model):
2024-06-06 15:08:38 +08:00
year = models.IntegerField(verbose_name="年份", help_text="数据统计的年份")
name = models.CharField(max_length=255, verbose_name="姓名", help_text="员工姓名")
department = models.CharField(max_length=255, verbose_name="一级部门", help_text="员工所属的一级部门")
current_year_income = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="当年收入",
help_text="当年通过销售活动累计的收入")
income_target = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="收入目标",
help_text="当年为员工设定的销售收入目标")
income_target_completion_rate = models.DecimalField(max_digits=5, decimal_places=2, verbose_name="收入目标完成率",
help_text="当年收入与收入目标的完成比率")
commission_paid = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="已发放提成",
help_text="当年已发放给员工的提成金额")
accrued_amount = models.DecimalField(max_digits=15, decimal_places=2, verbose_name="计提金额",
help_text="当年为提成预留的金额,尚未发放")
other_bonuses = 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"Employee Performance for {self.name} in {self.year}"
@staticmethod
def get_field_labels():
return {
'year': '年份',
'name': '姓名',
'department': '一级部门',
'current_year_income': '当年收入',
'income_target': '收入目标',
'income_target_completion_rate': '收入目标完成率',
'commission_paid': '已发放提成',
'accrued_amount': '计提金额',
'other_bonuses': '其他奖金',
}
def get_field_label(self, field_name):
field_labels = self.get_field_labels()
return field_labels.get(field_name, field_name)
class EmployeeAttendance(models.Model):
2024-06-06 15:08:38 +08:00
name = models.CharField(max_length=255, verbose_name="姓名", help_text="员工的姓名")
late = models.IntegerField(verbose_name="迟到", help_text="当年累计迟到的次数")
early_departure = models.IntegerField(verbose_name="早退", help_text="当年累计早退的次数")
absenteeism = models.IntegerField(verbose_name="旷工", help_text="当年累计旷工的天数")
annual_leave = models.IntegerField(verbose_name="年假", help_text="当年使用的年假天数")
personal_leave = models.IntegerField(verbose_name="事假", help_text="当年使用的事假天数")
sick_leave = models.IntegerField(verbose_name="病假", help_text="当年使用的病假天数")
other_leave = models.IntegerField(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"Employee Attendance for {self.name}"
@staticmethod
def get_field_labels():
return {
'name': '姓名',
'late': '迟到',
'early_departure': '早退',
'absenteeism': '旷工',
'annual_leave': '年假',
'personal_leave': '事假',
'sick_leave': '病假',
'other_leave': '其他',
}
def get_field_label(self, field_name):
field_labels = self.get_field_labels()
return field_labels.get(field_name, field_name)
class ProjectLedger(models.Model):
project_id = models.AutoField(primary_key=True, verbose_name="项目编号", help_text="主键,自增")
project_name = models.CharField(max_length=255, verbose_name="项目名称", help_text="项目的名称")
start_date = models.DateField(verbose_name="开始日期", help_text="项目创建日期")
end_date = models.DateField(verbose_name="结束日期", help_text="项目完成日期")
primary_department = models.CharField(max_length=255, verbose_name="一级部门", help_text="项目归属的一级部门")
customer_name = models.CharField(max_length=255, verbose_name="客户名称", help_text="项目相关的客户名称")
province = models.CharField(max_length=255, verbose_name="", help_text="项目所在省份")
city = models.CharField(max_length=255, verbose_name="", help_text="项目所在城市")
district = models.CharField(max_length=255, verbose_name="区县", help_text="项目所在区县")
project_leader = models.CharField(max_length=255, verbose_name="负责人", help_text="项目负责人")
project_members = models.CharField(max_length=255, verbose_name="项目组员", help_text="参与项目的团队成员")
project_status = models.CharField(max_length=20, choices=[
('进行中', '进行中'),
('暂停', '暂停'),
('待收款', '待收款'),
('完成', '完成')
2024-06-06 15:08:38 +08:00
], verbose_name="项目状态", help_text="项目当前状态")
resource_type = models.CharField(max_length=20, choices=[
('公司', '公司'),
('个人', '个人')
2024-06-06 15:08:38 +08:00
], verbose_name="资源类型", help_text="项目资源类型")
project_nature = models.CharField(max_length=20, choices=[
('新增', '新增'),
('存量', '存量'),
('新增及存量', '新增及存量'),
('老客户新业务', '老客户新业务')
2024-06-06 15:08:38 +08:00
], verbose_name="项目性质", help_text="项目的性质")
project_progress = models.CharField(max_length=255, verbose_name="项目进度", help_text="项目当前进度,可配置")
contract_date = models.DateField(verbose_name="签约时间", help_text="项目签约日期")
contract_amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="标的金额",
help_text="合同金额,单位元")
contract_rate = models.DecimalField(max_digits=5, decimal_places=2, verbose_name="合同费率",
help_text="合同费率,单位为百分比")
revenue = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="收入",
help_text="非空,项目收入,单位元")
cost_rate = models.DecimalField(max_digits=5, decimal_places=2, verbose_name="成本费率",
help_text="成本费率,单位为百分比")
cost = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="成本", help_text="非空,项目成本,单位元")
net_income = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="净收入", help_text="净收入,单位元")
total_amount_including_tax = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="价税合计金额",
help_text="从开票记录获取的总开票金额,单位元")
repayment_amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="回款金额",
help_text="从回款记录获取的总回款金额,单位元")
receivable_net_income = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="应收净收入",
help_text="应收净收入,单位元")
actual_net_income = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="实收净收入",
help_text="实收净收入,单位元")
outstanding_net_income = models.DecimalField(max_digits=10, decimal_places=2, verbose_name="待收净收入",
help_text="待收净收入,单位元")
notes = models.TextField(verbose_name="备注", help_text="附加信息")
class Meta:
verbose_name = "公司项目台账"
verbose_name_plural = "公司项目台账"
2024-06-06 15:08:38 +08:00
# 添加模型注释
db_table_comment = '存储公司项目台账数据,包括项目编号、项目名称、开始日期、结束日期、一级部门、客户名称、省、市、区县、负责人、项目组员、项目状态、资源类型、项目性质、项目进度、签约时间、标的金额、合同费率、收入、成本费率、成本、净收入、价税合计金额、回款金额、应收净收入、实收净收入、待收净收入和备注等'
def __str__(self):
2024-06-06 15:08:38 +08:00
return f"Project Ledger: {self.project_name} ({self.project_id})"
@staticmethod
def get_field_labels():
return {
'project_id': '项目编号',
'project_name': '项目名称',
'start_date': '开始日期',
'end_date': '结束日期',
'primary_department': '一级部门',
'customer_name': '客户名称',
'province': '',
'city': '',
'district': '区县',
'project_leader': '负责人',
'project_members': '项目组员',
'project_status': '项目状态',
'resource_type': '资源类型',
'project_nature': '项目性质',
'project_progress': '项目进度',
'contract_date': '签约时间',
'contract_amount': '标的金额',
'contract_rate': '合同费率',
'revenue': '收入',
'cost_rate': '成本费率',
'cost': '成本',
'net_income': '净收入',
'total_amount_including_tax': '价税合计金额',
'repayment_amount': '回款金额',
'receivable_net_income': '应收净收入',
'actual_net_income': '实收净收入',
'outstanding_net_income': '待收净收入',
'notes': '备注',
}
def get_field_label(self, field_name):
field_labels = self.get_field_labels()
return field_labels.get(field_name, field_name)