|
|
@ -68,6 +68,10 @@ class AccountingFileWizard(models.TransientModel): |
|
|
|
for r in reg: |
|
|
|
r.date_compta=False |
|
|
|
r.date_compta_down_payment=False |
|
|
|
invoices=self.env['account.move'].search([]) |
|
|
|
for i in invoices: |
|
|
|
i.date_compta_out_refund=False |
|
|
|
i.date_compta=False |
|
|
|
|
|
|
|
|
|
|
|
tmstp=secrets.token_hex(16) |
|
|
@ -89,10 +93,11 @@ class AccountingFileWizard(models.TransientModel): |
|
|
|
f.write(fic_line) |
|
|
|
|
|
|
|
|
|
|
|
self.donation_lines(f) |
|
|
|
self.membership_lines(f) |
|
|
|
self.event_lines(f) |
|
|
|
self.booking_event_lines(f) |
|
|
|
#self.donation_lines(f) |
|
|
|
#self.membership_lines(f) |
|
|
|
#self.event_lines(f) |
|
|
|
#self.booking_event_lines(f) |
|
|
|
self.out_refund_lines(f) |
|
|
|
fic_line="TOTAL_DEBIT="+str(total_debit)+ " TOTAL CREDIT="+str(total_credit) |
|
|
|
f.write(fic_line) |
|
|
|
|
|
|
@ -156,7 +161,7 @@ class AccountingFileWizard(models.TransientModel): |
|
|
|
global total_debit |
|
|
|
global total_credit |
|
|
|
global no_mvt |
|
|
|
#écritures pour les dons validés (donc payés), non déjà exportés |
|
|
|
#écritures pour les dons validés (donc payés), non déjà exportés |
|
|
|
donation=self.env['donation.donation'].search([('date_compta','=',False),('state','=','done')]) |
|
|
|
#raise UserError(donation) |
|
|
|
for d in donation: |
|
|
@ -396,6 +401,10 @@ class AccountingFileWizard(models.TransientModel): |
|
|
|
|
|
|
|
account_debit_number=self._file_format(str(self.env['account.payment.mode'].search([('name','=','Paypal')]).fixed_journal_id.default_account_id.code),6) |
|
|
|
|
|
|
|
if trans and trans.acquirer_id.name=='Paiement par carte bancaire': |
|
|
|
|
|
|
|
account_debit_number=self._file_format(str(self.env['account.payment.mode'].search([('name','=','CB')]).fixed_journal_id.default_account_id.code),6) |
|
|
|
|
|
|
|
#recherche de l'adhésion |
|
|
|
membership_credit_line=False |
|
|
|
membership=self.env['kalachakra.membership'].search([('invoice_id','=',int(reg.invoice_id))]) |
|
|
@ -625,6 +634,103 @@ class AccountingFileWizard(models.TransientModel): |
|
|
|
|
|
|
|
_logger.error('TOTAL DEBIT '+str(total_debit)+' TOTAL CREDIT '+str(total_credit)) |
|
|
|
return True |
|
|
|
|
|
|
|
def out_refund_lines(self,f): |
|
|
|
global total_debit |
|
|
|
global total_credit |
|
|
|
global no_mvt |
|
|
|
#écritures pour les avoirs pas encore utilisés ou payés mais jamais passé en compta |
|
|
|
out_refund_invoices=self.env['account.move'].search([('move_type','=','out_refund'),('date_compta','=',False),('date_compta_out_refund','=',False)]) |
|
|
|
for invoice in out_refund_invoices: |
|
|
|
invoice.date_compta_out_refund=date_compta |
|
|
|
firstname=invoice.partner_id.firstname |
|
|
|
name=invoice.partner_id.name |
|
|
|
if not name : name='N/A' |
|
|
|
if not firstname: firstname=' ' |
|
|
|
lib1=firstname[0]+' '+name |
|
|
|
lib1=self._file_format(lib1,12) |
|
|
|
|
|
|
|
lines=self.env['account.move.line'].search([('move_id','=',int(invoice.id))],limit=1) |
|
|
|
if lines: |
|
|
|
|
|
|
|
lib2=self._file_format(lines.name,13) |
|
|
|
else: |
|
|
|
lib2='' |
|
|
|
lib=lib1+' '+lib2 |
|
|
|
|
|
|
|
lib_piece=self._file_format(invoice.name,20) |
|
|
|
#écriture de débit |
|
|
|
amount=invoice.amount_total |
|
|
|
account_debit_number='170000' |
|
|
|
date_line=self._date_format(invoice.invoice_date) |
|
|
|
if amount==0: continue |
|
|
|
debit=str(amount) |
|
|
|
credit='' |
|
|
|
|
|
|
|
fic_line=str(no_mvt)+';'+'IN'+';'+date_line+';'+account_debit_number+';'+lib+';'+debit+';'+credit+';'+lib_piece+'\n' |
|
|
|
f.write(fic_line) |
|
|
|
no_mvt+=1 |
|
|
|
total_debit+=amount |
|
|
|
#écriture de crédit |
|
|
|
debit='' |
|
|
|
credit=str(amount) |
|
|
|
account_credit_number='411000' |
|
|
|
fic_line=str(no_mvt)+';'+'IN'+';'+date_line+';'+account_credit_number+';'+lib+';'+debit+';'+credit+';'+lib_piece+'\n' |
|
|
|
f.write(fic_line) |
|
|
|
no_mvt+=1 |
|
|
|
total_credit+=amount |
|
|
|
|
|
|
|
|
|
|
|
#écritures pour les avoirs qui ont été utilisés |
|
|
|
#écriture Débit 411000 – Crédit 170000 |
|
|
|
out_refund_invoices=self.env['account.move'].search([('move_type','=','out_refund'),('payment_state','=','paid'),('date_compta','=',False)]) |
|
|
|
for invoice in out_refund_invoices: |
|
|
|
invoice.date_compta=date_compta |
|
|
|
firstname=invoice.partner_id.firstname |
|
|
|
name=invoice.partner_id.name |
|
|
|
if not name : name='N/A' |
|
|
|
if not firstname: firstname=' ' |
|
|
|
lib1=firstname[0]+' '+name |
|
|
|
lib1=self._file_format(lib1,12) |
|
|
|
|
|
|
|
lib2='' |
|
|
|
reg=self.env['event.registration'].search(['|',('invoice_id','=',int(invoice.out_invoice_id)),('balance_invoice_id','=',int(invoice.out_invoice_id))]) |
|
|
|
if reg: |
|
|
|
lib2=self._file_format(reg.event_id.name,13) |
|
|
|
|
|
|
|
|
|
|
|
lib=lib1+' '+lib2 |
|
|
|
|
|
|
|
lib_piece=self._file_format(invoice.out_invoice_id.name,20) |
|
|
|
|
|
|
|
#écriture de débit |
|
|
|
amount=invoice.amount_total |
|
|
|
account_debit_number='411000' |
|
|
|
#date du paiement |
|
|
|
if self._payment_date_date(invoice.out_invoice_id):continue |
|
|
|
date_line=self._payment_date(invoice.out_invoice_id) |
|
|
|
|
|
|
|
|
|
|
|
if amount==0: continue |
|
|
|
debit=str(amount) |
|
|
|
credit='' |
|
|
|
|
|
|
|
fic_line=str(no_mvt)+';'+'IN'+';'+date_line+';'+account_debit_number+';'+lib+';'+debit+';'+credit+';'+lib_piece+'\n' |
|
|
|
f.write(fic_line) |
|
|
|
no_mvt+=1 |
|
|
|
total_debit+=amount |
|
|
|
#écriture de crédit |
|
|
|
debit='' |
|
|
|
credit=str(amount) |
|
|
|
account_credit_number='170000' |
|
|
|
fic_line=str(no_mvt)+';'+'IN'+';'+date_line+';'+account_credit_number+';'+lib+';'+debit+';'+credit+';'+lib_piece+'\n' |
|
|
|
f.write(fic_line) |
|
|
|
no_mvt+=1 |
|
|
|
total_credit+=amount |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _file_format(self,data,nbcars): |
|
|
|
if data: |
|
|
|
if len(data)>nbcars: |
|
|
|