@@ -921,8 +921,13 @@ class AppletAttendance(Controller):
|
||||
last_day_str = last_day.strftime('%Y-%m-%d')
|
||||
|
||||
floor_name = request.env['yuthon.epitope.values'].sudo().search([('id', '=', floor_id)]).name
|
||||
domain = [('state', '=', reading_state),
|
||||
('epitope_values_id.name', '=', floor_name),
|
||||
# domain = [('state', '=', reading_state),
|
||||
# ('epitope_values_id.name', '=', floor_name),
|
||||
# ('meter_date', '>=', first_day_str),
|
||||
# ('meter_date', '<=', last_day_str)]
|
||||
|
||||
# 去掉 state
|
||||
domain = [('epitope_values_id.name', '=', floor_name),
|
||||
('meter_date', '>=', first_day_str),
|
||||
('meter_date', '<=', last_day_str)]
|
||||
|
||||
|
||||
@@ -468,8 +468,7 @@ class PropertyBankStatements(models.Model):
|
||||
"dialog_size": "extra-large",
|
||||
"default_order": "due_date desc",
|
||||
}
|
||||
# 未知逻辑忘记可能要补充,只能依次对账
|
||||
# self._check_unreconciled_statements(start_time)
|
||||
self._check_unreconciled_statements(start_time)
|
||||
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
@@ -481,33 +480,32 @@ class PropertyBankStatements(models.Model):
|
||||
"context": context,
|
||||
}
|
||||
|
||||
# def _check_unreconciled_statements(self, current_transaction_time):
|
||||
# """
|
||||
# 检查所有承租方对应的银行账号在property.bank.statements中是否有未对账流水
|
||||
# :param current_transaction_time: 当前交易时间(带时区处理后)
|
||||
# """
|
||||
# if not self.lessee_ids:
|
||||
# return
|
||||
# bank_accounts = self.env['property.bank.line'].search([
|
||||
# ('tenant_id', 'in', self.lessee_ids.ids)
|
||||
# ]).mapped('bank')
|
||||
# bank_accounts = [acc for acc in bank_accounts if acc] # 过滤空值
|
||||
# if not bank_accounts:
|
||||
# return
|
||||
# unreconciled = {}
|
||||
# for account in bank_accounts:
|
||||
# # 查询条件:同账号 + 交易时间早于当前 + 未对账
|
||||
# statements = self.env['property.bank.statements'].search([
|
||||
# ('name', '=', account),
|
||||
# ('start_time', '<', current_transaction_time),
|
||||
# ('bank_state', '=', 'not_reconciled'),
|
||||
# ('id', '!=', self.id),
|
||||
# ])
|
||||
# if statements:
|
||||
# unreconciled[account] = len(statements)
|
||||
#
|
||||
# if unreconciled:
|
||||
# raise UserError("存在未对账的历史流水,请优先处理")
|
||||
def _check_unreconciled_statements(self, current_transaction_time):
|
||||
"""
|
||||
检查所有承租方对应的银行账号在property.bank.statements中是否有未对账流水
|
||||
:param current_transaction_time: 当前交易时间(带时区处理后)
|
||||
"""
|
||||
if not self.lessee_ids:
|
||||
return
|
||||
bank_accounts = self.env['property.bank.line'].search([
|
||||
('tenant_id', 'in', self.lessee_ids.ids)
|
||||
]).mapped('bank')
|
||||
bank_accounts = [acc for acc in bank_accounts if acc] # 过滤空值
|
||||
if not bank_accounts:
|
||||
return
|
||||
unreconciled = {}
|
||||
for account in bank_accounts:
|
||||
# 查询条件:同账号 + 交易时间早于当前 + 未对账
|
||||
statements = self.env['property.bank.statements'].search([
|
||||
('name', '=', account),
|
||||
('start_time', '<', current_transaction_time),
|
||||
('bank_state', '=', 'not_reconciled'),
|
||||
('id', '!=', self.id),
|
||||
])
|
||||
if statements:
|
||||
unreconciled[account] = len(statements)
|
||||
if unreconciled:
|
||||
raise UserError("存在未对账的历史流水,请优先处理:")
|
||||
|
||||
def button_reconciliation(self):
|
||||
for record in self:
|
||||
|
||||
@@ -304,7 +304,7 @@ class PropertyLeaseContract(models.Model):
|
||||
|
||||
name_title = fields.Char(default=_get_default_name_title)
|
||||
|
||||
contract_sort = fields.Selection([('property', '物业'), ('guanggao', '广告位'), ('guanzi', '管子间'), ('room', '机房'), ('base_station','基站'), ('other', '其他')], string="资产类型", default='property')
|
||||
contract_sort = fields.Selection([('property', '物业'), ('guanggao', '广告位'),('parking', '停车场'), ('guanzi', '管子间'), ('room', '机房'), ('base_station','基站'), ('other', '其他')], string="资产类型", default='property')
|
||||
|
||||
@api.depends('lease_ids.address_id.title_deed')
|
||||
def _compute_title_information(self):
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
<field name="bank_id" invisible="1"/>
|
||||
<field name="available_property_ids" widget="many2many_tags" invisible="1"/>
|
||||
<field name="available_contract_ids" widget="many2many_tags" invisible="1"/>
|
||||
<field name="property_ids" widget="many2many_tags" domain="[('id', 'in', available_property_ids)]"/>
|
||||
<field name="contract_ids" widget="many2many_tags" domain="[('id', 'in', available_contract_ids)]"/>
|
||||
<field name="property_ids" widget="many2many_tags" domain="[('id', 'in', available_property_ids)]" options="{'no_create': True}"/>
|
||||
<field name="contract_ids" widget="many2many_tags" domain="[('id', 'in', available_contract_ids)]" options="{'no_create': True}"/>
|
||||
</group>
|
||||
</sheet>
|
||||
<footer>
|
||||
|
||||
@@ -19,6 +19,8 @@ class PropertyReconciliationWizard(models.Model):
|
||||
name_account = fields.Char( string='对方户名')
|
||||
account = fields.Char(string='账号')
|
||||
amount_been_reconciled = fields.Float(string='已对金额', store=True)
|
||||
amount_water_been = fields.Float(string='已对流水金额')
|
||||
amount_water = fields.Float(string='未对流水金额')
|
||||
amount_reconciled = fields.Float(string='未核销', store=True)
|
||||
actual_total = fields.Float(string='实收金额')
|
||||
actual_date = fields.Date(string='实收日期')
|
||||
@@ -34,18 +36,19 @@ class PropertyReconciliationWizard(models.Model):
|
||||
rec.lessee_ids = rec.bank_id.lessee_ids.ids
|
||||
rec.name_account = rec.bank_id.name_account
|
||||
rec.remake = rec.bank_id.remake
|
||||
|
||||
rec.amount_water_been = rec.bank_id.yes_amount
|
||||
rec.amount_water = rec.bank_id.no_amount
|
||||
|
||||
@api.onchange('reconciliation_line_ids', 'actual_total')
|
||||
def _onchange_amount_reconciled(self):
|
||||
for rec in self:
|
||||
rec.amount_reconciled = rec.actual_total - rec.amount_been_reconciled - sum(line.amount for line in rec.reconciliation_line_ids)
|
||||
rec.amount_reconciled = max(rec.bank_id.no_amount - sum(line.amount for line in rec.reconciliation_line_ids), 0)
|
||||
for line in rec.reconciliation_line_ids:
|
||||
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)}'
|
||||
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:
|
||||
@@ -55,7 +58,7 @@ class PropertyReconciliationWizard(models.Model):
|
||||
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) + ',欠' + str(round(line.rent - line.amount, 2))
|
||||
line.remake = str(rec.actual_date) + '预' + str(due_date_str) + ',欠' + str(round(line.rent - line.amount, 2))
|
||||
|
||||
|
||||
@api.depends('reconciliation_line_ids')
|
||||
@@ -88,16 +91,6 @@ 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:
|
||||
@@ -328,7 +321,7 @@ class PropertyReconciliationWizard(models.Model):
|
||||
按已生成的明细行 分配金额
|
||||
:return:
|
||||
"""
|
||||
remaining_amount = self.actual_total
|
||||
remaining_amount = self.bank_id.no_amount
|
||||
rent_lines = [line for line in self.reconciliation_line_ids if line.collection_type == "rent"]
|
||||
other_lines = [line for line in self.reconciliation_line_ids if line.collection_type != "rent"]
|
||||
|
||||
@@ -400,8 +393,8 @@ class PropertyReconciliationWizard(models.Model):
|
||||
for line in rec.reconciliation_line_ids:
|
||||
remaining_amount += line.amount
|
||||
|
||||
if round(rec.actual_total, 2) > round(remaining_amount, 2):
|
||||
rec.bank_id.registered = rec.actual_total - remaining_amount
|
||||
if round(rec.amount_water, 2) > round(remaining_amount, 2):
|
||||
rec.bank_id.registered = rec.amount_water - remaining_amount
|
||||
rec.bank_id.bank_state = 'registered'
|
||||
else:
|
||||
rec.bank_id.registered = 0
|
||||
@@ -452,7 +445,7 @@ class PropertyReconciliationWizard(models.Model):
|
||||
'payout_date': rec.actual_date,
|
||||
'remark': final_remark,
|
||||
'reconciliation_time': fields.Datetime.now(),
|
||||
'receivable_log': f'当前登录人{rec.env.user.name}于{fields.Datetime.now()}对户名为{rec.bank_id.name_account}进行对账操作,对账应收金额为{rec.receivable_total},实际金额为{rec.actual_total}'
|
||||
'receivable_log': f'当前登录人{rec.env.user.name}于{fields.Datetime.now()}对户名为{rec.bank_id.name_account}进行对账操作,对账应收金额为{rec.receivable_total},实际金额为{rec.amount_water}'
|
||||
})
|
||||
self.env['receivable.modify.line'].create({
|
||||
'bank_id': rec.bank_id.id,
|
||||
@@ -522,11 +515,11 @@ class PropertyReconciliationWizard(models.Model):
|
||||
# 计算已对账和未对账金额
|
||||
rec.amount_been_reconciled += line.amount
|
||||
|
||||
if rec.actual_total > rec.amount_been_reconciled:
|
||||
amount_reconciled = rec.actual_total - rec.amount_been_reconciled
|
||||
if rec.amount_water > rec.amount_been_reconciled:
|
||||
amount_reconciled = rec.amount_water - rec.amount_been_reconciled
|
||||
else:
|
||||
amount_reconciled = 0.0
|
||||
rec.bank_id.yes_amount = rec.amount_been_reconciled
|
||||
rec.bank_id.yes_amount = rec.amount_water + rec.amount_water_been
|
||||
rec.bank_id.no_amount = amount_reconciled
|
||||
|
||||
|
||||
|
||||
@@ -19,19 +19,28 @@
|
||||
<field name="bank_branch" invisible="1"/>
|
||||
<field name="account" invisible="1"/>
|
||||
</group>
|
||||
<group col="2">
|
||||
<group>
|
||||
<field name="receivable_total" invisible="1"/>
|
||||
<field name="amount_been_reconciled" invisible="1"/>
|
||||
<field name="initial_total" invisible="1"/>
|
||||
<field name="rent" invisible="1"/>
|
||||
<field name="penalty" invisible="1"/>
|
||||
</group>
|
||||
<group col="4">
|
||||
<group>
|
||||
<field name="actual_total" readonly="1" style="font-weight: bold"/>
|
||||
<field name="receivable_total" invisible="1"/>
|
||||
<field name="amount_reconciled" readonly="1"/>
|
||||
<field name="remake" readonly="1"/>
|
||||
<field name="amount_been_reconciled" invisible="1"/>
|
||||
<field name="initial_total" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="rent" invisible="1"/>
|
||||
<field name="penalty" invisible="1"/>
|
||||
<field name="amount_water_been" readonly="1" style="color: green; font-weight: bold"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="amount_water" readonly="1" style="color: red; font-weight: bold;"/>
|
||||
</group>
|
||||
<group/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="amount_reconciled" readonly="1"/>
|
||||
<field name="remake" readonly="1"/>
|
||||
</group>
|
||||
<notebook>
|
||||
<page name="对账明细">
|
||||
@@ -40,10 +49,10 @@
|
||||
<field name="sequence" column_invisible="1" />
|
||||
<field name="reconciliation_id" column_invisible="1"/>
|
||||
<field name="property_ids" readonly="1" column_invisible="1"/>
|
||||
<field name="collection_type" readonly="1" force_save="1"/>
|
||||
<field name="property_name"/>
|
||||
<field name="contract_id" readonly="1" force_save="1"/>
|
||||
<field name="property_name"/>
|
||||
<field name="due_date" readonly="1" force_save="1"/>
|
||||
<field name="collection_type" readonly="1" force_save="1"/>
|
||||
<field name="rent_month" sum = "Total" readonly="1" force_save="1"/>
|
||||
<field name="rent" sum = "Total" readonly="1" force_save="1"/>
|
||||
<field name="amount" sum = "Total" force_save="1"/>
|
||||
|
||||
Reference in New Issue
Block a user