|
|
@ -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 |
|
|
|