From 041c1f5bdadcdaac47fdb8ba48a32df116c49405 Mon Sep 17 00:00:00 2001 From: Muhammad Shahrukh <> Date: Thu, 24 Oct 2024 12:05:27 +0500 Subject: [PATCH] CSTMM-43: Fix owner organization field on credit note creation --- .../directives/creditnote-create.directive.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ang/fe-creditnote/directives/creditnote-create.directive.js b/ang/fe-creditnote/directives/creditnote-create.directive.js index b59f3e0..9dd9e9f 100644 --- a/ang/fe-creditnote/directives/creditnote-create.directive.js +++ b/ang/fe-creditnote/directives/creditnote-create.directive.js @@ -119,9 +119,22 @@ return } + let currentOwnerOrganization = $scope.creditnotes.owner_organization ? $scope.creditnotes.owner_organization + : String($scope.companies[0]?.contact_id); + let contributionOwnerOrganization = null; + + $scope.companies.forEach((company) => { + if (company.contact_id !== null && + String(contribution['financeextras_contribution_owner.owner_organization']) === String(company.contact_id) + ) { + contributionOwnerOrganization = String(company.contact_id); + } + }); + $scope.contactId = contribution.contact_id $scope.creditnotes.contact_id = contribution.contact_id - $scope.creditnotes.owner_organization = String(contribution['financeextras_contribution_owner.owner_organization']) + $scope.creditnotes.owner_organization = contributionOwnerOrganization ? + contributionOwnerOrganization : currentOwnerOrganization; $scope.creditnotes.currency = contribution.currency $scope.disableCurrency = true $scope.currencySymbol = CurrencyCodes.getSymbol(contribution.currency);