forked from Yaltik/golem
[IMP]GOLEM Activity Registration State : rounded payments
Round payments with ceil payments for first ones, balance for the last one (or unique).
This commit is contained in:
parent
7c51acbfc9
commit
c683931250
@ -19,7 +19,7 @@
|
|||||||
'name': 'GOLEM Activity Session Member Registrations States',
|
'name': 'GOLEM Activity Session Member Registrations States',
|
||||||
'summary': 'GOLEM Activities Session Member Registration states',
|
'summary': 'GOLEM Activities Session Member Registration states',
|
||||||
'description': 'GOLEM Activities Session Member Registration states',
|
'description': 'GOLEM Activities Session Member Registration states',
|
||||||
'version': '10.0.1.0.2',
|
'version': '10.0.1.1.0',
|
||||||
'category': 'GOLEM',
|
'category': 'GOLEM',
|
||||||
'author': 'Fabien Bourgeois',
|
'author': 'Fabien Bourgeois',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
""" GOLEM Activity Registration Invoicing Wizard """
|
""" GOLEM Activity Registration Invoicing Wizard """
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from math import ceil
|
||||||
from odoo import models, fields, api
|
from odoo import models, fields, api
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -81,18 +82,21 @@ class GolemActivityRegistrationInvoicing(models.TransientModel):
|
|||||||
""" Create payment if schedule has been chosen """
|
""" Create payment if schedule has been chosen """
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
if self.schedule_id and self.schedule_id.occurences > 0:
|
if self.schedule_id and self.schedule_id.occurences > 0:
|
||||||
# TODO: make more intelligent price cut
|
|
||||||
amount = invoice.amount_total
|
amount = invoice.amount_total
|
||||||
amount_per_occurence = amount / self.schedule_id.occurences
|
amount_per_occurence = ceil(amount / self.schedule_id.occurences)
|
||||||
for day in self.schedule_id.day_ids:
|
for index, day in enumerate(self.schedule_id.day_ids):
|
||||||
|
payment_amount = (amount_per_occurence if index !=
|
||||||
|
(len(self.schedule_id.day_ids.ids) - 1)
|
||||||
|
else amount)
|
||||||
payment = self.env['account.payment'].new({
|
payment = self.env['account.payment'].new({
|
||||||
'payment_type': 'inbound',
|
'payment_type': 'inbound',
|
||||||
'partner_type': 'customer',
|
'partner_type': 'customer',
|
||||||
'partner_id': self.member_id.partner_id.id,
|
'partner_id': self.member_id.partner_id.id,
|
||||||
'amount': amount_per_occurence,
|
'amount': payment_amount,
|
||||||
'payment_date': day.day,
|
'payment_date': day.day,
|
||||||
'journal_id': self.journal_id.id,
|
'journal_id': self.journal_id.id,
|
||||||
})
|
})
|
||||||
|
amount -= amount_per_occurence
|
||||||
payment._onchange_journal()
|
payment._onchange_journal()
|
||||||
payment_values = dict(payment._cache)
|
payment_values = dict(payment._cache)
|
||||||
payment = self.env['account.payment'].create(payment_values)
|
payment = self.env['account.payment'].create(payment_values)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user