Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-FiBu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
0ettinZtiapi
AlekSIS-App-FiBu
Commits
45a1b17c
Commit
45a1b17c
authored
4 years ago
by
Frank Poetzsch-Heffter
Browse files
Options
Downloads
Patches
Plain Diff
Let classes derive from ExtensibleModel, set default values for some attributes
parent
ab119e67
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/fibu/migrations/0001_initial.py
+30
-8
30 additions, 8 deletions
aleksis/apps/fibu/migrations/0001_initial.py
aleksis/apps/fibu/models.py
+9
-7
9 additions, 7 deletions
aleksis/apps/fibu/models.py
with
39 additions
and
15 deletions
aleksis/apps/fibu/migrations/0001_initial.py
+
30
−
8
View file @
45a1b17c
# Generated by Django 3.0.
5
on 2020-0
4-13 12:56
# Generated by Django 3.0.
8
on 2020-0
8-04 14:31
import
datetime
import
django.db.models.deletion
from
django.conf
import
settings
import
django.contrib.postgres.fields.jsonb
import
django.contrib.sites.managers
from
django.db
import
migrations
,
models
import
django.db.models.deletion
import
django.utils.timezone
class
Migration
(
migrations
.
Migration
):
...
...
@@ -12,6 +14,7 @@ class Migration(migrations.Migration):
initial
=
True
dependencies
=
[
(
'
sites
'
,
'
0002_alter_domain_unique
'
),
migrations
.
swappable_dependency
(
settings
.
AUTH_USER_MODEL
),
]
...
...
@@ -20,6 +23,7 @@ class Migration(migrations.Migration):
name
=
'
Account
'
,
fields
=
[
(
'
id
'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'
ID
'
)),
(
'
extended_data
'
,
django
.
contrib
.
postgres
.
fields
.
jsonb
.
JSONField
(
default
=
dict
,
editable
=
False
)),
(
'
name
'
,
models
.
CharField
(
max_length
=
20
,
verbose_name
=
'
Booking account
'
)),
(
'
income
'
,
models
.
BooleanField
(
default
=
False
,
verbose_name
=
'
Income account
'
)),
(
'
budget
'
,
models
.
IntegerField
(
default
=
0
,
verbose_name
=
'
Budget
'
)),
...
...
@@ -31,49 +35,67 @@ class Migration(migrations.Migration):
'
verbose_name_plural
'
:
'
Booking accounts
'
,
'
permissions
'
:
[(
'
manage_account
'
,
'
Can manage account
'
)],
},
managers
=
[
(
'
objects
'
,
django
.
contrib
.
sites
.
managers
.
CurrentSiteManager
()),
],
),
migrations
.
CreateModel
(
name
=
'
CostCenter
'
,
fields
=
[
(
'
id
'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'
ID
'
)),
(
'
extended_data
'
,
django
.
contrib
.
postgres
.
fields
.
jsonb
.
JSONField
(
default
=
dict
,
editable
=
False
)),
(
'
name
'
,
models
.
CharField
(
max_length
=
30
,
verbose_name
=
'
Cost center
'
)),
(
'
year
'
,
models
.
IntegerField
(
choices
=
[(
2020
,
'
2020
'
),
(
2021
,
'
2021
'
),
(
2022
,
'
2022
'
),
(
2023
,
'
2023
'
)],
default
=
2020
,
verbose_name
=
'
Year
'
)),
(
'
site
'
,
models
.
ForeignKey
(
default
=
1
,
editable
=
False
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
sites.Site
'
)),
],
options
=
{
'
verbose_name
'
:
'
Cost center
'
,
'
verbose_name_plural
'
:
'
Cost centers
'
,
'
permissions
'
:
[(
'
manage_costcenter
'
,
'
Can manage costcenter
'
)],
},
managers
=
[
(
'
objects
'
,
django
.
contrib
.
sites
.
managers
.
CurrentSiteManager
()),
],
),
migrations
.
CreateModel
(
name
=
'
Booking
'
,
fields
=
[
(
'
id
'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'
ID
'
)),
(
'
extended_data
'
,
django
.
contrib
.
postgres
.
fields
.
jsonb
.
JSONField
(
default
=
dict
,
editable
=
False
)),
(
'
description
'
,
models
.
CharField
(
max_length
=
50
,
verbose_name
=
'
Description
'
)),
(
'
justification
'
,
models
.
CharField
(
blank
=
True
,
max_length
=
2000
,
null
=
True
,
verbose_name
=
'
Reason
'
)),
(
'
justification
'
,
models
.
CharField
(
blank
=
True
,
default
=
''
,
max_length
=
2000
,
verbose_name
=
'
Reason
'
)),
(
'
planned_amount
'
,
models
.
IntegerField
(
verbose_name
=
'
Planned amount
'
)),
(
'
invoice_date
'
,
models
.
DateField
(
blank
=
True
,
null
=
True
,
verbose_name
=
'
Date of invoice
'
)),
(
'
invoice_number
'
,
models
.
CharField
(
blank
=
True
,
max_length
=
20
,
null
=
True
,
verbose_name
=
'
Bill number
'
)),
(
'
firma
'
,
models
.
CharField
(
blank
=
True
,
max_length
=
30
,
null
=
True
,
verbose_name
=
'
Company
'
)),
(
'
invoice_date
'
,
models
.
DateField
(
blank
=
True
,
default
=
django
.
utils
.
timezone
.
now
,
verbose_name
=
'
Date of invoice
'
)),
(
'
invoice_number
'
,
models
.
CharField
(
blank
=
True
,
default
=
'
0
'
,
max_length
=
20
,
verbose_name
=
'
Bill number
'
)),
(
'
firma
'
,
models
.
CharField
(
blank
=
True
,
default
=
''
,
max_length
=
30
,
verbose_name
=
'
Company
'
)),
(
'
amount
'
,
models
.
DecimalField
(
decimal_places
=
2
,
default
=
0.0
,
max_digits
=
9
,
verbose_name
=
'
Amount
'
)),
(
'
payout_number
'
,
models
.
IntegerField
(
blank
=
True
,
null
=
True
,
verbose_name
=
'
Payout number
'
)),
(
'
submission_date
'
,
models
.
DateField
(
blank
=
True
,
null
=
True
,
verbose_name
=
'
Submission date
'
)),
(
'
booking_date
'
,
models
.
DateField
(
default
=
datetime
.
date
.
today
,
verbose_name
=
'
Booking date
'
)),
(
'
maturity
'
,
models
.
DateField
(
blank
=
True
,
null
=
True
,
verbose_name
=
'
Maturity
'
)),
(
'
upload
'
,
models
.
FileField
(
blank
=
True
,
default
=
None
,
null
=
True
,
upload_to
=
'
uploads/fibu/%Y/
'
,
verbose_name
=
'
Scan of invoice
'
)),
(
'
upload
'
,
models
.
FileField
(
blank
=
True
,
default
=
None
,
upload_to
=
'
uploads/fibu/%Y/
'
,
verbose_name
=
'
Scan of invoice
'
)),
(
'
status
'
,
models
.
IntegerField
(
choices
=
[(
0
,
'
requested
'
),
(
1
,
'
rejected
'
),
(
2
,
'
accepted
'
),
(
3
,
'
ordered
'
),
(
4
,
'
submitted
'
),
(
5
,
'
paid
'
)],
default
=
0
,
verbose_name
=
'
Status
'
)),
(
'
account
'
,
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
to
=
'
fibu.Account
'
,
verbose_name
=
'
Booking account
'
)),
(
'
contact
'
,
models
.
ForeignKey
(
blank
=
True
,
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
SET_NULL
,
related_name
=
'
bookings
'
,
to
=
settings
.
AUTH_USER_MODEL
,
verbose_name
=
'
Created by
'
)),
(
'
site
'
,
models
.
ForeignKey
(
default
=
1
,
editable
=
False
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
sites.Site
'
)),
],
options
=
{
'
verbose_name
'
:
'
Booking
'
,
'
verbose_name_plural
'
:
'
Bookings
'
,
'
permissions
'
:
[(
'
manage_booking
'
,
'
Can manage bookings
'
),
(
'
request_booking
'
,
'
Can request a booking
'
),
(
'
check_booking
'
,
'
Can check bookings
'
)],
},
managers
=
[
(
'
objects
'
,
django
.
contrib
.
sites
.
managers
.
CurrentSiteManager
()),
],
),
migrations
.
AddField
(
model_name
=
'
account
'
,
name
=
'
cost_center
'
,
field
=
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
fibu.CostCenter
'
,
verbose_name
=
'
Cost center
'
),
),
migrations
.
AddField
(
model_name
=
'
account
'
,
name
=
'
site
'
,
field
=
models
.
ForeignKey
(
default
=
1
,
editable
=
False
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'
sites.Site
'
),
),
]
This diff is collapsed.
Click to expand it.
aleksis/apps/fibu/models.py
+
9
−
7
View file @
45a1b17c
...
...
@@ -5,6 +5,8 @@ from django.db import models
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
from
aleksis.core.mixins
import
ExtensibleModel
current_year
=
timezone
.
now
().
year
YEARS
=
[(
x
,
str
(
x
))
for
x
in
range
(
current_year
,
current_year
+
4
)]
...
...
@@ -30,7 +32,7 @@ status_list = [
status_choices
=
[(
x
,
val
.
name
)
for
x
,
val
in
enumerate
(
status_list
)]
class
CostCenter
(
models
.
Model
):
class
CostCenter
(
Extensible
Model
):
name
=
models
.
CharField
(
max_length
=
30
,
blank
=
False
,
verbose_name
=
_
(
"
Cost center
"
))
year
=
models
.
IntegerField
(
default
=
timezone
.
now
().
year
,
choices
=
YEARS
,
blank
=
False
,
verbose_name
=
_
(
"
Year
"
)
...
...
@@ -47,7 +49,7 @@ class CostCenter(models.Model):
return
self
.
name
class
Account
(
models
.
Model
):
class
Account
(
Extensible
Model
):
name
=
models
.
CharField
(
max_length
=
20
,
blank
=
False
,
verbose_name
=
_
(
"
Booking account
"
))
cost_center
=
models
.
ForeignKey
(
to
=
CostCenter
,
on_delete
=
models
.
CASCADE
,
blank
=
False
,
verbose_name
=
_
(
"
Cost center
"
)
...
...
@@ -68,7 +70,7 @@ class Account(models.Model):
return
"
{}: {}
"
.
format
(
self
.
cost_center
,
self
.
name
)
class
Booking
(
models
.
Model
):
class
Booking
(
Extensible
Model
):
# General information
account
=
models
.
ForeignKey
(
to
=
Account
,
...
...
@@ -86,13 +88,13 @@ class Booking(models.Model):
null
=
True
,
)
description
=
models
.
CharField
(
max_length
=
50
,
verbose_name
=
_
(
"
Description
"
))
justification
=
models
.
CharField
(
max_length
=
2000
,
blank
=
True
,
verbose_name
=
_
(
"
Reason
"
))
justification
=
models
.
CharField
(
default
=
""
,
max_length
=
2000
,
blank
=
True
,
verbose_name
=
_
(
"
Reason
"
))
planned_amount
=
models
.
IntegerField
(
verbose_name
=
_
(
"
Planned amount
"
))
# Details
invoice_date
=
models
.
DateField
(
blank
=
True
,
verbose_name
=
_
(
"
Date of invoice
"
))
invoice_number
=
models
.
CharField
(
max_length
=
20
,
blank
=
True
,
verbose_name
=
_
(
"
Bill number
"
))
firma
=
models
.
CharField
(
max_length
=
30
,
blank
=
True
,
verbose_name
=
_
(
"
Company
"
))
invoice_date
=
models
.
DateField
(
default
=
timezone
.
now
,
blank
=
True
,
verbose_name
=
_
(
"
Date of invoice
"
))
invoice_number
=
models
.
CharField
(
default
=
"
0
"
,
max_length
=
20
,
blank
=
True
,
verbose_name
=
_
(
"
Bill number
"
))
firma
=
models
.
CharField
(
default
=
""
,
max_length
=
30
,
blank
=
True
,
verbose_name
=
_
(
"
Company
"
))
amount
=
models
.
DecimalField
(
max_digits
=
9
,
decimal_places
=
2
,
default
=
0.00
,
verbose_name
=
_
(
"
Amount
"
)
)
...
...
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