Merged develop into feature/VBV-696-person-export
This commit is contained in:
commit
c9a75c2867
|
|
@ -293,7 +293,7 @@ const executePayment = async () => {
|
|||
{{ formErrors.personal.join(", ") }}
|
||||
</p>
|
||||
|
||||
<section v-if="address.payment_method !== 'cembra_byjuno'">
|
||||
<section>
|
||||
<div class="mt-4">
|
||||
<button
|
||||
v-if="!withCompanyAddress"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
import djclick as click
|
||||
import structlog
|
||||
from django.db.models import Count
|
||||
|
||||
from vbv_lernwelt.course.models import CourseSessionUser
|
||||
|
||||
logger = structlog.get_logger(__name__)
|
||||
|
||||
|
||||
@click.command()
|
||||
def command():
|
||||
VV_COURSE_SESSIONS = [1, 2, 3] # DE, FR, IT
|
||||
|
||||
# Aggregation of users per organisation for a specific course session
|
||||
user_counts = (
|
||||
CourseSessionUser.objects.filter(course_session__id__in=VV_COURSE_SESSIONS)
|
||||
.values("user__organisation__organisation_id", "user__organisation__name_de")
|
||||
.annotate(user_count=Count("id"))
|
||||
.order_by("user__organisation__organisation_id")
|
||||
)
|
||||
|
||||
for entry in user_counts:
|
||||
print(
|
||||
f"Organisation Name: {entry['user__organisation__name_de']}, "
|
||||
f"User Count: {entry['user_count']}"
|
||||
)
|
||||
|
||||
print(
|
||||
f"Total number of users: {sum([entry['user_count'] for entry in user_counts])}"
|
||||
)
|
||||
|
|
@ -78,32 +78,32 @@ def create_customer_xml(checkout_information: CheckoutInformation):
|
|||
first_name=checkout_information.first_name,
|
||||
company_name=(
|
||||
checkout_information.organisation_detail_name
|
||||
if checkout_information.invoice_address == "org"
|
||||
if checkout_information.abacus_use_organisation_data()
|
||||
else ""
|
||||
),
|
||||
street=(
|
||||
checkout_information.organisation_street
|
||||
if checkout_information.invoice_address == "org"
|
||||
if checkout_information.abacus_use_organisation_data()
|
||||
else checkout_information.street
|
||||
),
|
||||
house_number=(
|
||||
checkout_information.organisation_street_number
|
||||
if checkout_information.invoice_address == "org"
|
||||
if checkout_information.abacus_use_organisation_data()
|
||||
else checkout_information.street_number
|
||||
),
|
||||
zip_code=(
|
||||
checkout_information.organisation_postal_code
|
||||
if checkout_information.invoice_address == "org"
|
||||
if checkout_information.abacus_use_organisation_data()
|
||||
else checkout_information.postal_code
|
||||
),
|
||||
city=(
|
||||
checkout_information.organisation_city
|
||||
if checkout_information.invoice_address == "org"
|
||||
if checkout_information.abacus_use_organisation_data()
|
||||
else checkout_information.city
|
||||
),
|
||||
country=(
|
||||
checkout_information.organisation_country_id
|
||||
if checkout_information.invoice_address == "org"
|
||||
if checkout_information.abacus_use_organisation_data()
|
||||
else checkout_information.country_id
|
||||
),
|
||||
language=customer.language,
|
||||
|
|
|
|||
|
|
@ -128,3 +128,15 @@ class CheckoutInformation(models.Model):
|
|||
self.abacus_order_id = new_abacus_order_id
|
||||
self.save()
|
||||
return self
|
||||
|
||||
def abacus_address_type(self) -> str:
|
||||
# always use priv for abacus and CembraPay
|
||||
return (
|
||||
self.INVOICE_ADDRESS_ORGANISATION
|
||||
if self.invoice_address == self.INVOICE_ADDRESS_ORGANISATION
|
||||
and not self.cembra_byjuno_invoice
|
||||
else self.INVOICE_ADDRESS_PRIVATE
|
||||
)
|
||||
|
||||
def abacus_use_organisation_data(self) -> bool:
|
||||
return self.abacus_address_type() == self.INVOICE_ADDRESS_ORGANISATION
|
||||
|
|
|
|||
|
|
@ -163,6 +163,53 @@ class AbacusInvoiceTestCase(TestCase):
|
|||
assert "<Street>Laupenstrasse</Street>" in customer_xml_content
|
||||
assert "<Country>CH</Country>" in customer_xml_content
|
||||
|
||||
def test_create_customer_xml_byjuno_cembra_with_company_address(self):
|
||||
_pat = User.objects.get(username="patrizia.huggel@eiger-versicherungen.ch")
|
||||
_pat.abacus_debitor_number = 60000011
|
||||
_pat.save()
|
||||
_ignore_checkout_information = CheckoutInformationFactory(
|
||||
user=_pat, abacus_order_id=6_000_000_123
|
||||
)
|
||||
|
||||
feuz = User.objects.get(username="andreas.feuz@eiger-versicherungen.ch")
|
||||
feuz_checkout_info = CheckoutInformationFactory(
|
||||
user=feuz,
|
||||
transaction_id="24021508331287484",
|
||||
first_name="Andreas",
|
||||
last_name="Feuz",
|
||||
street="Eggersmatt",
|
||||
street_number="32",
|
||||
postal_code="1719",
|
||||
city="Zumholz",
|
||||
country_id="CH",
|
||||
invoice_address="org",
|
||||
organisation_detail_name="VBV",
|
||||
organisation_street="Laupenstrasse",
|
||||
organisation_street_number="10",
|
||||
organisation_postal_code="3000",
|
||||
organisation_city="Bern",
|
||||
organisation_country_id="CH",
|
||||
cembra_byjuno_invoice=True,
|
||||
)
|
||||
feuz_checkout_info.created_at = datetime(2024, 2, 15, 8, 33, 12, 0)
|
||||
|
||||
customer_xml_filename, customer_xml_content = create_customer_xml(
|
||||
checkout_information=feuz_checkout_info
|
||||
)
|
||||
print(customer_xml_content)
|
||||
print(customer_xml_filename)
|
||||
|
||||
self.assertEqual("myVBV_debi_60000012.xml", customer_xml_filename)
|
||||
assert "<CustomerNumber>60000012</CustomerNumber>" in customer_xml_content
|
||||
assert (
|
||||
"<Email>andreas.feuz@eiger-versicherungen.ch</Email>"
|
||||
in customer_xml_content
|
||||
)
|
||||
assert "<AddressNumber>60000012</AddressNumber>" in customer_xml_content
|
||||
assert "<Name>Feuz</Name>" in customer_xml_content
|
||||
assert "<Text>VBV</Text>" not in customer_xml_content
|
||||
assert "<Street>Eggersmatt</Street>" in customer_xml_content
|
||||
|
||||
def test_render_customer_xml(self):
|
||||
customer_xml = render_customer_xml(
|
||||
abacus_debitor_number=60000012,
|
||||
|
|
|
|||
Loading…
Reference in New Issue