添加功能

This commit is contained in:
李鹏宇
2025-10-30 10:48:16 +08:00
parent 4e879946fb
commit aa449006f8
2 changed files with 6 additions and 5 deletions
@@ -216,7 +216,7 @@ class MeterArchivesLine(models.Model):
unit_number = fields.Char(string="单元编号/用途")
gauge_magnification = fields.Integer(string="仪表倍率", default=1)
last_reading_time = fields.Date(string="最后读数时间")
receivables = fields.Float(string="应收", compute="_compute_receivables", store=True, help="应收金额=本次用量*单价*(1+线损)")
receivables = fields.Float(string="应收", store=True, help="应收金额=本次用量*单价*(1+线损)")
unit = fields.Float(string="当月单价", group_operator=None, digits=(16, 4))
line_loss = fields.Float(string="线损", default=0.02)
type = fields.Selection([("public", "公共"), ("fees", "收费")], string="类型")
@@ -254,8 +254,8 @@ class MeterArchivesLine(models.Model):
else:
record.current_meter = 0
@api.depends('line_loss', 'current_meter', 'unit')
def _compute_receivables(self):
@api.constrains('line_loss', 'current_meter', 'unit')
def _constrains_receivables(self):
for record in self:
if record.line_loss and record.current_meter and record.unit:
raw_value = record.current_meter * record.unit * (1 + record.line_loss) * record.gauge_magnification
@@ -407,6 +407,7 @@ class PropertyReconciliationWizard(models.Model):
rec.bank_id.registered = 0
rec.bank_id.bank_state = 'reconciled'
rec.bank_id.reconciliation_time = fields.Datetime.now() - timedelta(hours=8)
yes_amount = 0
for line in rec.reconciliation_line_ids:
# 跳过金额为0的行
if (line.amount == 0 and line.collection_type != 'penalty') or \
@@ -519,10 +520,10 @@ class PropertyReconciliationWizard(models.Model):
'amount': line.amount,
})
# 计算已对账和未对账金额
rec.amount_been_reconciled += line.amount
yes_amount += line.amount
rec.bank_id.yes_amount = rec.amount_water + rec.amount_water_been
rec.bank_id.yes_amount = yes_amount
rec.bank_id.change_amount = sum(line.amount for line in rec.reconciliation_line_ids)
all_contracts = self.bank_id.contract_ids