-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
38c55b8
OBPIH-5455 Add Gl Accounts field
alannadolny 66b6289
OBPIH-5455 Add glAccountsId to queryParams
alannadolny 087dcde
OBPIH-5455 Add endpoint for gl accounts options
alannadolny 65ef712
OBPIH-5455 Add filtering by Gl Account
alannadolny 00c5525
Refactor initializeDefaultFilterValues in useProductFilters
alannadolny 593b914
OBPIH-5455 Change setDefaultValue function
alannadolny a7c2a6f
OBPIH-5455 Move import to new line
alannadolny 63a7aa0
OBPIH-5455 Fix testList in productApiControllerTests
alannadolny 0520272
OBPIH-5455 Fixes after review
alannadolny c7ab214
OBPIH-5455 Assign API url to variable
alannadolny 4bcfe1d
OBPIH-5455 Move options endpoints to new controller and change filter…
alannadolny 84f09c9
OBPIH-5455 Move select option functions to GenericApiService
alannadolny 3c2f7b3
OBPIH-5455 Fixes after review
alannadolny d890d5d
OBPIH-5455 Remove unused import
alannadolny 4cdc4e8
OBPIH-5455 Remove unused imports from genericApiService
alannadolny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
grails-app/controllers/org/pih/warehouse/api/SelectOptionsApiController.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) 2012 Partners In Health. All rights reserved. | ||
* The use and distribution terms for this software are covered by the | ||
* Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | ||
* which can be found in the file epl-v10.html at the root of this distribution. | ||
* By using this software in any fashion, you are agreeing to be bound by | ||
* the terms of this license. | ||
* You must not remove this notice, or any other, from this software. | ||
**/ | ||
package org.pih.warehouse.api | ||
|
||
import grails.converters.JSON | ||
import org.pih.warehouse.core.SelectOptionsService | ||
|
||
class SelectOptionsApiController { | ||
|
||
SelectOptionsService selectOptionsService; | ||
|
||
def glAccountOptions = { | ||
def glAccounts = selectOptionsService.getGlAccountsOptions() | ||
render([data: glAccounts] as JSON) | ||
} | ||
|
||
def tagOptions = { | ||
def tags = selectOptionsService.getTagsOptions() | ||
render([data: tags] as JSON) | ||
} | ||
|
||
def catalogOptions = { | ||
def catalogs = selectOptionsService.getCatalogsOptions() | ||
render([data: catalogs] as JSON) | ||
} | ||
|
||
def categoryOptions = { | ||
def categories = selectOptionsService.getCategoryOptions() | ||
render([data: categories] as JSON) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
grails-app/services/org/pih/warehouse/core/SelectOptionsService.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Copyright (c) 2012 Partners In Health. All rights reserved. | ||
* The use and distribution terms for this software are covered by the | ||
* Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) | ||
* which can be found in the file epl-v10.html at the root of this distribution. | ||
* By using this software in any fashion, you are agreeing to be bound by | ||
* the terms of this license. | ||
* You must not remove this notice, or any other, from this software. | ||
**/ | ||
package org.pih.warehouse.core | ||
|
||
import org.pih.warehouse.product.Category | ||
import org.pih.warehouse.product.ProductCatalog | ||
|
||
class SelectOptionsService { | ||
|
||
def getGlAccountsOptions() { | ||
return GlAccount.list().collect { | ||
[id: it.id, label: "${it.code} - ${it.name}"] | ||
} | ||
} | ||
|
||
def getTagsOptions() { | ||
return Tag.list(sort: "tag").collect { | ||
[id: it.id, label: "${it.tag} (${it?.products?.size()})"] | ||
} | ||
} | ||
|
||
def getCatalogsOptions() { | ||
return ProductCatalog.list(sort: "name").collect { | ||
[id: it.id, label: "${it.name} (${it?.productCatalogItems?.size()})"] | ||
} | ||
} | ||
|
||
def getCategoryOptions() { | ||
return Category.list().sort().collect { | ||
[id: it.id, label: it.getHierarchyAsString(" > ")] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -273,7 +273,7 @@ class ProductService { | |
* @return | ||
*/ | ||
List<Product> getProducts(Category category, List<Tag> tags, boolean includeInactive, Map params) { | ||
return getProducts([category], [], tags, includeInactive, params) | ||
return getProducts([category], [], tags, [], includeInactive, params) | ||
} | ||
|
||
/** | ||
|
@@ -282,10 +282,11 @@ class ProductService { | |
* @param category | ||
* @param catalogs | ||
* @param tags | ||
* @param glAccounts | ||
* @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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
int max = params.max ? params.int("max") : 10 | ||
int offset = params.offset ? params.int("offset") : 0 | ||
String sortColumn = params.sort ?: "name" | ||
|
@@ -323,6 +324,11 @@ class ProductService { | |
} | ||
} | ||
|
||
if (glAccounts) { | ||
glAccount { | ||
'in'("id", glAccounts.collect { it.id }) | ||
} | ||
} | ||
|
||
if (tagsInput) { | ||
tags { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { GL_ACCOUNTS_OPTION } from 'api/urls'; | ||
import apiClient from 'utils/apiClient'; | ||
|
||
export default { | ||
getGlAccountOptions: () => apiClient.get(GL_ACCOUNTS_OPTION), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
const API = '/openboxes/api'; | ||
|
||
// PURCHASE ORDER | ||
export const PURCHASE_ORDER_API = '/openboxes/api/purchaseOrders'; | ||
export const PURCHASE_ORDER_API = `${API}/purchaseOrders`; | ||
export const PURCHASE_ORDER_DELETE = id => `${PURCHASE_ORDER_API}/${id}`; | ||
export const PURCHASE_ORDER_ROLLBACK_ORDER = id => `${PURCHASE_ORDER_API}/${id}/rollback`; | ||
|
||
// STOCK MOVEMENT | ||
export const STOCK_MOVEMENT_API = '/openboxes/api/stockMovements'; | ||
export const STOCK_MOVEMENT_API = `${API}/stockMovements`; | ||
export const STOCK_MOVEMENT_DELETE = id => `${STOCK_MOVEMENT_API}/${id}`; | ||
export const STOCK_MOVEMENT_PENDING_SHIPMENT_ITEMS = `${STOCK_MOVEMENT_API}/pendingRequisitionItems`; | ||
export const STOCK_MOVEMENT_INCOMING_ITEMS = `${STOCK_MOVEMENT_API}/shippedItems`; | ||
|
||
// STOCK TRANSFER | ||
export const STOCK_TRANSFER_API = '/openboxes/api/stockTransfers'; | ||
export const STOCK_TRANSFER_API = `${API}/stockTransfers`; | ||
export const STOCK_TRANSFER_DELETE = id => `${STOCK_TRANSFER_API}/${id}`; | ||
|
||
// INVOICE | ||
export const INVOICE_API = '/openboxes/api/invoices'; | ||
export const INVOICE_API = `${API}/invoices`; | ||
|
||
// PRODUCT | ||
export const PRODUCT_API = '/openboxes/api/products'; | ||
export const PRODUCT_API = `${API}/products`; | ||
|
||
// STOCK LIST | ||
export const STOCKLIST_API = '/openboxes/api/stocklists'; | ||
export const STOCKLIST_API = `${API}/stocklists`; | ||
export const STOCKLIST_EXPORT = id => `${STOCKLIST_API}/${id}/export`; | ||
export const STOCKLIST_DELETE = id => `${STOCKLIST_API}/${id}`; | ||
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 = `${API}/glAccountOptions`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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