Skip to content

Commit

Permalink
feat: add pool as setting
Browse files Browse the repository at this point in the history
Sage X3 requires different pool for different environment.

#297
  • Loading branch information
igobranco committed Jun 5, 2024
1 parent ad4a395 commit 0ece58b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/billing/services/processor_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class SageX3Processor(TransactionProcessorInterface):
def __init__(self, transaction: Transaction) -> None:
super().__init__(transaction)
self.__processor_url = getattr(settings, "TRANSACTION_PROCESSOR_URL")
self.__pool_alias = getattr(settings, "POOL_ALIAS")
self.__vacitm1 = getattr(settings, "IVA_VACITM1_FIELD")
self.__vacbpr = getattr(settings, "GEOGRAPHIC_ACTIVITY_VACBPR_FIELD")
self.__user_processor_auth = getattr(settings, "USER_PROCESSOR_AUTH")
Expand Down Expand Up @@ -166,7 +167,7 @@ def __generate_data(self) -> str:
<wss:save soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<callContext xsi:type="wss:CAdxCallContext">
<codeLang xsi:type="xsd:string">POR</codeLang>
<poolAlias xsi:type="xsd:string">WSTEST</poolAlias>
<poolAlias xsi:type="xsd:string">{self.__pool_alias}</poolAlias>
<poolId xsi:type="xsd:string">?</poolId>
<requestConfig xsi:type="xsd:string">adxwss.beautify=true</requestConfig>
</callContext>
Expand Down
8 changes: 8 additions & 0 deletions apps/billing/tests/test_sagex3_processor_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ class SageX3ProcessDataTest(TestCase):
A test case for the SageX3Processor data property.
"""

@override_settings(POOL_ALIAS="MY_POOL")
def test_pool_alias(self):
transaction = TransactionFactory()
xml = SageX3Processor(transaction).data
root = ET.fromstring(xml) # nosec
poolAlias: str = root.findall(".//*/poolAlias")[0].text.strip()
self.assertEqual(poolAlias, "MY_POOL")

@staticmethod
def _get_xml_element_from_transaction(transaction: Transaction) -> ET.Element:
xml = SageX3Processor(transaction).data
Expand Down
1 change: 1 addition & 0 deletions nau_financial_manager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def get_env_setting(env_variable, default=None):

# Sage X3 - Transaction processor settings
TRANSACTION_PROCESSOR_URL = CONFIG.get("TRANSACTION_PROCESSOR_URL", "")
POOL_ALIAS = CONFIG.get("POOL_ALIAS", "WSTEST")
IVA_VACITM1_FIELD = CONFIG.get("IVA_VACITM1_FIELD", "NOR")
GEOGRAPHIC_ACTIVITY_VACBPR_FIELD = CONFIG.get("GEOGRAPHIC_ACTIVITY_VACBPR_FIELD", "CON")
USER_PROCESSOR_AUTH = CONFIG.get("USER_PROCESSOR_AUTH", "")
Expand Down

0 comments on commit 0ece58b

Please sign in to comment.