Skip to content

Commit

Permalink
feat: Add search product only stock available.
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt committed Oct 9, 2024
1 parent ad74018 commit 3344f95
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/api/ADempiere/fields/search/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ export function requestListProducts({
upc,
sku,
is_stocked,
is_only_stock_available,
product_group_id,
product_class_id,
product_category_id,
Expand Down Expand Up @@ -335,6 +336,7 @@ export function requestListProducts({
sku,
upc,
is_stocked,
is_only_stock_available,
product_group_id,
product_class_id,
product_category_id,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<!--
ADempiere-Vue (Frontend) for ADempiere ERP & CRM Smart Business Solution
Copyright (C) 2018-Present E.R.P. Consultores y Asociados, C.A. www.erpya.com
Contributor(s): Edwin Betancourt EdwinBetanc0urt@outlook.com https://github.com/EdwinBetanc0urt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https:www.gnu.org/licenses/>.
-->

<template>
<el-form-item
:label="$t('field.product.onlyOnHand')"
>
<el-select
v-model="currentValue"
:disabled="!isStockQuantities"
clearable
>
<!--
<empty-option-select
:current-value="currentValue"
:is-allows-zero="false"
/>
-->
<!-- :disabled="isDisabled" -->
<el-option
v-for="(option, key) in YES_NO_OPTIONS_LIST"
:key="key"
:value="option.booleanValue"
:label="option.displayValue"
/>
</el-select>
</el-form-item>
</template>

<script>
import { computed, defineComponent } from '@vue/composition-api'

import store from '@/store'

// Constants
import { YES_NO_OPTIONS_LIST } from '@/utils/ADempiere/dictionary/field/yesNo'

// Components and Mixins
import EmptyOptionSelect from '@/components/ADempiere/FieldDefinition/FieldSelect/emptyOptionSelect.vue'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'

export default defineComponent({
name: 'IsOnlyOnHandField',

components: {
EmptyOptionSelect
},

props: {
uuidForm: {
required: true,
type: String
},
parentUuid: {
type: String,
default: undefined
},
containerUuid: {
required: false,
type: String
}
},

setup(props) {
const ATTRIBUTE_KEY = 'is_only_stock_available'

const currentValue = computed({
set(newValue) {
store.commit('setProductSearchFieldQueryFilterByAttribute', {
containerUuid: props.uuidForm,
attributeKey: ATTRIBUTE_KEY,
value: newValue
})
},
get() {
return store.getters.getProductSearchFieldQueryFilterByAttribute({
containerUuid: props.uuidForm,
attributeKey: ATTRIBUTE_KEY
})
}
})

// const isDisabled = computed(() => {
// const warehouseId = store.getters.getProductSearchFieldQueryFilterByAttribute({
// containerUuid: props.uuidForm,
// attributeKey: 'warehouse_id'
// })
// return isEmptyValue(warehouseId) || warehouseId <= 0
// })

const getWarehouseId = computed(() => {
return store.getters.getProductSearchFieldQueryFilterByAttribute({
containerUuid: props.uuidForm,
attributeKey: 'warehouse_id'
})
})
const isStockQuantities = computed(() => {
return !isEmptyValue(getWarehouseId.value) && getWarehouseId.value > 0
})

return {
YES_NO_OPTIONS_LIST,
//
currentValue,
isStockQuantities
// isDisabled
}
}
})
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ import store from '@/store'
// Constants
import { YES_NO_OPTIONS_LIST } from '@/utils/ADempiere/dictionary/field/yesNo'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
// Components and Mixins
import EmptyOptionSelect from '@/components/ADempiere/FieldDefinition/FieldSelect/emptyOptionSelect.vue'

export default defineComponent({
name: 'IsStokedField',

components: {
EmptyOptionSelect
},

props: {
uuidForm: {
required: true,
Expand All @@ -69,7 +73,6 @@ export default defineComponent({

const currentValue = computed({
set(newValue) {
if (isEmptyValue(newValue)) newValue = -1
store.commit('setProductSearchFieldQueryFilterByAttribute', {
containerUuid: props.uuidForm,
attributeKey: ATTRIBUTE_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import store from '@/store'

// Components and Mixins
import EmptyOptionSelect from '@/components/ADempiere/FieldDefinition/FieldSelect/emptyOptionSelect.vue'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'

Expand Down Expand Up @@ -83,7 +84,15 @@ export default defineComponent({

const currentValue = computed({
set(newValue) {
if (isEmptyValue(newValue)) newValue = -1
if (isEmptyValue(newValue)) {
newValue = -1

store.commit('setProductSearchFieldQueryFilterByAttribute', {
containerUuid: props.uuidForm,
attributeKey: 'is_only_stock_available',
value: false
})
}
store.commit('setProductSearchFieldQueryFilterByAttribute', {
containerUuid: props.uuidForm,
attributeKey: ATTRIBUTE_KEY,
Expand Down
20 changes: 17 additions & 3 deletions src/components/ADempiere/Form/ProductSearch/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,14 @@ export default defineComponent({
})
})

const isStockQuantities = computed(() => {
const getIsOnlyStockAvailable = computed(() => {
return store.getters.getProductSearchFieldQueryFilterByAttribute({
containerUuid: uuidForm,
attributeKey: 'is_only_stock_available'
})
})

const getWarehouseId = computed(() => {
return store.getters.getProductSearchFieldQueryFilterByAttribute({
containerUuid: uuidForm,
attributeKey: 'warehouse_id'
Expand Down Expand Up @@ -567,7 +574,13 @@ export default defineComponent({
}
})

watch(isStockQuantities, (newValue, oldValue) => {
watch(getIsOnlyStockAvailable, (newValue, oldValue) => {
if (newValue !== oldValue) {
searchProduct()
}
})

watch(getWarehouseId, (newValue, oldValue) => {
if (newValue !== oldValue) {
searchProduct()
}
Expand Down Expand Up @@ -603,8 +616,9 @@ export default defineComponent({
listProducto,
recordCount,
getIsStocked,
getIsOnlyStockAvailable,
getVendorId,
isStockQuantities,
getWarehouseId,
getPriceListVersion,
getProductCategoryField,
getProductClassField,
Expand Down
11 changes: 10 additions & 1 deletion src/components/ADempiere/Form/ProductSearch/queryCriteria.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@
:uuid-form="uuidForm"
/>
</el-col>
<el-col :span="6">
<el-col :span="3">
<is-stocked-field
:uuid-form="uuidForm"
/>
</el-col>
<el-col :span="3">
<is-only-on-hand-field
:uuid-form="uuidForm"
/>
</el-col>
<el-col :span="6">
<price-list-version-field
:uuid-form="uuidForm"
Expand Down Expand Up @@ -84,11 +89,14 @@

<script>
import { defineComponent, ref, computed } from '@vue/composition-api'

import store from '@/store'

// Components and Mixins
import VendorField from '@/components/ADempiere/FieldDefinition/FieldSearch/ProductInfo/PanelForm/QueryCriteria/vendorField.vue'
import WarehouseField from '@/components/ADempiere/FieldDefinition/FieldSearch/ProductInfo/PanelForm/QueryCriteria/warehouseField.vue'
import IsStockedField from '@/components/ADempiere/FieldDefinition/FieldSearch/ProductInfo/PanelForm/QueryCriteria/isStockedField.vue'
import IsOnlyOnHandField from '@/components/ADempiere/FieldDefinition/FieldSearch/ProductInfo/PanelForm/QueryCriteria/isOnlyOnHandField.vue'
import PriceListVersionField from '@/components/ADempiere/FieldDefinition/FieldSearch/ProductInfo/PanelForm/QueryCriteria/priceListVersionField.vue'
import ProductCategoryField from '@/components/ADempiere/FieldDefinition/FieldSearch/ProductInfo/PanelForm/QueryCriteria/productCategoryField.vue'
import ProductClassField from '@/components/ADempiere/FieldDefinition/FieldSearch/ProductInfo/PanelForm/QueryCriteria/productClassField.vue'
Expand All @@ -102,6 +110,7 @@ export default defineComponent({
VendorField,
WarehouseField,
IsStockedField,
IsOnlyOnHandField,
ProductClassField,
ProductGroupField,
ProductCategoryField,
Expand Down
1 change: 1 addition & 0 deletions src/lang/ADempiere/en/field/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const product = {
margin: 'Margin',
// quantity
stocked: 'Stocked',
onlyOnHand: 'Only On Hand',
available: 'Available',
onHandQuantity: 'On Hand Qty',
reservedQuantity: 'Reserved Qty',
Expand Down
1 change: 1 addition & 0 deletions src/lang/ADempiere/es/field/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const product = {
margin: 'Margen',
// quantity
stocked: 'Almacenado',
onlyOnHand: 'Solo Disponible',
available: 'Cant. Disponible',
onHandQuantity: 'Cant. Existencia',
reservedQuantity: 'Cant. Reservada',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const emptyQueryFilters = {
price_list_version_id: undefined,
warehouse_id: undefined,
is_stocked: undefined,
is_only_stock_available: false,
attribute_set_id: undefined,
attribute_set_instance_id: undefined,
vendor_id: undefined,
Expand Down

0 comments on commit 3344f95

Please sign in to comment.