Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
C
cgscop_cotisation_cg
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse du dépôt
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Le Filament
Confédération Générale des SCOP
cgscop_cotisation_cg
Validations
160f9444
Valider
160f9444
rédigé
15 mars 2021
par
jordan
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[update] more sustainable code
parent
89011c59
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
models/scop_bordereau_cg.py
+1
-14
1 ajout, 14 suppressions
models/scop_bordereau_cg.py
models/scop_cotisation_cg.py
+44
-69
44 ajouts, 69 suppressions
models/scop_cotisation_cg.py
avec
45 ajouts
et
83 suppressions
models/scop_bordereau_cg.py
+
1
−
14
Voir le fichier @
160f9444
...
@@ -347,21 +347,8 @@ class Bordereau(models.Model):
...
@@ -347,21 +347,8 @@ class Bordereau(models.Model):
for
bordereau
in
self
:
for
bordereau
in
self
:
if
bordereau
.
state
==
'
new
'
:
if
bordereau
.
state
==
'
new
'
:
bordereau
.
base_cotisation_cg
.
create_cotiz_and_lines
(
bordereau
.
base_cotisation_cg
.
create_cotiz_and_lines
(
partner
=
bordereau
.
partner_id
,
partner
=
bordereau
.
partner_id
,
bordereau
=
bordereau
,
type_assiette
=
bordereau
.
type_assiette_retenu
,
bordereau
=
bordereau
,
liasse
=
bordereau
.
liasse_fiscale_id
,
liasse
=
bordereau
.
liasse_fiscale_id
,
ca
=
bordereau
.
ca_retenu
,
va_cg
=
bordereau
.
va_cg_retenu
,
va_fede_com
=
bordereau
.
va_fede_com_retenu
,
nb_quarter
=
bordereau
.
nb_quarter
,
staff_fede_com_count
=
bordereau
.
staff_fede_com_count_retenu
,
staff_ur_med_count
=
bordereau
.
staff_ur_med_count_retenu
,
staff_shareholder_count
=
bordereau
.
staff_shareholder_count_retenu
,
staff_average
=
bordereau
.
staff_average_retenu
,
net_results
=
bordereau
.
net_results_retenu
,
wage_cg
=
bordereau
.
wage_cg_retenu
)
)
# ------------------------------------------------------
# ------------------------------------------------------
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
models/scop_cotisation_cg.py
+
44
−
69
Voir le fichier @
160f9444
...
@@ -345,22 +345,12 @@ class ScopCotisation(models.Model):
...
@@ -345,22 +345,12 @@ class ScopCotisation(models.Model):
'
target
'
:
'
current
'
,
'
target
'
:
'
current
'
,
}
}
def
create_bordereau
(
self
,
member
,
nb_quarter
,
liasse
=
None
,
def
create_bordereau
(
self
,
member
,
nb_quarter
,
liasse
=
None
,
date
=
False
):
ca
=
0
,
va
=
0
,
staff_count
=
0
,
staff_shareholder_count
=
0
,
staff_average
=
0
,
net_results
=
0
,
wage_cg
=
0
,
date
=
False
):
"""
"""
Création du bordereau de cotisations
Création du bordereau de cotisations
:param member:
:param member:
:param nb_quarter:
:param nb_quarter:
:param liasse:
:param liasse:
:param ca:
:param va:
:param staff_count:
:param staff_shareholder_count:
:param staff_average:
:param net_results:
:param wage_cg:
:param date:
:param date:
:return bordereau_id:
:return bordereau_id:
"""
"""
...
@@ -369,7 +359,24 @@ class ScopCotisation(models.Model):
...
@@ -369,7 +359,24 @@ class ScopCotisation(models.Model):
(
'
year
'
,
'
=
'
,
self
.
year
),
(
'
year
'
,
'
=
'
,
self
.
year
),
])
])
if
not
existing_bordereau
:
if
not
existing_bordereau
:
# Variables to calculate cotiz
ca
=
liasse
.
revenue_cgsubv
va
=
self
.
get_va
(
liasse
)
staff_id
=
self
.
get_last_staff_id
(
member
)
if
staff_id
:
staff_shareholder_count
=
\
staff_id
.
staff_shareholder_count
staff_count
=
\
staff_id
.
staff_count
else
:
staff_shareholder_count
=
0
staff_count
=
0
staff_average
=
staff_id
.
staff_average
net_results
=
liasse
.
L2053_HN
\
if
liasse
.
L2053_HN
>
0
else
liasse
.
L2051_DI
wage_cg
=
liasse
.
wage_cg
date_invoice
=
date
if
date
else
self
.
date_cotisation
date_invoice
=
date
if
date
else
self
.
date_cotisation
bordereau
=
self
.
env
[
'
scop.bordereau
'
].
create
({
bordereau
=
self
.
env
[
'
scop.bordereau
'
].
create
({
'
partner_id
'
:
member
.
id
,
'
partner_id
'
:
member
.
id
,
'
payment_mode_id
'
:
member
.
customer_payment_mode_id
.
id
,
'
payment_mode_id
'
:
member
.
customer_payment_mode_id
.
id
,
...
@@ -422,12 +429,8 @@ class ScopCotisation(models.Model):
...
@@ -422,12 +429,8 @@ class ScopCotisation(models.Model):
else
:
else
:
return
Liasse
return
Liasse
def
create_cotiz_and_lines
(
self
,
partner
,
type_assiette
,
def
create_cotiz_and_lines
(
self
,
partner
,
bordereau
,
bordereau
,
liasse
=
None
,
liasse
=
None
,
date
=
False
):
ca
=
0
,
va_cg
=
0
,
va_fede_com
=
0
,
nb_quarter
=
4
,
staff_fede_com_count
=
0
,
staff_ur_med_count
=
0
,
staff_shareholder_count
=
0
,
staff_average
=
0
,
net_results
=
0
,
wage_cg
=
0
,
date
=
False
):
# Invoice cotiz CG
# Invoice cotiz CG
#
#
...
@@ -435,7 +438,8 @@ class ScopCotisation(models.Model):
...
@@ -435,7 +438,8 @@ class ScopCotisation(models.Model):
type_cotisation_cg
=
self
.
env
.
ref
(
'
cgscop_partner.riga_14397
'
).
id
type_cotisation_cg
=
self
.
env
.
ref
(
'
cgscop_partner.riga_14397
'
).
id
amount_cg
=
self
.
round_to_closest_multiple
(
amount_cg
=
self
.
round_to_closest_multiple
(
self
.
get_cotiz_cg
(
partner
,
type_assiette
,
ca
,
va_cg
)
self
.
get_cotiz_cg
(
partner
,
bordereau
.
type_assiette_retenu
,
bordereau
.
ca_retenu
,
bordereau
.
va_cg_retenu
)
,
4
)
,
4
)
invoice_cotiz_cg
=
self
.
create_contribution
(
invoice_cotiz_cg
=
self
.
create_contribution
(
product_cg_id
,
partner
,
type_cotisation_cg
,
product_cg_id
,
partner
,
type_cotisation_cg
,
...
@@ -444,9 +448,9 @@ class ScopCotisation(models.Model):
...
@@ -444,9 +448,9 @@ class ScopCotisation(models.Model):
'
cotisation_cg_id
'
:
self
.
id
,
'
cotisation_cg_id
'
:
self
.
id
,
'
bordereau_id
'
:
bordereau
.
id
,
'
bordereau_id
'
:
bordereau
.
id
,
'
amount_cg_calculated
'
:
amount_cg
,
'
amount_cg_calculated
'
:
amount_cg
,
'
nb_quarter
'
:
nb_quarter
'
nb_quarter
'
:
bordereau
.
nb_quarter
})
})
if
nb_quarter
!=
4
:
if
bordereau
.
nb_quarter
!=
4
:
invoice_cotiz_cg
.
recalcul_cotiz_cg
()
invoice_cotiz_cg
.
recalcul_cotiz_cg
()
invoice_cotiz_cg
.
env
.
cr
.
commit
()
invoice_cotiz_cg
.
env
.
cr
.
commit
()
...
@@ -463,8 +467,9 @@ class ScopCotisation(models.Model):
...
@@ -463,8 +467,9 @@ class ScopCotisation(models.Model):
'
cgscop_partner.riga_14398
'
).
id
'
cgscop_partner.riga_14398
'
).
id
amount_fede_com
=
self
.
round_to_closest_multiple
(
amount_fede_com
=
self
.
round_to_closest_multiple
(
self
.
get_cotiz_fede_com
(
va_fede_com
,
staff_average
,
self
.
get_cotiz_fede_com
(
bordereau
.
va_fede_com_retenu
,
staff_fede_com_count
)
bordereau
.
staff_average_retenu
,
bordereau
.
staff_fede_com_count_retenu
)
,
4
)
,
4
)
invoice_cotiz_fede_com
=
self
.
create_contribution
(
invoice_cotiz_fede_com
=
self
.
create_contribution
(
product_fede_com_id
,
partner
,
type_cotisation_fede_com
,
product_fede_com_id
,
partner
,
type_cotisation_fede_com
,
...
@@ -473,9 +478,9 @@ class ScopCotisation(models.Model):
...
@@ -473,9 +478,9 @@ class ScopCotisation(models.Model):
'
cotisation_cg_id
'
:
self
.
id
,
'
cotisation_cg_id
'
:
self
.
id
,
'
bordereau_id
'
:
bordereau
.
id
,
'
bordereau_id
'
:
bordereau
.
id
,
'
amount_cg_calculated
'
:
amount_fede_com
,
'
amount_cg_calculated
'
:
amount_fede_com
,
'
nb_quarter
'
:
nb_quarter
'
nb_quarter
'
:
bordereau
.
nb_quarter
})
})
if
nb_quarter
!=
4
:
if
bordereau
.
nb_quarter
!=
4
:
invoice_cotiz_fede_com
.
recalcul_cotiz_cg
()
invoice_cotiz_fede_com
.
recalcul_cotiz_cg
()
invoice_cotiz_fede_com
.
env
.
cr
.
commit
()
invoice_cotiz_fede_com
.
env
.
cr
.
commit
()
...
@@ -496,9 +501,9 @@ class ScopCotisation(models.Model):
...
@@ -496,9 +501,9 @@ class ScopCotisation(models.Model):
'
cotisation_cg_id
'
:
self
.
id
,
'
cotisation_cg_id
'
:
self
.
id
,
'
bordereau_id
'
:
bordereau
.
id
,
'
bordereau_id
'
:
bordereau
.
id
,
'
amount_cg_calculated
'
:
amount_fede_cae
,
'
amount_cg_calculated
'
:
amount_fede_cae
,
'
nb_quarter
'
:
nb_quarter
'
nb_quarter
'
:
bordereau
.
nb_quarter
})
})
if
nb_quarter
!=
4
:
if
bordereau
.
nb_quarter
!=
4
:
invoice_cotiz_fede_cae
.
recalcul_cotiz_cg
()
invoice_cotiz_fede_cae
.
recalcul_cotiz_cg
()
invoice_cotiz_fede_cae
.
env
.
cr
.
commit
()
invoice_cotiz_fede_cae
.
env
.
cr
.
commit
()
...
@@ -510,7 +515,7 @@ class ScopCotisation(models.Model):
...
@@ -510,7 +515,7 @@ class ScopCotisation(models.Model):
account_id
=
self
.
company_id
.
receivable_account_ur_hdf_id
account_id
=
self
.
company_id
.
receivable_account_ur_hdf_id
amount_hdf
=
self
.
round_to_closest_multiple
(
amount_hdf
=
self
.
round_to_closest_multiple
(
self
.
get_cotiz_hdf
(
wage_cg
)
self
.
get_cotiz_hdf
(
bordereau
.
wage_cg_retenu
)
,
4
)
,
4
)
invoice_cotiz_hdf
=
self
.
create_contribution
(
invoice_cotiz_hdf
=
self
.
create_contribution
(
product_hdf_id
,
partner
,
type_cotisation_ur
,
product_hdf_id
,
partner
,
type_cotisation_ur
,
...
@@ -519,9 +524,9 @@ class ScopCotisation(models.Model):
...
@@ -519,9 +524,9 @@ class ScopCotisation(models.Model):
'
cotisation_cg_id
'
:
self
.
id
,
'
cotisation_cg_id
'
:
self
.
id
,
'
bordereau_id
'
:
bordereau
.
id
,
'
bordereau_id
'
:
bordereau
.
id
,
'
amount_cg_calculated
'
:
amount_hdf
,
'
amount_cg_calculated
'
:
amount_hdf
,
'
nb_quarter
'
:
nb_quarter
'
nb_quarter
'
:
bordereau
.
nb_quarter
})
})
if
nb_quarter
!=
4
:
if
bordereau
.
nb_quarter
!=
4
:
invoice_cotiz_hdf
.
recalcul_cotiz_cg
()
invoice_cotiz_hdf
.
recalcul_cotiz_cg
()
invoice_cotiz_hdf
.
env
.
cr
.
commit
()
invoice_cotiz_hdf
.
env
.
cr
.
commit
()
...
@@ -533,9 +538,9 @@ class ScopCotisation(models.Model):
...
@@ -533,9 +538,9 @@ class ScopCotisation(models.Model):
account_id
=
self
.
company_id
.
receivable_account_ur_med_id
account_id
=
self
.
company_id
.
receivable_account_ur_med_id
amount_med
=
self
.
round_to_closest_multiple
(
amount_med
=
self
.
round_to_closest_multiple
(
self
.
get_cotiz_med
(
amount_cg
,
net_results
,
self
.
get_cotiz_med
(
amount_cg
,
bordereau
.
net_results
_retenu
,
staff_shareholder_count
,
bordereau
.
staff_shareholder_count
_retenu
,
staff_ur_med_count
)
bordereau
.
staff_ur_med_count
_retenu
)
,
4
)
,
4
)
invoice_cotiz_med
=
self
.
create_contribution
(
invoice_cotiz_med
=
self
.
create_contribution
(
product_med_id
,
partner
,
type_cotisation_ur
,
product_med_id
,
partner
,
type_cotisation_ur
,
...
@@ -544,9 +549,9 @@ class ScopCotisation(models.Model):
...
@@ -544,9 +549,9 @@ class ScopCotisation(models.Model):
'
cotisation_cg_id
'
:
self
.
id
,
'
cotisation_cg_id
'
:
self
.
id
,
'
bordereau_id
'
:
bordereau
.
id
,
'
bordereau_id
'
:
bordereau
.
id
,
'
amount_cg_calculated
'
:
amount_med
,
'
amount_cg_calculated
'
:
amount_med
,
'
nb_quarter
'
:
nb_quarter
'
nb_quarter
'
:
bordereau
.
nb_quarter
})
})
if
nb_quarter
!=
4
:
if
bordereau
.
nb_quarter
!=
4
:
invoice_cotiz_med
.
recalcul_cotiz_cg
()
invoice_cotiz_med
.
recalcul_cotiz_cg
()
invoice_cotiz_med
.
env
.
cr
.
commit
()
invoice_cotiz_med
.
env
.
cr
.
commit
()
...
@@ -789,8 +794,8 @@ class ScopCotisation(models.Model):
...
@@ -789,8 +794,8 @@ class ScopCotisation(models.Model):
# ------------------------------------------------------
# ------------------------------------------------------
# Threading task
# Threading task
# ------------------------------------------------------
# ------------------------------------------------------
def
process_cotiz_generate
(
self
,
partner_ids
,
def
process_cotiz_generate
(
self
,
partner_ids
,
cotiz_cg_task
,
cotiz_cg_task
,
nb_quarter
=
4
,
date
=
False
):
nb_quarter
=
4
,
date
=
False
):
"""
"""
Process de génération des cotiz CG en background
Process de génération des cotiz CG en background
"""
"""
...
@@ -813,47 +818,17 @@ class ScopCotisation(models.Model):
...
@@ -813,47 +818,17 @@ class ScopCotisation(models.Model):
member
=
member_id
.
with_env
(
new_env
)
member
=
member_id
.
with_env
(
new_env
)
liasse_id
=
new_self
.
get_liasse
(
member
)
liasse_id
=
new_self
.
get_liasse
(
member
)
# Variables to calculate cotiz
ca
=
liasse_id
.
revenue_cgsubv
va
=
new_self
.
get_va
(
liasse_id
)
type_assiette
=
new_self
.
get_type_assiette
(
ca
,
va
)
staff_id
=
new_self
.
get_last_staff_id
(
member
)
if
staff_id
:
staff_shareholder_count
=
\
staff_id
.
staff_shareholder_count
staff_count
=
\
staff_id
.
staff_count
else
:
staff_shareholder_count
=
0
staff_count
=
0
staff_average
=
staff_id
.
staff_average
net_results
=
liasse_id
.
L2053_HN
\
if
liasse_id
.
L2053_HN
>
0
else
liasse_id
.
L2051_DI
wage_cg
=
liasse_id
.
wage_cg
try
:
try
:
# Bordereau
# Bordereau
bordereau
=
new_self
.
create_bordereau
(
bordereau
=
new_self
.
create_bordereau
(
member
=
member
,
liasse
=
liasse_id
,
member
=
member
,
liasse
=
liasse_id
,
nb_quarter
=
nb_quarter
,
ca
=
ca
,
va
=
va
,
nb_quarter
=
nb_quarter
,
date
=
date
)
staff_count
=
staff_count
,
staff_shareholder_count
=
staff_shareholder_count
,
staff_average
=
staff_average
,
net_results
=
net_results
,
wage_cg
=
wage_cg
)
bordereau
.
env
.
cr
.
commit
()
bordereau
.
env
.
cr
.
commit
()
# Cotisations
# Cotisations
new_self
.
create_cotiz_and_lines
(
new_self
.
create_cotiz_and_lines
(
partner
=
member
,
liasse
=
liasse_id
,
partner
=
member
,
bordereau
=
bordereau
,
bordereau
=
bordereau
,
nb_quarter
=
nb_quarter
,
liasse
=
liasse_id
,
date
=
date
ca
=
ca
,
va_cg
=
va
,
va_fede_com
=
va
,
type_assiette
=
type_assiette
,
staff_fede_com_count
=
staff_count
,
staff_ur_med_count
=
staff_count
,
staff_shareholder_count
=
staff_shareholder_count
,
staff_average
=
staff_average
,
net_results
=
net_results
,
wage_cg
=
wage_cg
,
date
=
date
)
)
cotiz_created
+=
1
cotiz_created
+=
1
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter