Update rental_contract.py
This commit is contained in:
parent
9e25dfddd0
commit
fdba373106
|
|
@ -560,6 +560,7 @@ class RentalContract(models.Model):
|
|||
tax_amount = round(self.tax_id.amount / 100 * rent_amount_per_payment, 2)
|
||||
total_amount = round(untaxed_amount + tax_amount, 2)
|
||||
|
||||
|
||||
next_date = date_from
|
||||
service_next_date = date_from
|
||||
payment = 0
|
||||
|
|
@ -572,27 +573,24 @@ class RentalContract(models.Model):
|
|||
rent_amount_per_payment = raise_line.rent_amount_after_raise / (rent_factor / months)
|
||||
# Calculate the amounts
|
||||
|
||||
# Insert rent payment line
|
||||
self._cr.execute('INSERT INTO rent_payment \
|
||||
(name, contract_id, due_date, property_id, amount, water_cost, service_cost, user_id, company_id, state, tax_id, untaxed_amount, tax_amount, total_amount) \
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING id',
|
||||
(
|
||||
_('Payment %s') % (payment + 1),
|
||||
self.id,
|
||||
next_date.strftime('%Y-%m-%d'),
|
||||
self.property_id.id,
|
||||
rent_amount_per_payment,
|
||||
water_amount_per_payment if payment < no_services_payment else 0.0,
|
||||
services_amount_per_payment if payment < no_services_payment else 0.0,
|
||||
self.user_id.id,
|
||||
self.env.user.company_id.id,
|
||||
'draft',
|
||||
self.tax_id.id,
|
||||
untaxed_amount,
|
||||
tax_amount,
|
||||
total_amount
|
||||
))
|
||||
|
||||
self._cr.execute('INSERT INTO rent_payment \
|
||||
(name, contract_id, due_date, property_id, amount, water_cost, service_cost, user_id, company_id, state, tax_id, untaxed_amount, tax_amount) \
|
||||
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING id',
|
||||
(
|
||||
_('Payment %s') % (payment + 1),
|
||||
self.id,
|
||||
next_date.strftime('%Y-%m-%d'),
|
||||
self.property_id.id,
|
||||
rent_amount_per_payment,
|
||||
water_amount_per_payment if payment < no_services_payment else 0.0,
|
||||
services_amount_per_payment if payment < no_services_payment else 0.0,
|
||||
self.user_id.id,
|
||||
self.env.user.company_id.id,
|
||||
'draft',
|
||||
self.tax_id.id,
|
||||
untaxed_amount,
|
||||
tax_amount
|
||||
))
|
||||
# Move to the next payment date
|
||||
next_date += relativedelta(months=months)
|
||||
payment += 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue