This commit is contained in:
李鹏宇
2025-08-03 18:09:56 +08:00
parent 7826bf1b71
commit a57370f099
2 changed files with 10 additions and 21 deletions
+1 -1
View File
@@ -626,7 +626,7 @@ class HolidaysRequestBatch(models.Model):
def _compute_holiday_allowance(self):
for record in self:
reports_id = self.env['yuthon.vacation.reports'].search([('employee_id', '=', record.users_id.employee_id.id)], limit=1)
if reports_id:
if reports_id and not record.log_ids:
leave_hours_str = reports_id.leave.split('小时')[0].strip()
leave_hours = float(leave_hours_str)
leave_days = leave_hours / 8
@@ -10,16 +10,16 @@ class PropertyReconciliationWizard(models.Model):
receivable_total = fields.Float(string='应收金额')
bank_id = fields.Many2one('property.bank.statements', string='银行流水')
account = fields.Char(string='账号')
amount_been_reconciled = fields.Float(string='已对金额', compute="_compute_amount", store=True)
amount_reconciled = fields.Float(string='未对金额', compute="_compute_amount", store=True)
amount_been_reconciled = fields.Float(string='已对金额', store=True)
amount_reconciled = fields.Float(string='未对金额', store=True)
actual_total = fields.Float(string='实收金额')
actual_date = fields.Date(string='实收日期')
initial_total = fields.Float(string='初始金额', default=0.0)
reconciliation_line_ids = fields.One2many('property.reconciliation.line', 'reconciliation_id', string='对账明细')
@api.depends('reconciliation_line_ids')
def _compute_amount(self):
pass
# @api.depends('reconciliation_line_ids')
# def _compute_amount(self):
# pass
# for rec in self:
# rec.amount_been_reconciled = 0.0
# rec.amount_reconciled = 0.0
@@ -30,13 +30,12 @@ class PropertyReconciliationWizard(models.Model):
# else:
# rec.amount_reconciled = 0.0
@api.onchange('reconciliation_line_ids')
@api.onchange('actual_total', 'actual_date')
def _onchange_reconciliation_line_ids(self):
if not self.reconciliation_line_ids:
return
new_lines = []
remaining_amount = self.actual_total
line_count = len(self.reconciliation_line_ids)
# 检查是否有单行的rent等于实际金额
exact_match_line = next((line for line in self.reconciliation_line_ids if line.rent == remaining_amount), None)
if exact_match_line:
@@ -61,37 +60,27 @@ class PropertyReconciliationWizard(models.Model):
if key not in groups:
groups[key] = []
groups[key].append(line)
all_lines = self.reconciliation_line_ids
sorted_lines = sorted(
all_lines,
key=lambda line: line.due_date if line.due_date else fields.Date.max
)
sorted_lines = sorted(all_lines, key=lambda line: line.due_date if line.due_date else fields.Date.max)
for line in sorted_lines:
rent = line.rent or 0
line.amount = 0 # 重置金额
if remaining_amount <= 0:
continue
# 分配不超过租金和剩余金额的数值
assign_amount = min(rent, remaining_amount)
line.amount = assign_amount
remaining_amount -= assign_amount
# 检查是否违约
if (line.due_date and self.actual_date and
line.collection_type != 'deposit'):
if (line.due_date and self.actual_date and line.collection_type != 'deposit'):
# 计算应收日期的下月1号
next_month_first = (fields.Date.from_string(line.due_date) + relativedelta(months=1)).replace(day=1)
# 如果实收日期晚于下月1号,产生违约
if fields.Date.from_string(self.actual_date) > next_month_first:
# 计算违约天数
late_days = (fields.Date.from_string(self.actual_date) - next_month_first).days + 1
# 计算违约金 = 违约天数 * 应收租金 * 违约金百分比
penalty_amount = late_days * line.rent * float(line.contract_id.percentage_liquidated_damages.name)
penalty_amount = late_days * round(line.rent * float(line.contract_id.percentage_liquidated_damages.name), 2)
if penalty_amount > 0:
# 创建新的违约金记录,顺序值为原记录+1
penalty_line_vals = {