diff --git a/yuthon_property/wizard/__init__.py b/yuthon_property/wizard/__init__.py
index 381b1b454..14234ab69 100644
--- a/yuthon_property/wizard/__init__.py
+++ b/yuthon_property/wizard/__init__.py
@@ -4,3 +4,4 @@ from . import property_tenant_wizard
from . import property_water_wizard
from . import property_statements_wizard
from . import evaluation_plan_wizard
+from . import receivable_log_wizard
diff --git a/yuthon_property/wizard/property_statements_wizard.py b/yuthon_property/wizard/property_statements_wizard.py
index fd7017d7b..8d8b6a949 100644
--- a/yuthon_property/wizard/property_statements_wizard.py
+++ b/yuthon_property/wizard/property_statements_wizard.py
@@ -120,6 +120,30 @@ class PropertyStatementsWizard(models.Model):
'message':message,
}
if original_amount:
- self.env['property.bank.statements'].create(bank_data)
+ statements = self.env['property.bank.statements'].create(bank_data)
+ self._handle_contract_penalty(statements)
else:
- pass
\ No newline at end of file
+ pass
+
+ def _handle_contract_penalty(self, record):
+ '''
+ 处理合同违约金
+ :param record: property.bank.statements 记录
+ :return:
+ '''
+ for contract_id in record.contract_ids:
+ receivable_id = self.env['property.accounts.receivable'].search([('contract_id', '=', contract_id.id)])
+ if receivable_id:
+ dt = datetime.strptime(str(record.start_time), '%Y-%m-%d %H:%M:%S').date() # 流水交易时间
+ due = datetime.strptime(str(receivable_id.due_date), '%Y-%m-%d').date() + relativedelta(months=1, day=1) # 应收日期
+ # 判断是否违约
+ if receivable_id.submitted and not receivable_id.is_reconciliation or not receivable_id.is_suspend:
+ original_amount = (due - dt).days * receivable_id.original_amount * int(receivable_id.percentage_liquidated_damages.name)
+ self.env['property.penalty.list'].create({
+ 'contract_id': contract_id.id,
+ 'property_id': contract_id.lease_ids[0].address_id.id,
+ 'lessee_id': contract_id.lessee_id.id,
+ 'original_amount': original_amount
+ })
+ receivable_id.write({'penalty':original_amount})
+ receivable_id.is_reconciliation = True
\ No newline at end of file
diff --git a/yuthon_property/wizard/receivable_log_wizard.py b/yuthon_property/wizard/receivable_log_wizard.py
new file mode 100644
index 000000000..82ae58995
--- /dev/null
+++ b/yuthon_property/wizard/receivable_log_wizard.py
@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+from odoo import models, fields, api, _, SUPERUSER_ID
+from odoo.exceptions import ValidationError, UserError
+from pypinyin import pinyin, Style
+import xlrd
+import base64
+import datetime
+from datetime import datetime
+
+
+class ReceivableLogWizard(models.Model):
+ _name = 'receivable.log.wizard'
+ _description = '应收日志'
+
+ name = fields.Text(string='应收日志')
+
+
+
diff --git a/yuthon_property/wizard/receivable_log_wizard_views.xml b/yuthon_property/wizard/receivable_log_wizard_views.xml
new file mode 100644
index 000000000..26b9f86e6
--- /dev/null
+++ b/yuthon_property/wizard/receivable_log_wizard_views.xml
@@ -0,0 +1,17 @@
+
+
+
+ 应收日志
+ receivable.log.wizard
+
+
+
+
+
+
diff --git a/yuthon_property_approval/models/inherit_yuthon_property.py b/yuthon_property_approval/models/inherit_yuthon_property.py
index 9e7633c45..f0ffa5cca 100644
--- a/yuthon_property_approval/models/inherit_yuthon_property.py
+++ b/yuthon_property_approval/models/inherit_yuthon_property.py
@@ -3,6 +3,7 @@ from odoo.tools.float_utils import float_round
from numpy.ma.core import default_filler
from odoo import models, fields, api, exceptions, _
from odoo.exceptions import UserError, ValidationError
+from dateutil.relativedelta import relativedelta
class YuthonProperty(models.Model):
@@ -39,7 +40,7 @@ class PropertyBankStatements(models.Model):
for record in statements_ids:
self._handle_contract_penalty(record)
-
+ # 违约金计算
def _handle_contract_penalty(self, record):
'''
处理合同违约金
@@ -49,11 +50,11 @@ class PropertyBankStatements(models.Model):
for contract_id in record.contract_ids:
receivable_id = self.env['property.accounts.receivable'].search([('contract_id', '=', contract_id.id)])
if receivable_id:
- dt = datetime.strptime(str(record.start_time), '%Y-%m-%d %H:%M:%S').date() # 对账日期
- due = datetime.strptime(str(receivable_id.due_date), '%Y-%m-%d').date() # 应收日期
+ dt = datetime.strptime(str(record.start_time), '%Y-%m-%d %H:%M:%S').date() # 流水交易时间
+ due = datetime.strptime(str(receivable_id.due_date), '%Y-%m-%d').date() + relativedelta(months=1, day=1) # 应收日期
# 判断是否违约
- if receivable_id.due_date > record.start_time and not receivable_id.is_reconciliation or not receivable_id.is_suspend:
- original_amount = (due - dt).days * (receivable_id.original_amount - record.original_amount) * 0.001
+ if receivable_id.submitted and not receivable_id.is_reconciliation or not receivable_id.is_suspend:
+ original_amount = (due - dt).days * (receivable_id.original_amount - record.original_amount) * int(receivable_id.percentage_liquidated_damages.name)
self.env['property.penalty.list'].create({
'contract_id': contract_id.id,
'property_id': contract_id.lease_ids[0].address_id.id,
@@ -78,9 +79,6 @@ class PropertyBankStatements(models.Model):
water_ids = self.env['property.water.list'].search([('lessee_id', '=', tenant_id.id)])
# 应收电费
electricity_ids = self.env['property.tariff.list'].search([('lessee_id', '=', tenant_id.id)])
- # 应收违约金
- penalty_ids = self.env['property.penalty.list'].search([('lessee_id', '=', tenant_id.id)])
-
def create_reconciliation_vals(ids, collection_type_val):
"""
@@ -88,6 +86,17 @@ class PropertyBankStatements(models.Model):
:param collection_type_val: 费用类型(如 'rent', 'deposit')
:return: 格式化后的费用行列表
"""
+ collection_type_dict = {
+ 'deposit': '押金',
+ 'rent': '租金',
+ 'water_fee': '水费',
+ 'electricity_fee': '电费',
+ 'penalty': '违约',
+ 'management_fee': '管理费',
+ 'repair_fee': '维修费',
+ 'other': '其他'
+ }
+
nonlocal total_rent_month
vals_list = []
# 特殊处理:押金类型需要去重相同合同的记录
@@ -105,6 +114,11 @@ class PropertyBankStatements(models.Model):
due_date = False
if contract_id:
due_date = sub_record.contract_id.actual_start_time
+ management_type_id = self.env['yuthon.management.type'].search(
+ [('name', '=', collection_type_dict[collection_type_val])], limit=1)
+ accounts_id = self.env['property.accounts.receivable'].search(
+ [('lessee_id', '=', tenant_id.id), ('due_date', '=', due_date),
+ ('management_type_id', '=', management_type_id.id)], limit=1)
# 构建对账行数据
vals = {
'property_id': property_id,
@@ -113,6 +127,7 @@ class PropertyBankStatements(models.Model):
'rent': original_amount,
'collection_type': collection_type_val,
'due_date': due_date, # 押金类型使用合同实际开始日期
+ 'penalty': accounts_id.penalty if accounts_id else 0,
}
total_rent_month += original_amount # 累加总金额
vals_list.append((0, 0, vals))
@@ -126,6 +141,11 @@ class PropertyBankStatements(models.Model):
contract_id = sub_record.contract_id.id if sub_record.contract_id else False
original_amount = sub_record.original_amount if sub_record.original_amount else 0
due_date = sub_record.due_date if sub_record.due_date else False
+ management_type_id = self.env['yuthon.management.type'].search(
+ [('name', '=', collection_type_dict[collection_type_val])], limit=1)
+ accounts_id = self.env['property.accounts.receivable'].search(
+ [('lessee_id', '=', tenant_id.id), ('due_date', '=', due_date),
+ ('management_type_id', '=', management_type_id.id)], limit=1)
vals = {
'property_id': property_id,
'contract_id': contract_id,
@@ -133,11 +153,11 @@ class PropertyBankStatements(models.Model):
'rent': original_amount,
'collection_type': collection_type_val,
'due_date': due_date,
+ 'penalty': accounts_id.penalty if accounts_id else 0,
}
total_rent_month += original_amount # 累加总金额
vals_list.append((0, 0, vals))
-
return vals_list
all_vals = []
@@ -158,6 +178,7 @@ class PropertyBankStatements(models.Model):
:return:
"""
context = {
+ "default_bank_id": self.id,
"default_account": record.name,
"default_actual_total": record.original_amount,
"default_reconciliation_line_ids": all_vals,
@@ -175,7 +196,6 @@ class PropertyBankStatements(models.Model):
def button_reconciliation(self):
for record in self:
- self._handle_contract_penalty(record)
all_vals, total_rent_month = self._get_reconciliation_vals(record)
return self._get_context_and_action(record, all_vals, total_rent_month)
@@ -184,7 +204,6 @@ class PropertyBankStatements(models.Model):
total_all_vals = []
grand_total_rent_month = 0
for record in statements_ids:
- self._handle_contract_penalty(record)
all_vals, total_rent_month = self._get_reconciliation_vals(record)
total_all_vals.extend(all_vals)
grand_total_rent_month += total_rent_month
diff --git a/yuthon_property_approval/views/inherit_yuthon_property_views.xml b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
index 1ae0f18d9..a872dab40 100644
--- a/yuthon_property_approval/views/inherit_yuthon_property_views.xml
+++ b/yuthon_property_approval/views/inherit_yuthon_property_views.xml
@@ -341,7 +341,7 @@
-
+
@@ -390,9 +390,6 @@
-
-
-
diff --git a/yuthon_property_approval/views/property_accounts_approval_views.xml b/yuthon_property_approval/views/property_accounts_approval_views.xml
index 53da0a1c3..cb9cf86a8 100644
--- a/yuthon_property_approval/views/property_accounts_approval_views.xml
+++ b/yuthon_property_approval/views/property_accounts_approval_views.xml
@@ -57,7 +57,6 @@
-
diff --git a/yuthon_property_approval/wizard/property_reconciliation_wizard.py b/yuthon_property_approval/wizard/property_reconciliation_wizard.py
index f094722dd..66e9b3de3 100644
--- a/yuthon_property_approval/wizard/property_reconciliation_wizard.py
+++ b/yuthon_property_approval/wizard/property_reconciliation_wizard.py
@@ -7,6 +7,7 @@ class PropertyReconciliationWizard(models.Model):
_description = '对账弹窗'
receivable_total = fields.Float(string='应收金额')
+ bank_id = fields.Many2one('property.bank.statements', string='银行流水')
account = fields.Char(string='账号')
actual_total = fields.Float(string='实收金额')
initial_total = fields.Float(string='初始金额', default=0.0)
@@ -19,20 +20,26 @@ class PropertyReconciliationWizard(models.Model):
# 首次设置时记录初始值
if not self.initial_total:
self.initial_total = self.actual_total
- # 遍历明细行,按规则分配金额
- for index, line in enumerate(self.reconciliation_line_ids):
- if index == 0:
- # 第一行等于初始值
- line.amount = self.initial_total
- elif index == 1:
- # 第二行等于当前值减去初始值
- line.amount = max(0, self.actual_total - self.initial_total)
+
+ remaining_amount = self.actual_total
+
+ for line in self.reconciliation_line_ids:
+ if remaining_amount <= 0:
+ line.amount = 0 # 没有剩余金额,设为0
else:
- # 第三行及以后:当前值 - (初始值 * 行号),但不小于0
- line.amount = max(0, self.actual_total - (self.initial_total * index))
+ line.amount = min(self.initial_total, remaining_amount) # 分配初始值或剩余金额(取较小值)
+ remaining_amount -= line.amount # 更新剩余金额
def confirm(self):
- pass
+ for rec in self:
+ if rec.actual_total> rec.receivable_total:
+ rec.bank_id.registered = rec.actual_total - rec.receivable_total
+
+ receivable_ids = self.env['property.accounts.receivable'].search([('lessee_id.name', '=', self.bank_id.name_account)])
+ for receivable in receivable_ids:
+ receivable.write({'receivable_log': f'当前登录人{self.env.user.name}于{fields.Datetime.now()}对户名为{self.bank_id.name_account}进行对账操作,对账应收金额为{self.receivable_total}'
+ f'实际金额为{self.actual_total}'})
+
class PropertyReconciliationLine(models.Model):
_name = 'property.reconciliation.line'
diff --git a/yuthon_will_task/data/task_code_data.xml b/yuthon_will_task/data/task_code_data.xml
new file mode 100644
index 000000000..b85b2ad5e
--- /dev/null
+++ b/yuthon_will_task/data/task_code_data.xml
@@ -0,0 +1,10 @@
+
+
+
+ 日程编号
+ task_code
+ RC%(y)s%(month)s%(day)s
+ 3
+
+
+
diff --git a/yuthon_will_task/models/yuthon_will_task.py b/yuthon_will_task/models/yuthon_will_task.py
index a400e241e..d57bfe59d 100644
--- a/yuthon_will_task/models/yuthon_will_task.py
+++ b/yuthon_will_task/models/yuthon_will_task.py
@@ -67,6 +67,7 @@ class YuthonWillTask(models.Model):
priority = fields.Selection([('general', '不紧急不重要'), ('important', '重要不紧急'),
('urgent', '紧急不重要'), ('very_urgent', '重要且紧急')], string='优先级')
+ code = fields.Char(string="任务编号", default=lambda self: self.env['ir.sequence'].next_by_code('task_code'))
user_id = fields.Many2one('res.users', string="创建人", default=lambda self: self.env.user)
company_id = fields.Many2one('res.company', string="公司", default=lambda self: self.env.company)
task_content = fields.Text(string='任务内容')
diff --git a/yuthon_will_task/views/yuthon_will_task_views.xml b/yuthon_will_task/views/yuthon_will_task_views.xml
index 4f60f9570..e6ac46b58 100644
--- a/yuthon_will_task/views/yuthon_will_task_views.xml
+++ b/yuthon_will_task/views/yuthon_will_task_views.xml
@@ -47,12 +47,29 @@