Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nk20
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Wiki
Code
Merge requests
6
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDE
nk20
Commits
f468c2f9
Commit
f468c2f9
authored
4 years ago
by
Pierre-antoine Comby
Browse files
Options
Downloads
Plain Diff
Merge branch 'import_nk15' into 'master'
Import nk15 See merge request
!81
parents
7597ad85
fdf373d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!81
Import nk15
Pipeline
#8206
passed with warnings with stages
in 4 minutes and 22 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/note/models/transactions.py
+11
-0
11 additions, 0 deletions
apps/note/models/transactions.py
apps/treasury/models.py
+1
-1
1 addition, 1 deletion
apps/treasury/models.py
apps/treasury/signals.py
+7
-4
7 additions, 4 deletions
apps/treasury/signals.py
with
19 additions
and
5 deletions
apps/note/models/transactions.py
+
11
−
0
View file @
f468c2f9
...
@@ -264,6 +264,17 @@ class SpecialTransaction(Transaction):
...
@@ -264,6 +264,17 @@ class SpecialTransaction(Transaction):
def
type
(
self
):
def
type
(
self
):
return
_
(
'
Credit
'
)
if
isinstance
(
self
.
source
,
NoteSpecial
)
else
_
(
"
Debit
"
)
return
_
(
'
Credit
'
)
if
isinstance
(
self
.
source
,
NoteSpecial
)
else
_
(
"
Debit
"
)
def
is_credit
(
self
):
return
isinstance
(
self
.
source
,
NoteSpecial
)
def
is_debit
(
self
):
return
isinstance
(
self
.
destination
,
NoteSpecial
)
def
clean
(
self
):
# SpecialTransaction are only possible with NoteSpecial object
if
self
.
is_credit
()
==
self
.
is_debit
():
raise
(
ValidationError
(
_
(
"
A special transaction is only possible between a Note associated to a payment method and a User or a Club
"
)))
class
MembershipTransaction
(
Transaction
):
class
MembershipTransaction
(
Transaction
):
"""
"""
...
...
This diff is collapsed.
Click to expand it.
apps/treasury/models.py
+
1
−
1
View file @
f468c2f9
...
@@ -191,7 +191,7 @@ class SpecialTransactionProxy(models.Model):
...
@@ -191,7 +191,7 @@ class SpecialTransactionProxy(models.Model):
"""
"""
In order to keep modularity, we don
'
t that the Note app depends on the treasury app.
In order to keep modularity, we don
'
t that the Note app depends on the treasury app.
That
'
s why we create a proxy in this app, to link special transactions and remittances.
That
'
s why we create a proxy in this app, to link special transactions and remittances.
If it isn
'
t very clean,
that mak
es what we want.
If it isn
'
t very clean,
it do
es what we want.
"""
"""
transaction
=
models
.
OneToOneField
(
transaction
=
models
.
OneToOneField
(
...
...
This diff is collapsed.
Click to expand it.
apps/treasury/signals.py
+
7
−
4
View file @
f468c2f9
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-License-Identifier: GPL-3.0-or-later
from
note.models
import
NoteSpecial
from
treasury.models
import
SpecialTransactionProxy
,
RemittanceType
from
treasury.models
import
SpecialTransactionProxy
,
RemittanceType
...
@@ -9,6 +8,10 @@ def save_special_transaction(instance, created, **kwargs):
...
@@ -9,6 +8,10 @@ def save_special_transaction(instance, created, **kwargs):
"""
"""
When a special transaction is created, we create its linked proxy
When a special transaction is created, we create its linked proxy
"""
"""
if
created
and
isinstance
(
instance
.
source
,
NoteSpecial
)
\
and
RemittanceType
.
objects
.
filter
(
note
=
instance
.
source
).
exists
():
if
instance
.
is_credit
():
SpecialTransactionProxy
.
objects
.
create
(
transaction
=
instance
,
remittance
=
None
).
save
()
if
created
and
RemittanceType
.
objects
.
filter
(
note
=
instance
.
source
).
exists
():
SpecialTransactionProxy
.
objects
.
create
(
transaction
=
instance
,
remittance
=
None
).
save
()
else
:
if
created
and
RemittanceType
.
objects
.
filter
(
note
=
instance
.
destination
).
exists
():
SpecialTransactionProxy
.
objects
.
create
(
transaction
=
instance
,
remittance
=
None
).
save
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment