Allow other billing address for cembra

This commit is contained in:
Christian Cueni 2024-07-29 11:49:27 +02:00
parent c1092d3a07
commit 0313abb010
4 changed files with 66 additions and 7 deletions

View File

@ -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"

View File

@ -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,

View File

@ -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

View File

@ -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,