wbcore 1.56.7__py2.py3-none-any.whl → 1.56.8__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wbcore/contrib/directory/models/entries.py +9 -0
- wbcore/contrib/directory/tests/conftest.py +2 -0
- wbcore/contrib/directory/tests/test_models.py +21 -0
- wbcore/utils/strings.py +2 -2
- {wbcore-1.56.7.dist-info → wbcore-1.56.8.dist-info}/METADATA +1 -1
- {wbcore-1.56.7.dist-info → wbcore-1.56.8.dist-info}/RECORD +7 -7
- {wbcore-1.56.7.dist-info → wbcore-1.56.8.dist-info}/WHEEL +0 -0
|
@@ -22,6 +22,7 @@ from slugify import slugify
|
|
|
22
22
|
|
|
23
23
|
from wbcore.contrib.agenda.models import CalendarItem
|
|
24
24
|
from wbcore.contrib.authentication.models import User
|
|
25
|
+
from wbcore.contrib.currency.models import Currency
|
|
25
26
|
from wbcore.contrib.directory.models.contacts import (
|
|
26
27
|
AddressContact,
|
|
27
28
|
BankingContact,
|
|
@@ -413,6 +414,14 @@ class Entry(ComplexToStringMixin, DeleteToDisableMixin, WBModel):
|
|
|
413
414
|
if additional_field_key in self.additional_fields:
|
|
414
415
|
del self.additional_fields[additional_field_key]
|
|
415
416
|
|
|
417
|
+
def get_banking_contact(self, currency: Currency) -> BankingContact | None:
|
|
418
|
+
bank_accounts = self.banking.all()
|
|
419
|
+
if bank_accounts.filter(currency=currency).exists():
|
|
420
|
+
bank_accounts = bank_accounts.filter(currency=currency)
|
|
421
|
+
if bank_accounts.filter(primary=True).exists():
|
|
422
|
+
bank_accounts = bank_accounts.filter(primary=True)
|
|
423
|
+
return bank_accounts.first()
|
|
424
|
+
|
|
416
425
|
@classmethod
|
|
417
426
|
def get_endpoint_basename(cls):
|
|
418
427
|
return "wbcore:directory:entry"
|
|
@@ -5,6 +5,7 @@ from django.db.models.signals import pre_migrate
|
|
|
5
5
|
from pytest_factoryboy import register
|
|
6
6
|
from wbcore.contrib.authentication.factories import InternalUserFactory, UserFactory
|
|
7
7
|
from wbcore.contrib.geography.tests.signals import app_pre_migration
|
|
8
|
+
from wbcore.contrib.currency.factories import CurrencyFactory
|
|
8
9
|
from wbcore.tests.conftest import *
|
|
9
10
|
|
|
10
11
|
from ..factories import (
|
|
@@ -45,6 +46,7 @@ register(RelationshipFactory)
|
|
|
45
46
|
register(RelationshipTypeFactory)
|
|
46
47
|
register(CustomerStatusFactory)
|
|
47
48
|
register(CompanyTypeFactory)
|
|
49
|
+
register(CurrencyFactory)
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
@pytest.fixture(autouse=True, scope="session")
|
|
@@ -405,3 +405,24 @@ class TestSpecificModelsRelationships:
|
|
|
405
405
|
to_entry=to_entry,
|
|
406
406
|
)
|
|
407
407
|
assert rel.__str__() == "John Doe is Type of Jane Doe"
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
@pytest.mark.django_db
|
|
411
|
+
class TestEntry:
|
|
412
|
+
def test_get_banking_contact(self, entry, banking_contact_factory, currency_factory):
|
|
413
|
+
eur = currency_factory.create()
|
|
414
|
+
usd = currency_factory.create()
|
|
415
|
+
|
|
416
|
+
euro_banking_contact = banking_contact_factory.create(entry=entry, currency=eur)
|
|
417
|
+
assert entry.get_banking_contact(eur) == euro_banking_contact
|
|
418
|
+
assert (
|
|
419
|
+
entry.get_banking_contact(usd) == euro_banking_contact
|
|
420
|
+
) # even if usd does not exist, we need to return at least a banking contact
|
|
421
|
+
|
|
422
|
+
usd_banking_contact = banking_contact_factory.create(entry=entry, currency=usd, primary=True)
|
|
423
|
+
|
|
424
|
+
assert entry.get_banking_contact(eur) == euro_banking_contact
|
|
425
|
+
assert entry.get_banking_contact(usd) == usd_banking_contact
|
|
426
|
+
|
|
427
|
+
new_primary_usd_banking_contact = banking_contact_factory.create(entry=entry, currency=usd, primary=True)
|
|
428
|
+
assert entry.get_banking_contact(usd) == new_primary_usd_banking_contact
|
wbcore/utils/strings.py
CHANGED
|
@@ -15,7 +15,7 @@ def enumerated_string_join(array):
|
|
|
15
15
|
return ""
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def format_number(number, decimal: int = 2, **kwargs) -> float |
|
|
18
|
+
def format_number(number, decimal: int = 2, **kwargs) -> float | str:
|
|
19
19
|
"""
|
|
20
20
|
utility function used to serialize an aggregate to a json compatible value
|
|
21
21
|
Args:
|
|
@@ -28,7 +28,7 @@ def format_number(number, decimal: int = 2, **kwargs) -> float | None:
|
|
|
28
28
|
try:
|
|
29
29
|
return float(round(number, decimal))
|
|
30
30
|
except TypeError:
|
|
31
|
-
return
|
|
31
|
+
return ""
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
class ReferenceIDMixin:
|
|
@@ -318,7 +318,7 @@ wbcore/contrib/directory/migrations/0013_alter_clientmanagerrelationship_options
|
|
|
318
318
|
wbcore/contrib/directory/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
319
319
|
wbcore/contrib/directory/models/__init__.py,sha256=XtnmU5YUr3SGig6PsSfGsWUaiBaX6kaHShBv3sbxZ14,526
|
|
320
320
|
wbcore/contrib/directory/models/contacts.py,sha256=8KVCmzNARTzeQgRtXe78QKhJr0SvEJ-aZcsRuYaMIbE,18322
|
|
321
|
-
wbcore/contrib/directory/models/entries.py,sha256=
|
|
321
|
+
wbcore/contrib/directory/models/entries.py,sha256=XXEWJ3UOvs8CgN0AekY7FOy4sNOww5jTpPTdDedYYb0,32365
|
|
322
322
|
wbcore/contrib/directory/models/relationships.py,sha256=7SZFo1tA7NRzS7_gv_fKwMsPPhawu90eWSrEvij_0rk,22108
|
|
323
323
|
wbcore/contrib/directory/release_notes/1_0_0.md,sha256=Twbl9RMLO6dbbm5dVoKorw8BecRqAYsKeobcNmDWHu8,165
|
|
324
324
|
wbcore/contrib/directory/release_notes/1_0_1.md,sha256=yHolV-HwBmIavaPn9pg0ABRgxQ-eKIuiAs-phKb_ix0,285
|
|
@@ -352,12 +352,12 @@ wbcore/contrib/directory/static/directory/markdown/documentation/userisclient.md
|
|
|
352
352
|
wbcore/contrib/directory/static/directory/markdown/documentation/userismanager.md,sha256=I3ojIVTFZ_bEk8-67jO2Jrctk90kSzX-WrREDfplwpg,1037
|
|
353
353
|
wbcore/contrib/directory/static/directory/markdown/documentation/website.md,sha256=n8VAXbgxQh9zslLfLB0UhRgliMCvNS2N6gR-K0oTrkY,1453
|
|
354
354
|
wbcore/contrib/directory/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
355
|
-
wbcore/contrib/directory/tests/conftest.py,sha256=
|
|
355
|
+
wbcore/contrib/directory/tests/conftest.py,sha256=54xK711IfBc6Cj7MweNOGNdkP-ojjMcfqjP1G2XrSn0,1826
|
|
356
356
|
wbcore/contrib/directory/tests/disable_signals.py,sha256=kgVeTtzItEtLJ7MOVo9KdnRABsMvKBTub-vhHIMKO_M,1727
|
|
357
357
|
wbcore/contrib/directory/tests/signals.py,sha256=DqQkJWnq2Y0wTTLh3ICY3qZJLUpGJqiTTSV6YypqsDQ,3217
|
|
358
358
|
wbcore/contrib/directory/tests/test_configs.py,sha256=VouLg3TpDuxi_ljh8MtJGMhtW_h8OzCo15GyyApW16c,189
|
|
359
359
|
wbcore/contrib/directory/tests/test_filters.py,sha256=tc4G0XoUoDoiisECXtaftYCG69fdE42-EmkmLcjbN78,2492
|
|
360
|
-
wbcore/contrib/directory/tests/test_models.py,sha256=
|
|
360
|
+
wbcore/contrib/directory/tests/test_models.py,sha256=L2029y7pTUznRYHXJOKFpy_jdTBZvvbx3KwHMEcNSAM,19304
|
|
361
361
|
wbcore/contrib/directory/tests/test_permissions.py,sha256=lmGAiE0wtIDJkHEfNk_8NDwqN71FdPuu2qXvSMm0FbM,4231
|
|
362
362
|
wbcore/contrib/directory/tests/test_serializers.py,sha256=AIa-Rktw4EG2eywMSCz-X1rYcBSmw7Zzx38CghBVGzo,9202
|
|
363
363
|
wbcore/contrib/directory/tests/test_viewsets.py,sha256=pZJ-D-pxRP1IWNZDrKML_6j4iBcFzv8qpo59qX9MpOU,32624
|
|
@@ -1216,7 +1216,7 @@ wbcore/utils/serializers.py,sha256=fn__UYJolYjg063OHmAt7zC9zxMxsqrVERpGhLzUK3o,4
|
|
|
1216
1216
|
wbcore/utils/settings.py,sha256=MCt48ZJO9nOzGPAFYJ-_o0uRCDUt3_yzEek6m4oZTYg,198
|
|
1217
1217
|
wbcore/utils/signals.py,sha256=sNDbYKcjTsACpod50dB_TgYC-f37aN0N_M_DMJgTiMA,1132
|
|
1218
1218
|
wbcore/utils/string_loader.py,sha256=AWmn40nM8A1cxoVwpO2lF6YidEfL3JC1du2cank4Dw4,1169
|
|
1219
|
-
wbcore/utils/strings.py,sha256=
|
|
1219
|
+
wbcore/utils/strings.py,sha256=DvMm2vrEjfxH6Hjf7XvRSo-3eAnLf4oLzxki8xonmNs,1856
|
|
1220
1220
|
wbcore/utils/task.py,sha256=HlPyALx78lSprsY_ICeI-SrXTPBmRpx8nyVIIrRtKb4,84
|
|
1221
1221
|
wbcore/utils/urls.py,sha256=BjmavE84QYECWDKyV3dENn8GQqwdBmX6MqXyCjmwmbA,2137
|
|
1222
1222
|
wbcore/utils/views.py,sha256=XnWQqMjAi6dXTF-ZYF9FHU1a7cDpAymcuZRt8g_cEqI,8541
|
|
@@ -1229,6 +1229,6 @@ wbcore/viewsets/generics.py,sha256=lKDq9UY_Tyc56u1bqaIEvHGgoaXwXxpZ1c3fLVteptI,1
|
|
|
1229
1229
|
wbcore/viewsets/mixins.py,sha256=IdHd_uixOv3ExKoHxTgL5Bt8OELIwfYwhBZm0nsvZfc,12054
|
|
1230
1230
|
wbcore/viewsets/utils.py,sha256=4520Ij3ASM8lOa8QZkCqbBfOexVRiZu688eW-PGqMOA,882
|
|
1231
1231
|
wbcore/viewsets/viewsets.py,sha256=FPPESunEjlunDr5VFsjTfsquTS3iDSQkw0H6QjMKPqk,6574
|
|
1232
|
-
wbcore-1.56.
|
|
1233
|
-
wbcore-1.56.
|
|
1234
|
-
wbcore-1.56.
|
|
1232
|
+
wbcore-1.56.8.dist-info/METADATA,sha256=cga3JvdAH3UXpC-1tiJr-T6bI08lEZ2HXvyRJHm43RI,2332
|
|
1233
|
+
wbcore-1.56.8.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
|
|
1234
|
+
wbcore-1.56.8.dist-info/RECORD,,
|
|
File without changes
|