Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
C
cgscop_cotisation
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
Déploiement
Registre de paquets
Opération
Modules Terraform
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
Hervé Silvant - CGScop
cgscop_cotisation
Validations
8e7af0b9
Valider
8e7af0b9
rédigé
Il y a 3 ans
par
Benjamin - Le Filament
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
[update] compute is_loss & review query
parent
ed6739ed
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
report/scop_contribution_report.py
+33
-12
33 ajouts, 12 suppressions
report/scop_contribution_report.py
avec
33 ajouts
et
12 suppressions
report/scop_contribution_report.py
+
33
−
12
Voir le fichier @
8e7af0b9
...
@@ -21,7 +21,7 @@ class ScopContributionReport(models.Model):
...
@@ -21,7 +21,7 @@ class ScopContributionReport(models.Model):
amount_called
=
fields
.
Float
(
'
Montant Appelé
'
)
amount_called
=
fields
.
Float
(
'
Montant Appelé
'
)
amount_paid
=
fields
.
Float
(
'
Montant Payé
'
)
amount_paid
=
fields
.
Float
(
'
Montant Payé
'
)
amount_due
=
fields
.
Float
(
'
Montant Restant
'
)
amount_due
=
fields
.
Float
(
'
Montant Restant
'
)
is_loss
=
fields
.
Boolean
(
'
Exonération/Perte
'
)
is_loss
=
fields
.
Boolean
(
'
Exonération/Perte
'
,
compute
=
"
_compute_is_loss
"
)
payments
=
fields
.
Html
(
'
Paiements
'
,
compute
=
"
_compute_payments
"
)
payments
=
fields
.
Html
(
'
Paiements
'
,
compute
=
"
_compute_payments
"
)
_depends
=
{
_depends
=
{
...
@@ -43,8 +43,7 @@ class ScopContributionReport(models.Model):
...
@@ -43,8 +43,7 @@ class ScopContributionReport(models.Model):
i.partner_id,
i.partner_id,
SUM(i.amount_total_signed) AS amount_called,
SUM(i.amount_total_signed) AS amount_called,
SUM(i.amount_total_signed - i.residual_company_signed) AS amount_paid,
SUM(i.amount_total_signed - i.residual_company_signed) AS amount_paid,
SUM(i.residual_company_signed) AS amount_due,
SUM(i.residual_company_signed) AS amount_due
(CASE WHEN max(refund.id) IS NOT NULL THEN true ELSE FALSE END) AS is_loss
"""
"""
return
select_str
return
select_str
...
@@ -52,16 +51,13 @@ class ScopContributionReport(models.Model):
...
@@ -52,16 +51,13 @@ class ScopContributionReport(models.Model):
from_str
=
"""
from_str
=
"""
FROM
FROM
account_invoice i
account_invoice i
LEFT JOIN
account_invoice refund ON refund.refund_invoice_id = i.id
"""
"""
return
from_str
return
from_str
def
_where_invoice
(
self
):
def
_where_invoice
(
self
):
where_str
=
"""
where_str
=
"""
WHERE
WHERE
i.type =
'
out_invoice
'
AND
i.state in (
'
open
'
,
'
paid
'
,
'
in_payment
'
) AND
i.state in (
'
open
'
,
'
paid
'
) AND
i.is_contribution = true
i.is_contribution = true
"""
"""
return
where_str
return
where_str
...
@@ -96,8 +92,7 @@ class ScopContributionReport(models.Model):
...
@@ -96,8 +92,7 @@ class ScopContributionReport(models.Model):
c.partner_id,
c.partner_id,
SUM(c.amount_called) AS amount_called,
SUM(c.amount_called) AS amount_called,
SUM(c.amount_paid) AS amount_paid,
SUM(c.amount_paid) AS amount_paid,
SUM(c.amount_due) AS amount_due,
SUM(c.amount_due) AS amount_due
BOOL_OR(c.is_loss) AS is_loss
FROM (
FROM (
"""
"""
return
select_str
return
select_str
...
@@ -131,6 +126,11 @@ class ScopContributionReport(models.Model):
...
@@ -131,6 +126,11 @@ class ScopContributionReport(models.Model):
# ------------------------------------------------------
# ------------------------------------------------------
# Computed fields
# Computed fields
# ------------------------------------------------------
# ------------------------------------------------------
@api.multi
def
_compute_is_loss
(
self
):
for
contribution
in
self
:
contribution
.
is_loss
=
contribution
.
_get_is_loss
()
@api.multi
@api.multi
def
_compute_name
(
self
):
def
_compute_name
(
self
):
for
contribution
in
self
:
for
contribution
in
self
:
...
@@ -146,13 +146,26 @@ class ScopContributionReport(models.Model):
...
@@ -146,13 +146,26 @@ class ScopContributionReport(models.Model):
# ------------------------------------------------------
# ------------------------------------------------------
# Business functions
# Business functions
# ------------------------------------------------------
# ------------------------------------------------------
def
_get_is_loss
(
self
):
invoice_ids
=
self
.
env
[
'
account.invoice
'
].
search
([
(
'
year
'
,
'
=
'
,
int
(
self
.
year
)),
(
'
partner_id
'
,
'
=
'
,
self
.
partner_id
.
id
),
(
'
type_contribution_id
'
,
'
=
'
,
self
.
type_contribution_id
.
id
),
])
refund_ids
=
invoice_ids
.
filtered
(
lambda
i
:
i
.
type
==
'
out_refund
'
)
if
refund_ids
:
return
True
else
:
return
False
def
_get_payment
(
self
):
def
_get_payment
(
self
):
self
.
ensure_one
()
self
.
ensure_one
()
invoice_ids
=
self
.
env
[
'
account.invoice
'
].
search
([
invoice_ids
=
self
.
env
[
'
account.invoice
'
].
search
([
(
'
year
'
,
'
=
'
,
int
(
self
.
year
)),
(
'
year
'
,
'
=
'
,
int
(
self
.
year
)),
(
'
partner_id
'
,
'
=
'
,
self
.
partner_id
.
id
),
(
'
partner_id
'
,
'
=
'
,
self
.
partner_id
.
id
),
(
'
type_contribution_id
'
,
'
=
'
,
self
.
type_contribution_id
.
id
),
(
'
type_contribution_id
'
,
'
=
'
,
self
.
type_contribution_id
.
id
),
(
'
type
'
,
'
=
'
,
'
out_invoice
'
)
(
'
type
'
,
'
=
'
,
'
out_invoice
'
),
(
'
bordereau_id.state
'
,
'
not in
'
,
(
'
cancel
'
,))
])
])
payment_ids
=
invoice_ids
.
mapped
(
'
payment_move_line_ids
'
)
payment_ids
=
invoice_ids
.
mapped
(
'
payment_move_line_ids
'
)
if
payment_ids
:
if
payment_ids
:
...
@@ -161,6 +174,13 @@ class ScopContributionReport(models.Model):
...
@@ -161,6 +174,13 @@ class ScopContributionReport(models.Model):
'
name
'
:
p
.
name
,
'
name
'
:
p
.
name
,
'
ref
'
:
p
.
ref
,
'
ref
'
:
p
.
ref
,
'
credit
'
:
p
.
credit
,
'
credit
'
:
p
.
credit
,
'
class
'
:
''
}
if
not
p
.
invoice_id
else
{
'
date
'
:
p
.
date
,
'
name
'
:
p
.
name
,
'
ref
'
:
'
Avoir
'
,
'
credit
'
:
p
.
credit
,
'
class
'
:
'
text-danger
'
})
})
payments_html
=
self
.
_get_html_table
(
payments
)
payments_html
=
self
.
_get_html_table
(
payments
)
else
:
else
:
...
@@ -185,13 +205,14 @@ class ScopContributionReport(models.Model):
...
@@ -185,13 +205,14 @@ class ScopContributionReport(models.Model):
content_html
=
""
content_html
=
""
for
payment
in
payments
:
for
payment
in
payments
:
content_html
+=
"""
content_html
+=
"""
<tr>
<tr
class=
'
%s
'
>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td class=
'
text-right
'
>%.2f €</td>
<td class=
'
text-right
'
>%.2f €</td>
</tr>
</tr>
"""
%
(
payment
.
get
(
'
date
'
,
''
).
strftime
(
'
%d/%m/%Y
'
),
"""
%
(
payment
.
get
(
'
class
'
,
''
),
payment
.
get
(
'
date
'
,
''
).
strftime
(
'
%d/%m/%Y
'
),
payment
.
get
(
'
name
'
,
''
),
payment
.
get
(
'
ref
'
,
''
),
payment
.
get
(
'
name
'
,
''
),
payment
.
get
(
'
ref
'
,
''
),
payment
.
get
(
'
credit
'
,
0.0
),)
payment
.
get
(
'
credit
'
,
0.0
),)
...
...
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