|
7 | 7 | from fyle_accounting_mappings.models import CategoryMapping, DestinationAttribute, ExpenseAttribute, Mapping |
8 | 8 | from sageintacctsdk.exceptions import WrongParamsError |
9 | 9 |
|
10 | | -from apps.mappings.models import GeneralMapping |
| 10 | +from apps.mappings.models import GeneralMapping, LocationEntityMapping |
11 | 11 | from apps.sage_intacct.models import CostCode, CostType, SageIntacctAttributesCount |
12 | 12 | from apps.sage_intacct.utils import Configuration, SageIntacctConnector, SageIntacctCredential, Workspace |
13 | 13 | from fyle_intacct_api.utils import invalidate_sage_intacct_credentials |
@@ -485,6 +485,36 @@ def test_construct_journal_entry(create_journal_entry, db): |
485 | 485 | assert dict_compare_keys(journal_entry_object, data['journal_entry_re_payload']) == [], 'construct journal entry api return diffs in keys' |
486 | 486 |
|
487 | 487 |
|
| 488 | +def test_construct_journal_entry_with_baselocation(create_journal_entry, db): |
| 489 | + """ |
| 490 | + Test construct journal entry includes BASELOCATION_NO when conditions are met |
| 491 | + """ |
| 492 | + workspace_id = 1 |
| 493 | + |
| 494 | + intacct_credentials = SageIntacctCredential.objects.get(workspace_id=workspace_id) |
| 495 | + sage_intacct_connection = SageIntacctConnector(credentials_object=intacct_credentials, workspace_id=workspace_id) |
| 496 | + |
| 497 | + LocationEntityMapping.objects.filter(workspace_id=workspace_id).update(destination_id='top_level') |
| 498 | + |
| 499 | + configuration = Configuration.objects.get(workspace_id=workspace_id) |
| 500 | + configuration.je_single_credit_line = True |
| 501 | + configuration.save() |
| 502 | + |
| 503 | + general_mappings = GeneralMapping.objects.get(workspace_id=workspace_id) |
| 504 | + general_mappings.default_location_id = 'LOC123' |
| 505 | + general_mappings.save() |
| 506 | + |
| 507 | + journal_entry, journal_entry_lineitems = create_journal_entry |
| 508 | + |
| 509 | + journal_entry_object = sage_intacct_connection._SageIntacctConnector__construct_journal_entry( |
| 510 | + journal_entry=journal_entry, |
| 511 | + journal_entry_lineitems=journal_entry_lineitems |
| 512 | + ) |
| 513 | + |
| 514 | + assert 'BASELOCATION_NO' in journal_entry_object |
| 515 | + assert journal_entry_object['BASELOCATION_NO'] == 'LOC123' |
| 516 | + |
| 517 | + |
488 | 518 | def test_construct_sage_intacct_reimbursement(create_sage_intacct_reimbursement, db): |
489 | 519 | """ |
490 | 520 | Test construct sage intacct reimbursement |
|
0 commit comments