wbcore 1.56.6__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.
@@ -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"
@@ -27,9 +27,7 @@ class CompanyModelSerializer(EntryModelSerializer):
27
27
  )
28
28
  _employees = PersonRepresentationSerializer(source="employees", many=True)
29
29
  is_primary_employer = wb_serializers.BooleanField(read_only=True)
30
- tier = wb_serializers.CharField(
31
- help_text=settings.DEFAULT_TIERING_HELP_TEXT, required=False, read_only=True, label=_("Tier")
32
- )
30
+ tier = wb_serializers.CharField(help_text=settings.DEFAULT_TIERING_HELP_TEXT, label=_("Tier"), required=False)
33
31
  _type = CompanyTypeRepresentationSerializer(source="type")
34
32
 
35
33
  @wb_serializers.register_resource()
@@ -203,7 +203,6 @@ class EntryModelSerializer(wb_serializers.ModelSerializer):
203
203
  )
204
204
  primary_telephone = wb_serializers.TelephoneField(
205
205
  allow_null=True,
206
- read_only=True,
207
206
  required=False,
208
207
  label=_("Primary Telephone"),
209
208
  )
@@ -29,7 +29,7 @@ class PersonModelSerializer(ModelTranslateSerializerMixin, EntryModelSerializer)
29
29
  color=WBColor.BLUE_LIGHT.value, required=False, label=_("Personality Profile Blue")
30
30
  )
31
31
  _specializations = SpecializationRepresentationSerializer(source="specializations", many=True)
32
- tier = wb_serializers.CharField(read_only=True, help_text=_("Tier of the primary employer"), label=_("Tier"))
32
+ tier = wb_serializers.CharField(help_text=_("Tier of the primary employer"), label=_("Tier"), required=False)
33
33
 
34
34
  def get_user_account_email(self, obj):
35
35
  if hasattr(obj, "user_account"):
@@ -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 | None:
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 None
31
+ return ""
32
32
 
33
33
 
34
34
  class ReferenceIDMixin:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wbcore
3
- Version: 1.56.6
3
+ Version: 1.56.8
4
4
  Author-email: Christopher Wittlinger <c.wittlinger@stainly.com>
5
5
  Requires-Dist: boto3==1.35.*
6
6
  Requires-Dist: celery[redis]==5.*
@@ -318,17 +318,17 @@ 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=S53zghpS18sqZGquAEirMGVuenHhq2Yhdh8ijTScPCw,31904
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
325
325
  wbcore/contrib/directory/release_notes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
326
326
  wbcore/contrib/directory/serializers/__init__.py,sha256=36WcX6aHrBuZXVWR0JSCeCCvJin_jOEaiwuSYBSs5eo,2131
327
- wbcore/contrib/directory/serializers/companies.py,sha256=E9LegHl_jBdlJnixaa9j3RmMtvgYqHiEHHRK8GmhZzU,5777
327
+ wbcore/contrib/directory/serializers/companies.py,sha256=Bvxex_tq5lyR3k9Ox_Z2AnRQVyhPM0l1bdClJAjeEdo,5747
328
328
  wbcore/contrib/directory/serializers/contacts.py,sha256=Q-3lmivmS4ci9XP-65lO1d06Gm6cQMgPH3YA8FY71ZE,15205
329
- wbcore/contrib/directory/serializers/entries.py,sha256=gtp0zLfyrbr46N3hKhbBy7BkT8wHq-be4weva6ckVhc,13608
329
+ wbcore/contrib/directory/serializers/entries.py,sha256=QV_hlstwFWvhp-uiVPn3xMt0bES_6gKJs4rf_CVHIn0,13584
330
330
  wbcore/contrib/directory/serializers/entry_representations.py,sha256=Pj8j4HYDINvXlLZ7onBypF2ZOK_GGzFZevd-yzESqoU,1397
331
- wbcore/contrib/directory/serializers/persons.py,sha256=1zPg1FnPuXg-0jtf2lRxP0Wo-inD2ZifzEpv5UelZys,7641
331
+ wbcore/contrib/directory/serializers/persons.py,sha256=YtUgKKeijvV87JLtgeQtxmyk21COLQjSrb5klBw_EXQ,7641
332
332
  wbcore/contrib/directory/serializers/relationships.py,sha256=jGrjy8M8kaxNRHHJ0HiDMdD_-wZFwioRJabCpCwHZ4U,12390
333
333
  wbcore/contrib/directory/static/directory/markdown/documentation/address.md,sha256=gfUVi2PZh5uQ5sWkLG-AxYV9ULWeswRp3E2Me4fEs88,1865
334
334
  wbcore/contrib/directory/static/directory/markdown/documentation/banking.md,sha256=5jgF1tqTGdr4fRaXCtobtpFEx0xcSmVYkKvzVALp4L8,28387
@@ -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=6Png5NaERN8WBcnpw3mM8F6Xg7erCHh0IO-6hdPyT6E,1738
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=OhqzBiI6B3-yrdsKV1PS0LyJcWwayGPdR7OwU2BDi54,18323
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=_7IzcjOQqPVbqxnRwGI4PAJrwJa7NmnXqXWxMuw5kew,1859
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.6.dist-info/METADATA,sha256=y-y-6lzajumEVNnQ1SH4JkvwCCBMYJUFH4d_eWaQvT0,2332
1233
- wbcore-1.56.6.dist-info/WHEEL,sha256=tkmg4JIqwd9H8mL30xA7crRmoStyCtGp0VWshokd1Jc,105
1234
- wbcore-1.56.6.dist-info/RECORD,,
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,,