From 38f0315e04c72924dc9980b84bb7faee126d57a1 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 2 Oct 2022 09:56:19 +0200 Subject: [PATCH] export participants retraite --- models/booking_event.py | 91 +++++++++++++++++++++++++--- models/booking_event_registration.py | 80 ------------------------ 2 files changed, 82 insertions(+), 89 deletions(-) diff --git a/models/booking_event.py b/models/booking_event.py index daa927b..9b72031 100755 --- a/models/booking_event.py +++ b/models/booking_event.py @@ -118,15 +118,88 @@ class BookingEvent(models.Model): csv_lines='' for reg in booking.registration_ids: name=str(reg.name) - role=str(self._compute_member_status(reg)) - options=str(self._compute_invoice_options(reg)) - booking_amount=str(self._compute_booking_amount(reg)) - membership_amount=str(self._compute_membership_amount(reg)) + role=self._compute_member_status(reg) + options=self._compute_invoice_options(reg) + booking_amount=self._compute_booking_amount(reg) + membership_amount=self._compute_membership_amount(reg) + invoice_options_amount= self._compute_invoice_options_amount(reg) + amount_to_be_paid=self._compute_amount_to_be_paid(reg) + payment_status=str(reg.payment_status) + payment_mode=self._compute_payment_mode(reg) + amount_paid=self._compute_amount_paid(reg) - csv_lines=csv_lines+name+';'+role+';'+options+';'+booking_amount+';'+membership_amount+'\n' + csv_lines=csv_lines+name+';'+role+';'+options+';'+booking_amount+';'+membership_amount+';'+invoice_options_amount+';'+amount_to_be_paid+';'+payment_status+';'+payment_mode+';'+amount_paid+'\n' return str.encode(header_ligne+csv_lines,'utf-8') + def _compute_payment_mode(self,rec): + + payment_mode='' + if rec.invoice_id: + payment_mode=rec.invoice_id.payment_mode_id.name + if rec.down_payment_invoice_id: + payment_mode=rec.down_payment_invoice_id.payment_mode_id.name + return payment_mode + + def _compute_amount_paid(self,rec): + + amount_paid=0 + if rec.invoice_id: + amount_paid=rec.invoice_id.amount_total-rec.invoice_id.amount_residual + if rec.down_payment_invoice_id: + amount_paid=amount_paid+rec.down_payment_invoice_id.amount_total-rec.down_payment_invoice_id.amount_residual + if rec.balance_invoice_id: + amount_paid=amount_paid+rec.balance_invoice_id.amount_total-rec.balance_invoice_id.amount_residual + if rec.end_of_stay_invoice_id: + amount_paid=amount_paid+rec.end_of_stay_invoice_id.amount_total-rec.end_of_stay_invoice_id.amount_residual + + return str(amount_paid) + def _compute_amount_to_be_paid(self,rec): + + amount_to_be_paid=0 + if rec.invoice_id: + amount_to_be_paid=rec.invoice_id.amount_residual + if rec.down_payment_invoice_id: + amount_to_be_paid=amount_to_be_paid+rec.down_payment_invoice_id.amount_residual + if rec.balance_invoice_id: + amount_to_be_paid=amount_to_be_paid+rec.balance_invoice_id.amount_residual + if rec.end_of_stay_invoice_id: + amount_to_be_paid=amount_to_be_paid+rec.end_of_stay_invoice_id.amount_residual + return str(amount_to_be_paid) + def _compute_invoice_options_amount(self,rec): + membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1) + + invoice_options_amount=0 + #si facture sans acompte: + i=1 + + if rec.invoice_id: + + for line in rec.invoice_id.invoice_line_ids: + if i>1: + if line.name!=membership_product.name: + invoice_options_amount=invoice_options_amount+line.price_subtotal + i=i+1 + #si facture avec acompte: + i=1 + + if rec.balance_invoice_id: + + for line in rec.balance_invoice_id.invoice_line_ids: + if i>1: + if line.name!=membership_product.name: + invoice_options_amount=invoice_options_amount+line.price_subtotal + i=i+1 + i=1 + if rec.end_of_stay_invoice_id: + for line in rec.end_of_stay_invoice_id.invoice_line_ids: + if i>1: + if line.name!=membership_product.name: + invoice_options_amount=invoice_options_amount+line.price_subtotal + + i=i+1 + return str(invoice_options_amount) + def _compute_booking_amount(self,rec): membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1) @@ -146,7 +219,7 @@ class BookingEvent(models.Model): if line.name==membership_product.name: booking_amount=rec.booking_amount+line.price_subtotal break - return booking_amount + return str(booking_amount) def _compute_member_status(self,reg): @@ -160,7 +233,7 @@ class BookingEvent(models.Model): status=participant.member_status else: status='not member' - return status + return str(status) def _compute_membership_amount(self,rec): membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1) @@ -181,7 +254,7 @@ class BookingEvent(models.Model): if line.name==membership_product.name: membership_amount=line.price_subtotal - return membership_amount + return str(membership_amount) def _compute_invoice_options(self,rec): @@ -217,7 +290,7 @@ class BookingEvent(models.Model): invoice_options=invoice_options+str(line.name)+'('+str(line.price_subtotal)+' €)- ' i=i+1 - return invoice_options + return str(invoice_options) # booking_option_ids=fields.One2many('booking.option','event_id','booking options') # @api.model diff --git a/models/booking_event_registration.py b/models/booking_event_registration.py index 2c3e1fd..ac7f868 100755 --- a/models/booking_event_registration.py +++ b/models/booking_event_registration.py @@ -103,86 +103,6 @@ class EventRegistration(models.Model): start_day_individual_booking=fields.Date('Start day individual booking') end_day_individual_booking=fields.Date('End day individual booking') - #pour rapport - # member_status=fields.Char('member status', compute='_compute_member_status') - # invoice_options_amount=fields.Float('invoice options amount',compute='_compute_invoice_options_amount') - # membership_amount=fields.Float('membership amount',compute='_compute_membership_amount') - # booking_amount=fields.Float('booking amount',compute='_compute_booking_amount') - # amount_to_be_paid=fields.Float('booking amount to be paid',compute='_compute_amount_to_be_paid') - # amount_paid=fields.Float('booking amount paid',compute='_compute_amount_paid') - # invoice_options=fields.Char('invoice options',compute='_compute_invoice_options') - # payment_mode=fields.Char('invoice options',compute='_compute_payment_mode') - - def _compute_payment_mode(self): - for rec in self: - rec.payment_mode='' - if rec.invoice_id: - rec.payment_mode=rec.invoice_id.payment_mode_id.name - if rec.down_payment_invoice_id: - rec.payment_mode=rec.down_payment_invoice_id.payment_mode_id.name - - def _compute_amount_paid(self): - for rec in self: - rec.amount_paid=0 - if rec.invoice_id: - rec.amount_paid=rec.invoice_id.amount_total-rec.invoice_id.amount_residual - if rec.down_payment_invoice_id: - rec.amount_paid=rec.amount_paid+rec.down_payment_invoice_id.amount_total-rec.down_payment_invoice_id.amount_residual - if rec.balance_invoice_id: - rec.amount_paid=rec.amount_paid+rec.balance_invoice_id.amount_total-rec.balance_invoice_id.amount_residual - if rec.end_of_stay_invoice_id: - rec.amount_paid=rec.amount_paid+rec.end_of_stay_invoice_id.amount_total-rec.end_of_stay_invoice_id.amount_residual - - def _compute_amount_to_be_paid(self): - for rec in self: - rec.amount_to_be_paid=0 - if rec.invoice_id: - rec.amount_to_be_paid=rec.invoice_id.amount_residual - if rec.down_payment_invoice_id: - rec.amount_to_be_paid=rec.amount_to_be_paid+rec.down_payment_invoice_id.amount_residual - if rec.balance_invoice_id: - rec.amount_to_be_paid=rec.amount_to_be_paid+rec.balance_invoice_id.amount_residual - if rec.end_of_stay_invoice_id: - rec.amount_to_be_paid=rec.amount_to_be_paid+rec.end_of_stay_invoice_id.amount_residual - - - - - - def _compute_invoice_options_amount(self): - membership_product=self.env['product.product'].sudo().search([('membership_product','=',True)],limit=1) - for rec in self: - rec.invoice_options_amount=0 - #si facture sans acompte: - i=1 - - if rec.invoice_id: - - for line in rec.invoice_id.invoice_line_ids: - if i>1: - if line.name!=membership_product.name: - rec.invoice_options_amount=rec.invoice_options_amount+line.price_subtotal - i=i+1 - #si facture avec acompte: - i=1 - - if rec.balance_invoice_id: - - for line in rec.balance_invoice_id.invoice_line_ids: - if i>1: - if line.name!=membership_product.name: - rec.invoice_options_amount=rec.invoice_options_amount+line.price_subtotal - i=i+1 - i=1 - if rec.end_of_stay_invoice_id: - for line in rec.end_of_stay_invoice_id.invoice_line_ids: - if i>1: - if line.name!=membership_product.name: - rec.invoice_options_amount=rec.invoice_options_amount+line.price_subtotal - - i=i+1 - - def compute_individual_room(self): for rec in self: