Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBPIH-5455 Add filter for GL account #3866

Merged
merged 15 commits into from
Mar 1, 2023
Merged

OBPIH-5455 Add filter for GL account #3866

merged 15 commits into from
Mar 1, 2023

Conversation

alannadolny
Copy link
Collaborator

No description provided.

}

render([data: glAccounts] as JSON)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be in the GlAccountController, not in the ProductApiController and would be good to add this fetching stuff to the service and here leave:

def glAccounts = glAccountService.getGlAccountsOptions()
...

export const fetchProductsGlAccounts = async () => {
const response = await apiClient.get('/openboxes/api/glAccountOptions');
return response.data.data;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we could follow, since you've refactored some of our api calls to use api/services, to use this approach here?

@@ -27,3 +27,6 @@ export const STOCKLIST_CLEAR = id => `${STOCKLIST_API}/${id}/clear`;
export const STOCKLIST_CLONE = id => `${STOCKLIST_API}/${id}/clone`;
export const STOCKLIST_PUBLISH = id => `${STOCKLIST_API}/${id}/publish`;
export const STOCKLIST_UNPUBLISH = id => `${STOCKLIST_API}/${id}/unpublish`;

// GL ACCOUNTS
export const GL_ACCOUNTS_OPTION = '/openboxes/api/glAccountOptions';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having an occassion - could you please specify at the top of the file

const API = '/openboxes/api'

and use it in this endpoint?
You don't have to change it the lines above, but just to have less refactor in the future and use this constant since now

export const fetchProductsGlAccounts = async () => {
const { data } = await glAccountApi.getGlAccountOptions();
return data.data;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding one additional comment, which should be rather answered by @awalkowiak - I'm wondering if we should wrap it inside try/catch and have somewhat user-friendly error message if any happens, or let the handler handle that, but we could have some "ugly" error message in terms of user perspective?

Copy link
Member

@jmiranda jmiranda Feb 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion for standardizing error messages #3849 to be included in coding conventions. May require more technical discussions around this. #3867

grails-app/conf/UrlMappings.groovy Outdated Show resolved Hide resolved
* @param params
* @return
*/
List<Product> getProducts(List<Category> categories, List<ProductCatalog> catalogsInput, List<Tag> tagsInput, boolean includeInactive, Map params) {
List<Product> getProducts(List<Category> categories, List<ProductCatalog> catalogsInput, List<Tag> tagsInput, List<GlAccount> glAccounts, boolean includeInactive, Map params) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am starting to dislike these parameters more with each new one. I think we could think about refactoring this one.

Copy link
Member

@jmiranda jmiranda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to create a new API for the options endpoints.

Copy link
Member

@jmiranda jmiranda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

SelectOptionsService selectOptionsService;

def glAccountOptions = {
def glAccounts = selectOptionsService.getGlAccountsOptions()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awalkowiak What do you think about using the generic API service here?

def glAccountOptions = { 
    def glAccounts = genericApiService.getList(GlAccount.class, [:]).collect {
            [id: it.id, label: "${it.code} - ${it.name}"]
        }
    }
    render([data: glAccounts] as JSON)
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if we can get rid of adding one another redundant service, then this should be good. cc: @alannadolny

@@ -137,4 +141,27 @@ class GenericApiService {
}
}

def getGlAccountsOptions() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not put this here since in that way this is in no way generic. You should use the exact code that Justin suggested.

@@ -18,6 +18,10 @@ import org.hibernate.ObjectNotFoundException
import org.hibernate.SessionFactory
import org.hibernate.criterion.Criterion
import org.hibernate.criterion.Restrictions
import org.pih.warehouse.core.GlAccount
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need this anymore

@awalkowiak awalkowiak merged commit a854eac into develop Mar 1, 2023
@awalkowiak awalkowiak deleted the OBPIH-5455 branch March 1, 2023 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants