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
5
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
cf45b08c
Commit
cf45b08c
authored
5 years ago
by
ynerant
Browse files
Options
Downloads
Patches
Plain Diff
Automatically link SpecialTransactions and their proxies
parent
884a7d0f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!61
Tresorerie
Pipeline
#8009
failed with stages
in 2 minutes and 16 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/treasury/apps.py
+15
-0
15 additions, 0 deletions
apps/treasury/apps.py
apps/treasury/models.py
+18
-0
18 additions, 0 deletions
apps/treasury/models.py
apps/treasury/signals.py
+12
-0
12 additions, 0 deletions
apps/treasury/signals.py
with
45 additions
and
0 deletions
apps/treasury/apps.py
+
15
−
0
View file @
cf45b08c
...
...
@@ -2,9 +2,24 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from
django.apps
import
AppConfig
from
django.db.models.signals
import
post_save
from
django.utils.translation
import
gettext_lazy
as
_
class
TreasuryConfig
(
AppConfig
):
name
=
'
treasury
'
verbose_name
=
_
(
'
Treasury
'
)
def
ready
(
self
):
"""
Define app internal signals to interact with other apps
"""
from
.
import
signals
from
note.models
import
SpecialTransaction
from
treasury.models
import
SpecialTransactionProxy
post_save
.
connect
(
signals
.
save_special_transaction
,
sender
=
SpecialTransaction
)
# If the treasury app was disabled, we ensure that each special transaction is linked to a proxy
for
transaction
in
SpecialTransaction
.
objects
.
filter
(
specialtransactionproxy
=
None
):
SpecialTransactionProxy
.
objects
.
create
(
transaction
=
transaction
,
remittance
=
None
)
This diff is collapsed.
Click to expand it.
apps/treasury/models.py
+
18
−
0
View file @
cf45b08c
...
...
@@ -9,6 +9,10 @@ from note.models import NoteSpecial, SpecialTransaction
class
Invoice
(
models
.
Model
):
"""
An invoice model that can generate a true invoice
"""
id
=
models
.
PositiveIntegerField
(
primary_key
=
True
,
verbose_name
=
_
(
"
Invoice identifier
"
),
...
...
@@ -57,6 +61,10 @@ class Invoice(models.Model):
class
Product
(
models
.
Model
):
"""
Product that appear on an invoice.
"""
invoice
=
models
.
ForeignKey
(
Invoice
,
on_delete
=
models
.
PROTECT
,
...
...
@@ -89,6 +97,10 @@ class Product(models.Model):
class
Remittance
(
models
.
Model
):
"""
Treasurers want to regroup checks or bank transfers in bank remittances.
"""
date
=
models
.
DateTimeField
(
auto_now_add
=
True
,
verbose_name
=
_
(
"
Date
"
),
...
...
@@ -132,6 +144,12 @@ class Remittance(models.Model):
class
SpecialTransactionProxy
(
models
.
Model
):
"""
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.
If it isn
'
t very clean, that makes what we want.
"""
transaction
=
models
.
OneToOneField
(
SpecialTransaction
,
on_delete
=
models
.
CASCADE
,
...
...
This diff is collapsed.
Click to expand it.
apps/treasury/signals.py
0 → 100644
+
12
−
0
View file @
cf45b08c
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from
treasury.models
import
SpecialTransactionProxy
def
save_special_transaction
(
instance
,
created
,
**
kwargs
):
"""
When a special transaction is created, we create its linked proxy
"""
if
created
:
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