Skip to content

Commit

Permalink
fix: Payment allocation list currencies. (PanJiaChen#2052)
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt authored Apr 1, 2024
1 parent 6460526 commit b467c29
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 103 deletions.
7 changes: 6 additions & 1 deletion src/api/ADempiere/form/VAllocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* 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
* 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
Expand Down Expand Up @@ -43,6 +43,7 @@ export function listBusinessPartners({
page_size: pageSize,
page_token: pageToken,
// DSL Query
is_only_active_records: true,
search_value: searchValue
}
})
Expand All @@ -63,6 +64,7 @@ export function requestListOrganizations({
page_size: pageSize,
page_token: pageToken,
// DSL Query
is_only_active_records: true,
search_value: searchValue
}
})
Expand All @@ -80,6 +82,7 @@ export function requestListCurrencies({
page_size: pageSize,
page_token: pageToken,
// DSL Query
is_only_active_records: true,
search_value: searchValue
}
})
Expand Down Expand Up @@ -167,6 +170,7 @@ export function requestListCharges({
page_size: pageSize,
page_token: pageToken,
// DSL Query
is_only_active_records: true,
search_value: searchValue
}
})
Expand All @@ -185,6 +189,7 @@ export function requestListTransactionOrganizations({
page_size: pageSize,
page_token: pageToken,
// DSL Query
is_only_active_records: true,
search_value: searchValue
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<template>
<el-form-item
v-if="!isEmptyValue(bPartnerField)"
style="width: 100%;"
:required="true"
>
<template slot="label">
{{ bPartnerField.name }}
<span style="color: #f34b4b"> * </span>
<!-- <span style="color: #f34b4b"> * </span> -->
</template>

<el-select
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<!--
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
style="width: 100%;"
:required="true"
>
<template slot="label">
{{ $t('form.VAllocation.searchCriteria.currency') }}
<!-- <span style="color: #f34b4b"> * </span> -->
</template>

<el-select
v-model="currentCurrencyValue"
clearable
style="width: 100%;"
filterable
:default-first-option="true"
remote
:remote-method="remoteSearchCurrencies"
@visible-change="findCurrencies"
>
<empty-option-select
:current-value="currentCurrencyValue"
/>
<el-option
v-for="item in optionsCurrency"
:key="item.id"
:label="item.label"
:value="item.id"
/>
</el-select>
</el-form-item>
</template>

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

import store from '@/store'

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

// API Request Methods
import {
requestListCurrencies
} from '@/api/ADempiere/form/VAllocation.ts'

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

export default defineComponent({
name: 'CurrencyField',

components: {
EmptyOptionSelect
},

setup() {
const currentCurrencyValue = computed({
// getter
get() {
const { currencyId } = store.getters.getSearchFilter
return currencyId
},
// setter
set(id) {
// store.commit('setCurrency', id)
store.commit('updateAttributeCriteriaVallocation', {
attribute: 'currencyId',
criteria: 'searchCriteria',
value: id
})
}
})

const optionsCurrency = computed({
// getter
get() {
const { listCurrency } = store.getters.getSearchFilter
return listCurrency
},
// setter
set(list) {
store.commit('updateAttributeCriteriaVallocation', {
attribute: 'listCurrency',
criteria: 'searchCriteria',
value: list
})
// store.commit('setBusinessPartner', id)
}
})

function findCurrencies(isFind, searchValue) {
if (!isFind) {
return
}
requestListCurrencies({
searchValue
})
.then(response => {
const { records } = response
optionsCurrency.value = records.map(currency => {
const { id, uuid, values } = currency
return {
id,
uuid,
label: values.DisplayColumn
}
})
})
}

function remoteSearchCurrencies(searchValue) {
// if (!isEmptyValue(searchValue) && searchValue.length > 1) {
// const result = optionsCurrency.value.filter((textValue) => {
// const search = searchValue.toLowerCase()
// return textValue.label.toLowerCase().includes(search)
// })
// if (isEmptyValue(result)) {
// findCurrencies(true, searchValue)
// }
// }
findCurrencies(true, searchValue)
}

return {
// Computeds
currentCurrencyValue,
optionsCurrency,
// Methods
findCurrencies,
remoteSearchCurrencies
}
}
})
</script>
Loading

0 comments on commit b467c29

Please sign in to comment.