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

Add option to change warehouse and price list #913

Merged
merged 4 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 84 additions & 4 deletions src/api/ADempiere/form/point-of-sales.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export function createOrder({
posUuid,
customerUuid,
documentTypeUuid,
salesRepresentativeUuid
salesRepresentativeUuid,
warehouseUuid
}) {
return request({
url: `${config.pointOfSales.endpoint}/create-order`,
Expand All @@ -86,7 +87,8 @@ export function createOrder({
pos_uuid: posUuid,
customer_uuid: customerUuid,
document_type_uuid: documentTypeUuid,
sales_representative_uuid: salesRepresentativeUuid
sales_representative_uuid: salesRepresentativeUuid,
warehouse_uuid: warehouseUuid
}
})
.then(createOrderResponse => {
Expand All @@ -101,7 +103,8 @@ export function updateOrder({
orderUuid,
posUuid,
customerUuid,
description
description,
warehouseUuid
}) {
return request({
url: `${config.pointOfSales.endpoint}/update-order`,
Expand All @@ -110,7 +113,8 @@ export function updateOrder({
order_uuid: orderUuid,
pos_uuid: posUuid,
customer_uuid: customerUuid,
description
description,
warehouse_uuid: warehouseUuid
}
})
.then(updateOrderResponse => {
Expand Down Expand Up @@ -637,3 +641,79 @@ export function validatePin({
return pinResponse
})
}

/**
* list Warehouse
* @param {string} posUuidd - POS UUID reference
*/
export function listWarehouse({
posUuid
}) {
return request({
url: `${config.pointOfSales.endpoint}/available-warehouses`,
method: 'get',
params: {
pos_uuid: posUuid
}
})
.then(listWarehouseResponse => {
return listWarehouseResponse
})
}

/**
* List Prices
* @param {string} posUuidd - POS UUID reference
*/
export function listPrices({
posUuid
}) {
return request({
url: `${config.pointOfSales.endpoint}/available-price-list`,
method: 'get',
params: {
pos_uuid: posUuid
}
})
.then(listPricesResponse => {
return listPricesResponse
})
}

/**
* Currencies
* @param {string} posUuidd - POS UUID reference
*/
export function listCurrencies({
posUuid
}) {
return request({
url: `${config.pointOfSales.endpoint}/available-currencies`,
method: 'get',
params: {
pos_uuid: posUuid
}
})
.then(listCurrencies => {
return listCurrencies
})
}

/**
* Tender Type
* @param {string} posUuidd - POS UUID reference
*/
export function listTenderType({
posUuid
}) {
return request({
url: `${config.pointOfSales.endpoint}/available-tender-types`,
method: 'get',
params: {
pos_uuid: posUuid
}
})
.then(listTenderType => {
return listTenderType
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,22 @@ export default {
} else {
this.amountConvertionTotal = this.amount
}
},
currencyUuid(value) {
const listCurrency = this.$store.getters.getConvertionRate.find(currency => {
if (currency.uuid === value) {
return currency
}
})
if (listCurrency === undefined) {
this.$store.dispatch('conversionDivideRate', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.pointOfSalesCurrency.uuid,
conversionDate: this.formatDate(new Date()),
currencyToUuid: value
})
}
}
// currencyUuid(value) {
// const listCurrency = this.$store.getters.getConvertionRate.find(currency => {
// if (currency.uuid === value) {
// return currency
// }
// })
// if (listCurrency === undefined) {
// this.$store.dispatch('conversionDivideRate', {
// conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
// currencyFromUuid: this.pointOfSalesCurrency.uuid,
// conversionDate: this.formatDate(new Date()),
// currencyToUuid: value
// })
// }
// }
},
created() {
this.defaultValueCurrency()
Expand Down
126 changes: 94 additions & 32 deletions src/components/ADempiere/Form/VPOS/Collection/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,24 @@
<b>{{ $t('form.pos.collect.dayRate') }}:</b>
<!-- Conversion rate to date -->
<b v-if="!isEmptyValue(dateRate)" style="float: right;">
<span v-if="formatConversionCurrenty(dateRate.amountConvertion) > 100">
{{
formatPrice(formatConversionCurrenty(dateRate.amountConvertion), dateRate.iSOCode)
}}
<span v-if="!isEmptyValue(dateRate.divideRate)">
<span v-if="formatConversionCurrenty(dateRate.divideRate) > 1">
{{
formatPrice(formatConversionCurrenty(dateRate.divideRate), dateRate.currencyTo.iSOCode)
}}
</span>
<span v-else>
{{
dateRate.currencyTo.iSOCode
}}
{{
formatConversionCurrenty(dateRate.divideRate)
}}
</span>
</span>
<span v-else>
{{
dateRate.iSOCode
}}
{{
formatConversionCurrenty(dateRate.amountConvertion)
formatPrice(1, dateRate.iSOCode)
}}
</span>
</b>
Expand All @@ -93,10 +100,38 @@
<el-col v-for="(field, index) in fieldsList" :key="index" :span="8">
<!-- Add selected currency symbol -->
<field-definition
v-if="field.columnName === 'PayAmt' || field.columnName === 'TenderType'"
:key="field.columnName"
:metadata-field="field.columnName === 'PayAmt' ? {
...field,
labelCurrency: dateRate
labelCurrency: isEmptyValue(dateRate.divideRate) ? dateRate : dateRate.currencyTo
} : field"
/>
</el-col>
<el-col :span="8">
<el-form-item :label="fieldsList[1].name">
<el-select
v-model="currentFieldCurrency"
:placeholder="fieldsList[1].help"
@change="changeCurrency"
>
<el-option
v-for="item in listCurrency"
:key="item.id"
:label="item.name"
:value="item.key"
/>
</el-select>
</el-form-item>
</el-col>
<el-col v-for="(field, index) in fieldsList" :key="index" :span="8">
<!-- Add selected currency symbol -->
<field-definition
v-if="field.columnName !== 'PayAmt' && field.columnName !== 'TenderType' && field.columnName !== 'C_Currency_ID'"
:key="field.columnName"
:metadata-field="field.columnName === 'PayAmt' ? {
...field,
labelCurrency: isEmptyValue(dateRate.divideRate) ? dateRate : dateRate.currencyTo
} : field"
/>
</el-col>
Expand Down Expand Up @@ -272,10 +307,18 @@ export default {
defaultLabel: '',
fieldsList: fieldsListCollection,
sendToServer: false,
amontSend: 0
value: '',
amontSend: 0,
currentFieldCurrency: ''
}
},
computed: {
listCurrency() {
return this.$store.state['pointOfSales/point/index'].listCurrency
},
convertionList() {
return this.$store.state['pointOfSales/point/index'].conversionList
},
validateCompleteCollection() {
let collection
if (this.pay === this.currentOrder.grandTotal) {
Expand Down Expand Up @@ -488,11 +531,15 @@ export default {
return this.$store.getters.getUpdatePaymentPos
},
dateRate() {
return this.$store.getters.getConvertionRate.find(currency => {
if (currency.id === this.typeCurrency) {
const convertion = this.convertionList.find(currency => {
if ((currency.currencyTo.iSOCode === this.currentFieldCurrency) && (this.pointOfSalesCurrency.iSOCode !== currency.currencyTo.iSOCode)) {
return currency
}
})
if (!this.isEmptyValue(convertion)) {
return convertion
}
return this.pointOfSalesCurrency
},
fieldsPaymentType() {
return this.fieldsList[2]
Expand All @@ -503,24 +550,24 @@ export default {
this.$store.commit('updateValueOfField', {
containerUuid: this.containerUuid,
columnName: 'PayAmt',
value
})
},
currencyUuid(value) {
const listCurrency = this.$store.getters.getConvertionRate.find(currency => {
if (currency.uuid === value) {
return currency
}
})
if (listCurrency === undefined) {
this.$store.dispatch('conversionDivideRate', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.pointOfSalesCurrency.uuid,
conversionDate: this.formatDate(new Date()),
currencyToUuid: value
})
}
},
value: value
})
},
// currencyUuid(value) {
// const listCurrency = this.$store.getters.getConvertionRate.find(currency => {
// if (currency.uuid === value) {
// return currency
// }
// })
// if (listCurrency === undefined) {
// this.$store.dispatch('conversionDivideRate', {
// conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
// currencyFromUuid: this.pointOfSalesCurrency.uuid,
// conversionDate: this.formatDate(new Date()),
// currencyToUuid: value
// })
// }
// },
convertAllPayment(value) {
if (!this.isEmptyValue(value)) {
this.allPayCurrency = this.pay / value
Expand All @@ -537,11 +584,11 @@ export default {
}
},
dateRate(value) {
if (value && !this.isEmptyValue(value.amountConvertion)) {
if (!this.isEmptyValue(value.divideRate)) {
this.$store.commit('updateValueOfField', {
containerUuid: this.containerUuid,
columnName: 'PayAmt',
value: this.pending / value.amountConvertion
value: this.pending / value.divideRate
})
} else {
this.$store.commit('updateValueOfField', {
Expand All @@ -565,6 +612,7 @@ export default {
}
},
created() {
this.currentFieldCurrency = this.pointOfSalesCurrency.iSOCode
this.$store.dispatch('addRateConvertion', this.pointOfSalesCurrency)
this.unsubscribe = this.subscribeChanges()
this.defaultValueCurrency()
Expand Down Expand Up @@ -724,6 +772,7 @@ export default {
this.defaultValueCurrency()
this.$store.commit('currencyDivideRateCollection', 1)
this.$store.commit('currencyMultiplyRate', 1)
this.currentFieldCurrency = this.pointOfSalesCurrency.iSOCode
},
exit() {
this.$store.commit('setShowPOSCollection', false)
Expand Down Expand Up @@ -865,6 +914,19 @@ export default {
}
}
})
},
changeCurrency(value) {
this.currentFieldCurrency = value
const currency = this.listCurrency.find(currency => currency.key === value)
const findCoventionList = this.convertionList.find(convertion => convertion.currencyTo.iSOCode === value)
if (!this.isEmptyValue(currency) && this.isEmptyValue(findCoventionList) && (value !== this.pointOfSalesCurrency.iSOCode)) {
this.$store.dispatch('searchConversion', {
conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
currencyFromUuid: this.pointOfSalesCurrency.uuid,
conversionDate: this.formatDate(new Date()),
currencyToUuid: currency.uuid
})
}
}
}
}
Expand Down
Loading