Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Paweljong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
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
Teckids
Projekt Hack-n-Fun
AlekSIS-App-Paweljong
Commits
c72bcdfe
Verified
Commit
c72bcdfe
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Add invoicing
parent
a2532161
No related branches found
No related tags found
1 merge request
!14
Payments
Pipeline
#58385
failed
3 years ago
Stage: prepare
Stage: test
Stage: build
Stage: publish
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/paweljong/models.py
+47
-0
47 additions, 0 deletions
aleksis/apps/paweljong/models.py
pyproject.toml
+1
-0
1 addition, 0 deletions
pyproject.toml
with
48 additions
and
0 deletions
aleksis/apps/paweljong/models.py
+
47
−
0
View file @
c72bcdfe
from
datetime
import
datetime
from
django.contrib.contenttypes.models
import
ContentType
from
django.db
import
models
from
django.urls
import
reverse
from
django.utils.text
import
slugify
...
...
@@ -8,7 +9,10 @@ from django.utils.translation import gettext_lazy as _
from
ckeditor.fields
import
RichTextField
from
django_iban.fields
import
IBANField
from
payments
import
PurchasedItem
from
aleksis.apps.tezor.models.base
import
Client
from
aleksis.apps.tezor.models.invoice
import
Invoice
,
InvoiceGroup
from
aleksis.core.mixins
import
ExtensibleModel
from
aleksis.core.models
import
Group
,
Person
from
aleksis.core.util.core_helpers
import
generate_random_code
,
get_site_preferences
...
...
@@ -261,6 +265,49 @@ class EventRegistration(ExtensibleModel):
blank
=
True
,
)
def
get_invoice
(
self
):
# FIXME Maybe do not hard-code this
client
,
__
=
Client
.
objects
.
get_or_create
(
name
=
"
Teckids e.V.
"
)
group
,
__
=
InvoiceGroup
.
objects
.
get_or_create
(
name
=
"
Hack
'
n
'
Fun-Veranstaltungen
"
,
client
=
client
)
invoice
,
__
=
Invoice
.
objects
.
get_or_create
(
for_content_type
=
ContentType
.
objects
.
get_for_model
(
self
),
for_object_id
=
self
.
pk
,
defaults
=
{
"
group
"
:
group
,
"
variant
"
:
"
dummy
"
,
"
transaction_id
"
:
f
"
HNF-
{
self
.
date_registered
.
strftime
(
'
%Y-%m
'
)
}
-
{
self
.
id
}
"
,
"
currency
"
:
"
EUR
"
,
"
total
"
:
self
.
_get_total_amount
()[
0
],
"
tax
"
:
self
.
_get_total_amount
()[
1
],
"
description
"
:
_
(
"
Participation of {} in event {}
"
).
format
(
self
.
person
.
addressing_name
,
self
.
event
.
display_name
),
"
billing_first_name
"
:
self
.
person
.
first_name
,
"
billing_last_name
"
:
self
.
person
.
last_name
,
"
billing_address_1
"
:
f
"
{
self
.
person
.
street
}
{
self
.
person
.
housenumber
}
"
,
"
billing_address_city
"
:
self
.
person
.
place
,
"
billing_address_postcode
"
:
self
.
person
.
postal_code
,
"
billing_email
"
:
self
.
perosn
.
email
,
})
return
invoice
def
get_purchased_items
(
self
):
# FIXME Maybe do not hard-code the tax rate and currency
# First, return main amount
yield
PurchasedItem
(
name
=
self
.
event
.
display_name
,
quantity
=
1
,
price
=
self
.
event
.
cost
,
currency
=
"
EUR
"
,
sku
=
""
,
tax_rate
=
7
)
# If a dnoation was made, add it
if
self
.
donation
:
yield
PurchasedItem
(
name
=
_
(
"
Social Sponsoring / Extra Donation
"
),
quantity
=
1
,
price
=
self
.
donation
,
currency
=
"
EUR
"
,
sku
=
""
,
tax_rate
=
0
)
# If a voucher was used, add it
if
self
.
voucher
:
yield
PurchasedItem
(
name
=
_
(
"
Voucher / Granted discount
"
),
quantity
=
1
,
price
=-
1
*
self
.
voucher
.
discount
*
self
.
event
.
cost
/
100
,
currency
=
"
EUR
"
,
sku
=
""
,
tax_rate
=
7
)
def
_get_total_amount
(
self
):
total
,
tax
=
0
,
0
for
item
in
self
.
get_purchased_items
():
total
+=
item
.
price
tax
+=
item
.
price
*
item
.
tax_rate
/
100
return
total
,
tax
def
__str__
(
self
)
->
str
:
return
f
"
{
self
.
event
}
,
{
self
.
person
.
first_name
}
{
self
.
person
.
last_name
}
"
...
...
This diff is collapsed.
Click to expand it.
pyproject.toml
+
1
−
0
View file @
c72bcdfe
...
...
@@ -30,6 +30,7 @@ django-iban-field = "^0.8"
django-formtools
=
"^2.3"
django-starfield
=
"^1.0"
aleksis-app-postbuero
=
"1.0+20220218233830.a212f707"
aleksis-app-tezor
=
"^1.0.dev0"
[tool.poetry.dev-dependencies]
aleksis-builddeps
=
"*"
...
...
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