@ -97,7 +97,7 @@ class AccountingFileWizard(models.TransientModel):
#N° de pièce: ref transaction , ex: txD-457
#N° de pièce: ref transaction , ex: txD-457
fic_line = " N° mouvement;Code du journal;Date;N° de compte;Libellé;Débit;Crédit;N° de pièce" + " \n "
fic_line = ' " N° mouvement;Code du journal;Date;N° de compte;Libellé;Débit;Crédit;N° de pièce' + ' " ' + " \n "
f . write ( fic_line )
f . write ( fic_line )
@ -135,7 +135,10 @@ class AccountingFileWizard(models.TransientModel):
}
}
def _accounting_line ( self , no_mvt , date_line , account_number , lib , debit , credit , lib_piece ) :
return ' " ' + str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' " ' + ' \n '
def donation_lines ( self , f ) :
def donation_lines ( self , f ) :
global total_debit
global total_debit
global total_credit
global total_credit
@ -192,14 +195,16 @@ class AccountingFileWizard(models.TransientModel):
debit = ' '
debit = ' '
credit = str ( amount )
credit = str ( amount )
total_credit + = amount
total_credit + = amount
account_number = account_credit_number
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt + = 1
no_mvt + = 1
#debit line
#debit line
debit = str ( amount )
debit = str ( amount )
credit = ' '
credit = ' '
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_debit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_debit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
total_debit + = amount
total_debit + = amount
no_mvt + = 1
no_mvt + = 1
@ -260,15 +265,16 @@ class AccountingFileWizard(models.TransientModel):
lib = lib1 + ' ' + lib2
lib = lib1 + ' ' + lib2
debit = ' '
debit = ' '
credit = str ( amount )
credit = str ( amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt + = 1
no_mvt + = 1
total_credit + = amount
total_credit + = amount
#debit line
#debit line
debit = str ( amount )
debit = str ( amount )
credit = ' '
credit = ' '
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_debit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_debit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt + = 1
no_mvt + = 1
total_debit + = amount
total_debit + = amount
@ -339,15 +345,16 @@ class AccountingFileWizard(models.TransientModel):
lib = lib1 + ' ' + lib2
lib = lib1 + ' ' + lib2
debit = ' '
debit = ' '
credit = str ( amount - membership_amount )
credit = str ( amount - membership_amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt + = 1
no_mvt + = 1
total_credit + = amount
total_credit + = amount
#debit line
#debit line
debit = str ( amount - membership_amount )
debit = str ( amount - membership_amount )
credit = ' '
credit = ' '
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_debit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_debit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt + = 1
no_mvt + = 1
total_debit + = amount
total_debit + = amount
@ -412,14 +419,16 @@ class AccountingFileWizard(models.TransientModel):
debit = str ( amount )
debit = str ( amount )
credit = ' '
credit = ' '
lib_piece = self . _file_format ( reg . end_of_stay_invoice_id . name , 20 )
lib_piece = self . _file_format ( reg . end_of_stay_invoice_id . name , 20 )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_debit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_debit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt + = 1
no_mvt + = 1
total_debit + = amount
total_debit + = amount
#écriture de crédit
#écriture de crédit
debit = ' '
debit = ' '
credit = str ( amount - membership_amount - donation_amount )
credit = str ( amount - membership_amount - donation_amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt + = 1
no_mvt + = 1
total_credit + = amount
total_credit + = amount
@ -427,8 +436,8 @@ class AccountingFileWizard(models.TransientModel):
if membership_credit_line :
if membership_credit_line :
debit = ' '
debit = ' '
credit = str ( membership_amount )
credit = str ( membership_amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + self . _file_format ( ' 756100 ' , 6 ) + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = self . _file_format ( ' 756100 ' , 6 )
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt = no_mvt + 1
no_mvt = no_mvt + 1
total_credit + = membership_amount
total_credit + = membership_amount
@ -438,7 +447,8 @@ class AccountingFileWizard(models.TransientModel):
debit = ' '
debit = ' '
amount = d . amount_total
amount = d . amount_total
credit = str ( amount )
credit = str ( amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt = no_mvt + 1
no_mvt = no_mvt + 1
total_credit + = amount
total_credit + = amount
@ -478,7 +488,7 @@ class AccountingFileWizard(models.TransientModel):
lib = lib1 + ' ' + lib2
lib = lib1 + ' ' + lib2
#si pas de facture d'acompte et facture payée:
#si pas de facture d'acompte et facture payée:
if not reg . down_payment_invoice_id and reg . invoice_id . payment_state == ' paid ' and reg . date_compta == False :
if not reg . down_payment_invoice_id and reg . balance_invoice_id . amount_total > 0 and reg . invoice_id . payment_state == ' paid ' and reg . date_compta == False :
_logger . error ( ' CC1 ' )
_logger . error ( ' CC1 ' )
if reg . date_payment and reg . date_payment < self . start_date . date ( ) : continue
if reg . date_payment and reg . date_payment < self . start_date . date ( ) : continue
@ -536,9 +546,16 @@ class AccountingFileWizard(models.TransientModel):
trans = self . env [ ' payment.transaction ' ] . search ( [ ( ' invoice_ids ' , ' in ' , reg . down_payment_invoice_id . id ) , ( ' state ' , ' = ' , ' done ' ) ] , limit = 1 )
trans = self . env [ ' payment.transaction ' ] . search ( [ ( ' invoice_ids ' , ' in ' , reg . down_payment_invoice_id . id ) , ( ' state ' , ' = ' , ' done ' ) ] , limit = 1 )
if trans and trans . acquirer_id . name == ' Paypal ' : 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 == ' Paypal ' : 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 )
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 )
#_logger.error('facture='+str(reg.down_payment_invoice_id.name)+str(reg.date_payment_down_payment))
if reg . date_payment_down_payment :
if reg . date_payment_down_payment > = self . start_date . date ( ) :
amount = reg . down_payment_invoice_id . amount_total + reg . balance_invoice_id . amount_total
else :
amount = reg . balance_invoice_id . amount_total
else :
#si pas de date de paiement, la facture doit être à zero
amount = reg . balance_invoice_id . amount_total
amount = reg . down_payment_invoice_id . amount_total + reg . balance_invoice_id . amount_total
date_line = self . _date_format ( reg . date_payment_balance )
date_line = self . _date_format ( reg . date_payment_balance )
@ -558,7 +575,7 @@ class AccountingFileWizard(models.TransientModel):
for d in donations :
for d in donations :
donation_amount = donation_amount + d . amount_total
donation_amount = donation_amount + d . amount_total
trans = self . env [ ' payment.transaction ' ] . search ( [ ( ' state ' , ' = ' , ' done ' ) , ( ' invoice_ids ' , ' in ' , reg . down_payment _invoice_id. id ) ] , limit = 1 )
trans = self . env [ ' payment.transaction ' ] . search ( [ ( ' state ' , ' = ' , ' done ' ) , ( ' invoice_ids ' , ' in ' , reg . balance _invoice_id. id ) ] , limit = 1 )
#si facture d'acompte payée pas encore exporté et solde non payée :
#si facture d'acompte payée pas encore exporté et solde non payée :
elif reg . down_payment_invoice_id . payment_state == ' paid ' and not reg . date_compta_down_payment and reg . balance_invoice_id . payment_state != ' paid ' :
elif reg . down_payment_invoice_id . payment_state == ' paid ' and not reg . date_compta_down_payment and reg . balance_invoice_id . payment_state != ' paid ' :
@ -629,13 +646,23 @@ class AccountingFileWizard(models.TransientModel):
#debit line
#debit line
if case_line == 1 : amount = reg . invoice_id . amount_total
if case_line == 1 : amount = reg . invoice_id . amount_total
if case_line == 2 : amount = reg . down_payment_invoice_id . amount_total + reg . balance_invoice_id . amount_total
if case_line == 2 :
down_payment_already_in_accounting = True
if reg . date_payment_down_payment :
if reg . date_payment_down_payment > = self . start_date . date ( ) :
down_payment_already_in_accounting = False
amount = reg . down_payment_invoice_id . amount_total + reg . balance_invoice_id . amount_total
else :
amount = reg . balance_invoice_id . amount_total
if case_line == 3 : amount = reg . down_payment_invoice_id . amount_total
if case_line == 3 : amount = reg . down_payment_invoice_id . amount_total
if case_line == 4 : amount = reg . balance_invoice_id . amount_total
if case_line == 4 : amount = reg . balance_invoice_id . amount_total
if amount == 0 : continue
if amount == 0 : continue
credit = ' '
credit = ' '
debit = str ( amount )
debit = str ( amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_debit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_debit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt = no_mvt + 1
no_mvt = no_mvt + 1
total_debit + = amount
total_debit + = amount
@ -648,23 +675,27 @@ class AccountingFileWizard(models.TransientModel):
amount = amount - membership_amount - donation_amount
amount = amount - membership_amount - donation_amount
debit = ' '
debit = ' '
credit = str ( amount )
credit = str ( amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt = no_mvt + 1
no_mvt = no_mvt + 1
total_credit + = amount
total_credit + = amount
if case_line == 2 :
if case_line == 2 :
amount = reg . down_payment_invoice_id . amount_total
debit = ' '
credit = str ( amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
f . write ( fic_line )
no_mvt = no_mvt + 1
total_credit + = amount
if not down_payment_already_in_accounting :
amount = reg . down_payment_invoice_id . amount_total
debit = ' '
credit = str ( amount )
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
no_mvt = no_mvt + 1
total_credit + = amount
amount = float ( reg . balance_invoice_id . amount_total ) - float ( membership_amount ) - float ( donation_amount )
amount = float ( reg . balance_invoice_id . amount_total ) - float ( membership_amount ) - float ( donation_amount )
debit = ' '
debit = ' '
credit = str ( amount )
credit = str ( amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt = no_mvt + 1
no_mvt = no_mvt + 1
total_credit + = amount
total_credit + = amount
@ -672,7 +703,8 @@ class AccountingFileWizard(models.TransientModel):
amount = reg . down_payment_invoice_id . amount_total
amount = reg . down_payment_invoice_id . amount_total
debit = ' '
debit = ' '
credit = str ( amount )
credit = str ( amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt = no_mvt + 1
no_mvt = no_mvt + 1
total_credit + = amount
total_credit + = amount
@ -680,7 +712,8 @@ class AccountingFileWizard(models.TransientModel):
amount = reg . balance_invoice_id . amount_total - membership_amount - donation_amount
amount = reg . balance_invoice_id . amount_total - membership_amount - donation_amount
debit = ' '
debit = ' '
credit = str ( amount )
credit = str ( amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt = no_mvt + 1
no_mvt = no_mvt + 1
total_credit + = amount
total_credit + = amount
@ -690,8 +723,8 @@ class AccountingFileWizard(models.TransientModel):
if membership_credit_line :
if membership_credit_line :
debit = ' '
debit = ' '
credit = str ( membership_amount )
credit = str ( membership_amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + self . _file_format ( ' 756100 ' , 6 ) + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = self . _file_format ( ' 756100 ' , 6 )
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt = no_mvt + 1
no_mvt = no_mvt + 1
total_credit + = membership_amount
total_credit + = membership_amount
@ -701,7 +734,8 @@ class AccountingFileWizard(models.TransientModel):
debit = ' '
debit = ' '
amount = d . amount_total
amount = d . amount_total
credit = str ( amount )
credit = str ( amount )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt = no_mvt + 1
no_mvt = no_mvt + 1
total_credit + = amount
total_credit + = amount
@ -747,8 +781,8 @@ class AccountingFileWizard(models.TransientModel):
if amount == 0 : continue
if amount == 0 : continue
debit = str ( amount )
debit = str ( amount )
credit = ' '
credit = ' '
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_debit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_debit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt + = 1
no_mvt + = 1
total_debit + = amount
total_debit + = amount
@ -756,7 +790,8 @@ class AccountingFileWizard(models.TransientModel):
debit = ' '
debit = ' '
credit = str ( amount )
credit = str ( amount )
account_credit_number = ' 411000 '
account_credit_number = ' 411000 '
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt + = 1
no_mvt + = 1
total_credit + = amount
total_credit + = amount
@ -805,8 +840,8 @@ class AccountingFileWizard(models.TransientModel):
if amount == 0 : continue
if amount == 0 : continue
debit = str ( amount )
debit = str ( amount )
credit = ' '
credit = ' '
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_debit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_debit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt + = 1
no_mvt + = 1
total_debit + = amount
total_debit + = amount
@ -818,8 +853,8 @@ class AccountingFileWizard(models.TransientModel):
else :
else :
account_credit_number = self . _payment_account_number ( invoice )
account_credit_number = self . _payment_account_number ( invoice )
fic_line = str ( no_mvt ) + ' ; ' + ' IN ' + ' ; ' + date_line + ' ; ' + account_credit_number + ' ; ' + lib + ' ; ' + debit + ' ; ' + credit + ' ; ' + lib_piece + ' \n '
account_number = account_credit_number
fic_line = self . _accounting_line ( no_mvt , date_line , account_number , lib , debit , credit , lib_piece )
f . write ( fic_line )
f . write ( fic_line )
no_mvt + = 1
no_mvt + = 1
total_credit + = amount
total_credit + = amount