diff --git a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py index 8faf058bb..3671fef18 100644 --- a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py +++ b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py @@ -450,8 +450,8 @@ class HrAttendanceDetail(models.Model): holidays_list = [self.remove_leading_zero(date) for date in holidays_list] shift_days_list = [self.remove_leading_zero(date) for date in shift_days_list] - - if (current_data in holidays_list) or (current_data.weekday() in [5, 6]): + result = [f"{current_data.month}月{current_data.day}日"] + if (result in holidays_list) or (current_data.weekday() in [5, 6]): return False elif current_data in shift_days_list: return True diff --git a/yuthon_property/models/property_meter_archives.py b/yuthon_property/models/property_meter_archives.py index 43ba6c085..948af6c95 100644 --- a/yuthon_property/models/property_meter_archives.py +++ b/yuthon_property/models/property_meter_archives.py @@ -239,7 +239,7 @@ class MeterArchivesLine(models.Model): ) last_reading_time = fields.Date(string="最后读数时间") receivables = fields.Float( - string="应收", compute="_compute_receivables", store=True, group_operator=None + string="应收", compute="_compute_receivables", store=True, group_operator=None, help="应收金额=本次用量*单价*(1+线损)" ) unit = fields.Float(string="当月单价", group_operator=None, igits=(6, 4)) line_loss = fields.Float(string="线损", default=0.02) @@ -260,16 +260,14 @@ class MeterArchivesLine(models.Model): ) maximum_count = fields.Integer(string="最大位数") - @api.depends("line_loss", "current_meter", "unit") + @api.depends('line_loss', 'current_meter', 'unit') def _compute_receivables(self): for record in self: if record.line_loss and record.current_meter and record.unit: - record.receivables = ( - record.current_meter - * record.unit - * (1 + record.line_loss) - * record.gauge_magnification - ) + raw_value = record.current_meter * record.unit * (1 + record.line_loss) * record.gauge_magnification + record.receivables = round(raw_value, 1) + else: + record.receivables = 0.0 def update_meter(self): current_year = datetime.now().year diff --git a/yuthon_property/models/property_meter_water.py b/yuthon_property/models/property_meter_water.py index dd225b8b5..1b2620e6e 100644 --- a/yuthon_property/models/property_meter_water.py +++ b/yuthon_property/models/property_meter_water.py @@ -183,6 +183,28 @@ class MeterWaterLine(models.Model): index=True, ) + current_read = fields.Float(string='本次读数', group_operator=None) + unit_number = fields.Char(string='单元编号/用途') + unit = fields.Float(string='当月单价', group_operator=None) + receivables = fields.Float(string="应收", compute='_compute_receivables', store=True, group_operator=None, help="应收金额=本次用量*单价*(1+线损)") + gauge_magnification = fields.Integer(string='仪表倍率', readonly=True, default=1, group_operator=None) + last_reading_time = fields.Date(string="最后读数时间") + type = fields.Selection([("public", "公共"), ("fees", "收费")], string="类型") + start_time = fields.Date(string="安装日期") + line_loss = fields.Float(string="线损", default=0.02) + end_time = fields.Date(string="拆除日期") + water_state = fields.Selection([('stop', '停用'), ('use', '使用'), ('rent', '出租')], string='状态') + state = fields.Selection([('reading', '已抄'), ('unreading', '未抄')], string='抄表状态', default='unreading') + remarks = fields.Text(string='备注') + employee_ids = fields.Many2many('hr.employee', string='抄表人') + maximum_count = fields.Integer(string='最大位数') + meter_date_month = fields.Char( + string="任务日期月份", + compute="_compute_meter_date_month", + store=True, + index=True, + ) + def _compute_meter_date_month(self): for rec in self: if rec.meter_date: @@ -190,39 +212,6 @@ class MeterWaterLine(models.Model): else: rec.meter_date_month = False - current_meter = fields.Float( - string="本次用量", - store=True, - compute="compute_meter_values", - group_operator=None, - ) - - current_read = fields.Float(string="本次读数", group_operator=None) - unit_number = fields.Char(string="单元编号/用途") - unit = fields.Float(string="当月单价", group_operator=None) - receivables = fields.Float( - string="应收", compute="_compute_receivables", store=True, group_operator=None - ) - gauge_magnification = fields.Integer( - string="仪表倍率", readonly=True, default=1, group_operator=None - ) - last_reading_time = fields.Date(string="最后读数时间") - type = fields.Selection([("public", "公共"), ("fees", "收费")], string="类型") - start_time = fields.Date(string="安装日期") - line_loss = fields.Float(string="线损", default=0.02) - end_time = fields.Date(string="拆除日期") - water_state = fields.Selection( - [("stop", "停用"), ("use", "使用"), ("rent", "出租")], string="状态" - ) - state = fields.Selection( - [("reading", "已抄"), ("unreading", "未抄")], - string="抄表状态", - default="unreading", - ) - remarks = fields.Text(string="备注") - employee_ids = fields.Many2many("hr.employee", string="抄表人") - maximum_count = fields.Integer(string="最大位数") - @api.onchange("name") def _onchange_line_ids(self): if self.line_ids: @@ -233,12 +222,10 @@ class MeterWaterLine(models.Model): def _compute_receivables(self): for record in self: if record.line_loss and record.current_meter and record.unit: - record.receivables = ( - record.current_meter - * record.unit - * (1 + record.line_loss) - * record.gauge_magnification - ) + raw_value = record.current_meter * record.unit * (1 + record.line_loss) * record.gauge_magnification + record.receivables = round(raw_value, 1) + else: + record.receivables = 0.0 def update_meter(self): current_year = datetime.now().year diff --git a/yuthon_property/views/property_meter_archives_views.xml b/yuthon_property/views/property_meter_archives_views.xml index cd874d10f..60d239418 100644 --- a/yuthon_property/views/property_meter_archives_views.xml +++ b/yuthon_property/views/property_meter_archives_views.xml @@ -110,7 +110,7 @@ - + diff --git a/yuthon_property/views/property_meter_water_views.xml b/yuthon_property/views/property_meter_water_views.xml index 28a263f01..e88e47f62 100644 --- a/yuthon_property/views/property_meter_water_views.xml +++ b/yuthon_property/views/property_meter_water_views.xml @@ -96,28 +96,26 @@ meter.water.line.tree meter.water.line - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - + + + + + + @@ -143,8 +141,7 @@ - + diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index 560b5209e..5b783113e 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -7,6 +7,26 @@ from dateutil.relativedelta import relativedelta import calendar +class PropertyMeterWater(models.Model): + _inherit = 'property.meter.water' + + contract_id = fields.Many2one('property.lease.contract', string="合同") + +class PropertyMeterArchives(models.Model): + _inherit = 'property.meter.archives' + + contract_id = fields.Many2one('property.lease.contract', string="合同") + +class MeterArchivesLine(models.Model): + _inherit = 'meter.archives.line' + + contract_id = fields.Many2one('property.lease.contract', string="合同") + +class MeterWaterLine(models.Model): + _inherit = 'meter.water.line' + + contract_id = fields.Many2one('property.lease.contract', string="合同") + class YuthonProperty(models.Model): _inherit = 'yuthon.property' diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml index b9d0120eb..a6438e1cd 100644 --- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml +++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml @@ -1,5 +1,45 @@ + + inherit.property.meter.archives.form + property.meter.archives + + + + + + + + + inherit.property.meter.water.form + property.meter.water + + + + + + + + + inherit.view.meter.archives.line.tree + meter.archives.line + + + + + + + + + view.meter.water.line.tree.inherit + meter.water.line + + + + + + + yuthon.property.form.inherit yuthon.property diff --git a/yuthon_property_approval/views/property_lease_contract.xml b/yuthon_property_approval/views/property_lease_contract.xml index d58c90464..711bf3b3d 100644 --- a/yuthon_property_approval/views/property_lease_contract.xml +++ b/yuthon_property_approval/views/property_lease_contract.xml @@ -667,7 +667,20 @@ - + + + + + + + + + + + + + + diff --git a/yuthon_property_approval/wizard/property_rental_wizard.py b/yuthon_property_approval/wizard/property_rental_wizard.py index 2f6f8b738..1f6c8477c 100644 --- a/yuthon_property_approval/wizard/property_rental_wizard.py +++ b/yuthon_property_approval/wizard/property_rental_wizard.py @@ -177,7 +177,7 @@ class PropertyRentalWizard(models.Model): "original_amount": amount, }) - def create_management_list(self, record, start_date): + def create_management_list(self, record, start_date, rent_amount): """封装创建管理费记录的逻辑""" first_day_of_month = start_date.replace(day=1) last_day_of_month = first_day_of_month + relativedelta(months=1) - timedelta(days=1) @@ -189,27 +189,33 @@ class PropertyRentalWizard(models.Model): ('due_date', '>=', first_day_of_month), ('due_date', '<=', last_day_of_month) ]) - if property_id.message_standard_id: - standard_id = property_id.message_standard_id - original_amount = property_id.management_area * standard_id.amount - if not management_id: - self.sudo().env["property.management.list"].create({ - "contract_id": record.id, - "property_id": property_id.id, - 'original_amount':original_amount, - 'message_standard_id': property_id.message_standard_id.id, - 'lessee_id': record.lessee_id.id, - "due_date":start_date - }) + if record.contract_sort == 'property': + if property_id.message_standard_id: + standard_id = property_id.message_standard_id + original_amount = int(round(property_id.management_area * standard_id.amount)) else: - management_id.write({ - "contract_id": record.id, - "property_id": property_id.id, - 'original_amount': original_amount, - 'message_standard_id': property_id.message_standard_id.id, - 'lessee_id': record.lessee_id.id, - "due_date": start_date - }) + original_amount = 0 + else: + original_amount = rent_amount + + if not management_id: + self.sudo().env["property.management.list"].create({ + "contract_id": record.id, + "property_id": property_id.id, + 'original_amount':original_amount, + 'message_standard_id': property_id.message_standard_id.id, + 'lessee_id': record.lessee_id.id, + "due_date":start_date + }) + else: + management_id.write({ + "contract_id": record.id, + "property_id": property_id.id, + 'original_amount': original_amount, + 'message_standard_id': property_id.message_standard_id.id, + 'lessee_id': record.lessee_id.id, + "due_date": start_date + }) def process_rent_record(self, record, rent_id, date_field_year_month, days, period_month=0, multiplier=1, is_year=0): """封装处理租金逻辑,增加 multiplier 参数用于乘法""" @@ -224,8 +230,10 @@ class PropertyRentalWizard(models.Model): start_date = datetime.strptime(date_str, "%Y-%m-%d") # 当期应收日期 if start_year_month <= date_field_year_month <= end_year_month: - self.create_rent_list(record, rent_id, rent_amount, start_date, multiplier) - self.create_management_list(record, start_date) + if record.contract_sort == 'property': + self.create_rent_list(record, rent_id, rent_amount, start_date, multiplier) + else: + self.create_management_list(record, start_date, rent_amount) def get_multiplier(self, cycle_dict): """根据周期类型返回相应的租金乘数""" @@ -246,6 +254,7 @@ class PropertyRentalWizard(models.Model): records = self.env['property.lease.contract'].search([ ('actual_start_time', '<=', last_day), ('actual_end_time', '>=', first_day), + ('contract_code','=', '租(2025)001') ]) filtered_records = [ rec for rec in records