diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index 6fa9cbaf1..d72bdbd7a 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -230,7 +230,6 @@ class YuthonVacationReports(models.Model): actual_attendance = actual_attendance - total_leave_days - is_abnormal employee = rec.employee_id - print(employee.name) contract = employee.contract_id is_outside = employee.user_role_id.name == '外派' month_start = date(year, month, 1) diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py index 540a906bf..b191c3834 100644 --- a/yuthon_property_approval/models/inherit_yuthon_property.py +++ b/yuthon_property_approval/models/inherit_yuthon_property.py @@ -141,7 +141,21 @@ class PropertyBankStatements(models.Model): _inherit = 'property.bank.statements' contract_id = fields.Many2one('property.lease.contract', string="关联租赁合同审批") - contract_ids = fields.Many2many('property.lease.contract', string="租赁合同审批") + contract_ids = fields.Many2many( + 'property.lease.contract', + 'property_bank_stmt_contract_rel', + 'stmt_id', + 'contract_id', + string='合同' + ) + + contract_ids1 = fields.Many2many( + 'property.lease.contract', + 'property_bank_stmt_contract1_rel', + 'stmt_id', + 'contract_id', + string='已对合同' + ) property_name = fields.Text(string="物业名称", compute="compute_property_name", store=True) accounts_id = fields.Many2one('property.accounts.approval', string="关联生成应收审批单") lessee_ids = fields.Many2many('property.tenant.information', string='承租方', compute="_compute_property_employee_id") @@ -232,20 +246,12 @@ class PropertyBankStatements(models.Model): self._filter_contracts_based_on_receivables() def _filter_contracts_based_on_receivables(self): - """筛选合同:仅保留存在未对账应收单的合同""" + """还原合同""" for stmt in self: - if not stmt.contract_ids: + if not stmt.contract_ids1: continue - remaining_contract_ids = [] - for contract in stmt.contract_ids: - unreconciled_receivables = self.env["property.accounts.receivable"].search([ - ('contract_id', '=', contract.id), - ('is_reconciliation', '=', False), - ], limit=1) - if unreconciled_receivables: - remaining_contract_ids.append(contract.id) - if remaining_contract_ids != stmt.contract_ids.ids: - stmt.contract_ids = [(6, 0, remaining_contract_ids)] + new_contract_ids = stmt.contract_ids.ids + stmt.contract_ids1.ids + stmt.contract_ids = [(6, 0, new_contract_ids)] def binding_information(self): return { @@ -311,7 +317,6 @@ class PropertyBankStatements(models.Model): def _get_reconciliation_vals(self, record): if record.name: dt = datetime.strptime(str(self.start_time), '%Y-%m-%d %H:%M:%S').date() - last_day = dt.replace(day=1) + relativedelta(months=1) - relativedelta(days=1) total_rent_month = 0 # 应收租金 rent_ids = self.env['property.accounts.receivable'].search([ @@ -319,7 +324,6 @@ class PropertyBankStatements(models.Model): ('contract_id.lessor_id.referred', '=', self.your_own_unit), ('management_type_id.name', '=', '租金'), ('is_reconciliation', '=', False), - ('due_date', '<=', fields.Date.to_string(last_day)), ]) # 应收押金 @@ -328,7 +332,6 @@ class PropertyBankStatements(models.Model): ('contract_id.lessor_id.referred', '=', self.your_own_unit), ('management_type_id.name', '=', '押金'), ('is_reconciliation', '=', False), - ('due_date', '<=', fields.Date.to_string(last_day)), ]) # 应收管理费 management_ids = self.env['property.accounts.receivable'].search([ @@ -336,7 +339,6 @@ class PropertyBankStatements(models.Model): ('contract_id.lessor_id.referred', '=', self.your_own_unit), ('management_type_id.name', '=', '管理费'), ('is_reconciliation', '=', False), - ('due_date', '<=', fields.Date.to_string(last_day)), ]) # 应收水费 water_ids = self.env['property.accounts.receivable'].search([ @@ -344,7 +346,6 @@ class PropertyBankStatements(models.Model): ('contract_id.lessor_id.referred', '=', self.your_own_unit), ('management_type_id.name', '=', '水费'), ('is_reconciliation', '=', False), - ('due_date', '<=', fields.Date.to_string(last_day)), ]) # 应收电费 electricity_ids = self.env['property.accounts.receivable'].search([ @@ -352,7 +353,6 @@ class PropertyBankStatements(models.Model): ('contract_id.lessor_id.referred', '=', self.your_own_unit), ('management_type_id.name', '=', '电费'), ('is_reconciliation', '=', False), - ('due_date', '<=', fields.Date.to_string(last_day)), ]) def create_reconciliation_vals(ids, collection_type_val, sequence_val): diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py index af146a6e9..0fdda21fc 100644 --- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py +++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py @@ -41,18 +41,22 @@ class PropertyReconciliationWizard(models.Model): for rec in self: rec.amount_reconciled = rec.actual_total - rec.amount_been_reconciled - sum(line.amount for line in rec.reconciliation_line_ids) for line in rec.reconciliation_line_ids: - if line.amount: + if line.amount and line.collection_type != 'penalty': + if (line.due_date.month >= rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year > rec.actual_date.year): + if line.rent >= line.amount: + due_date_str = fields.Date.to_date(line.due_date).strftime('%Y-%m') + line.remake = f'预{due_date_str},欠{round(line.rent - line.amount, 2)}' + if line.due_date.month == rec.actual_date.month and line.due_date.year == line.due_date.year: if line.rent >= line.amount: due_date_str = fields.Date.to_date(line.due_date).strftime('%Y-%m') - line.remake = f'交{due_date_str},欠{line.rent - line.amount}' - if line.due_date.month != rec.actual_date.month and line.collection_type == 'rent': - if line.rent == line.amount: + line.remake = f'交{due_date_str},欠{round(line.rent - line.amount, 2)}' + + if (line.due_date.month < rec.actual_date.month and line.due_date.year == line.due_date.year) or (line.due_date.year < rec.actual_date.year): + if line.rent >= line.amount: due_date_str = fields.Date.to_date(line.due_date).strftime('%Y-%m') - line.remake = str(rec.actual_date) + '补' + str(due_date_str) + ',欠0' - elif line.rent > line.amount: - due_date_str = fields.Date.to_date(line.due_date).strftime('%Y-%m') - line.remake = str(rec.actual_date) + '补' + str(due_date_str) + ',欠' + str(line.rent - line.amount) + line.remake = str(rec.actual_date) + '补' + str(due_date_str) + ',欠' + str(round(line.rent - line.amount, 2)) + @api.depends('reconciliation_line_ids') def _compute_receivable_total(self): @@ -84,6 +88,16 @@ class PropertyReconciliationWizard(models.Model): @api.onchange('actual_total') def _onchange_reconciliation_line_ids(self): + collection_type_mapping = { + 'deposit': '押金', + 'rent': '租金', + 'water_fee': '水费', + 'electricity_fee': '电费', + 'penalty': '违约金', + 'management_fee': '管理费', + 'repair_fee': '维修费', + 'other': '其他' + } new_lines = [] # 违约金生成 for contract_id in self.bank_id.contract_ids: @@ -113,7 +127,7 @@ class PropertyReconciliationWizard(models.Model): ('is_reconciliation', '=', False), ('due_date', '>=', first_day_of_last_month.strftime('%Y-%m-%d')), ('due_date', '<=', last_day_of_last_month.strftime('%Y-%m-%d')), - ('management_type_id.name', '=', '租金') + ('management_type_id.name', '!=', '违约金') ], limit=1) if contract_receivables: # 计算应收日期的下月1号 @@ -356,6 +370,16 @@ class PropertyReconciliationWizard(models.Model): remaining_amount -= assign_amount def confirm(self): + collection_type_mapping = { + 'deposit': '押金', + 'rent': '租金', + 'water_fee': '水费', + 'electricity_fee': '电费', + 'penalty': '违约金', + 'management_fee': '管理费', + 'repair_fee': '维修费', + 'other': '其他' + } for rec in self: bank_lines = self.env['property.bank.line'].search([ ('bank', '=', rec.bank_id.name), @@ -376,14 +400,13 @@ class PropertyReconciliationWizard(models.Model): for line in rec.reconciliation_line_ids: remaining_amount += line.amount - if rec.actual_total > remaining_amount: + if round(rec.actual_total, 2) > round(remaining_amount, 2): rec.bank_id.registered = rec.actual_total - remaining_amount rec.bank_id.bank_state = 'registered' else: rec.bank_id.registered = 0 rec.bank_id.bank_state = 'reconciled' rec.bank_id.reconciliation_time = fields.Datetime.now() - timedelta(hours=8) - first_line = bank_lines[0] for line in rec.reconciliation_line_ids: # 跳过金额为0的行 if (line.amount == 0 and line.collection_type != 'penalty') or \ @@ -404,7 +427,7 @@ class PropertyReconciliationWizard(models.Model): first_day = line.due_date.replace(day=1) last_day = (first_day + relativedelta(months=1)) - relativedelta(days=1) domain = [ - ('management_type_id.name', '!=', '违约金'), + ('management_type_id.name', '=', collection_type_mapping.get(line.collection_type)), ('is_reconciliation', '=', False), ('is_suspend', '=', False), ('due_date', '>=', first_day), @@ -507,23 +530,25 @@ class PropertyReconciliationWizard(models.Model): rec.bank_id.no_amount = amount_reconciled - # 更新流水的合同信息 + all_contracts = self.bank_id.contract_ids + all_contract_ids = all_contracts.ids remaining_contract_ids = [] - for contract in self.bank_id.contract_ids: + for contract in all_contracts: unreconciled_receivables = self.env["property.accounts.receivable"].search([ ('contract_id', '=', contract.id), ('is_reconciliation', '=', False), ], limit=1) - - # 核心逻辑:存在未对账应收单 → 保留合同;否则 → 移除 if unreconciled_receivables: remaining_contract_ids.append(contract.id) + # 计算被移除的合同ID(整数列表:所有合同ID - 保留的ID) + removed_contract_ids = list(set(all_contract_ids) - set(remaining_contract_ids)) + bank_ids = self.env["property.bank.statements"].search([('name', '=', self.bank_id.name)]) for rec in bank_ids: if remaining_contract_ids != rec.contract_ids.ids: rec.contract_ids = [(6, 0, remaining_contract_ids)] - + rec.contract_ids1 = [(6, 0, removed_contract_ids)] class PropertyReconciliationLine(models.Model): _name = 'property.reconciliation.line' diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml index 963f40a99..1b11a4d06 100644 --- a/yuthon_will_task/views/yuthon_will_task_views.xml +++ b/yuthon_will_task/views/yuthon_will_task_views.xml @@ -13,17 +13,18 @@ - - - - + + + + + - - + +