1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-12 22:29:59 +08:00

Feature/support pos (#577)

* when cancelled, you must exit the collection window

* when there is no conversion rate it should show the amount receivable in zero
This commit is contained in:
Elsio Sanchez 2021-02-01 22:58:14 -04:00 committed by GitHub
parent 4368cf71c9
commit d83b109aef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 27 deletions

View File

@ -73,9 +73,21 @@ export default {
computed: { computed: {
displayCurrency() { displayCurrency() {
return this.$store.getters.getValueOfField({ return this.$store.getters.getValueOfField({
containerUuid: this.containerUuid, containerUuid: 'Collection-Convert-Amount',
columnName: 'DisplayColumn_C_Currency_ID' columnName: 'DisplayColumn_C_Currency_ID'
}) })
},
typeCurrency() {
return this.$store.getters.getValueOfField({
containerUuid: 'Collection-Convert-Amount',
columnName: 'C_Currency_ID'
})
},
currencyUuid() {
return this.$store.getters.getValueOfField({
containerUuid: 'Collection-Convert-Amount',
columnName: 'C_Currency_ID_UUID'
})
} }
}, },
created() { created() {

View File

@ -34,7 +34,6 @@ export default [
// Bank // Bank
{ {
tableName, tableName,
elementColumnName: 'C_Bank_ID',
columnName: 'C_Bank_ID', columnName: 'C_Bank_ID',
isFromDictionary: true, isFromDictionary: true,
overwriteDefinition: { overwriteDefinition: {

View File

@ -73,7 +73,7 @@
</b> </b>
</el-link> </el-link>
</el-checkbox> </el-checkbox>
<el-button type="danger" icon="el-icon-close" @click="cancel" /> <el-button type="danger" icon="el-icon-close" @click="exit" />
<el-button type="primary" :disabled="validPay || addPay" icon="el-icon-plus" @click="addCollectToList(paymentBox)" /> <el-button type="primary" :disabled="validPay || addPay" icon="el-icon-plus" @click="addCollectToList(paymentBox)" />
<el-button type="success" :disabled="validateCompleteCollection" icon="el-icon-shopping-cart-full" /> <el-button type="success" :disabled="validateCompleteCollection" icon="el-icon-shopping-cart-full" />
</samp> </samp>
@ -233,14 +233,17 @@ export default {
}, },
computed: { computed: {
validateCompleteCollection() { validateCompleteCollection() {
if (this.order.grandTotal === this.pay) { let collection
return false if (this.pay === this.order.grandTotal) {
} else if (this.isCashAmt >= this.change) { collection = false
return false } else {
} else if (this.pay >= this.order.grandTotal && this.checked) { if (this.pay >= this.order.grandTotal && (this.isCashAmt >= this.change) || this.checked) {
return false collection = false
} else {
collection = true
}
} }
return true return collection
}, },
fullCopper() { fullCopper() {
if ((this.change > this.isCashAmt) && this.pay > this.order.grandTotal) { if ((this.change > this.isCashAmt) && this.pay > this.order.grandTotal) {
@ -406,7 +409,7 @@ export default {
}, },
currencyUuid() { currencyUuid() {
return this.$store.getters.getValueOfField({ return this.$store.getters.getValueOfField({
containerUuid: this.containerUuid, containerUuid: 'Collection',
columnName: 'C_Currency_ID_UUID' columnName: 'C_Currency_ID_UUID'
}) })
}, },
@ -419,9 +422,12 @@ export default {
multiplyRate() { multiplyRate() {
return this.$store.getters.getMultiplyRate return this.$store.getters.getMultiplyRate
}, },
multiplyRateCollection() {
return this.$store.getters.getMultiplyRateCollection
},
converCurrency() { converCurrency() {
return this.$store.getters.getValueOfField({ return this.$store.getters.getValueOfField({
containerUuid: 'Collection-Convert-Amount', containerUuid: 'Collection',
columnName: 'C_Currency_ID_UUID' columnName: 'C_Currency_ID_UUID'
}) })
}, },
@ -442,7 +448,7 @@ export default {
return true return true
}, },
fieldpending() { fieldpending() {
return this.pending * this.multiplyRate return this.pending * this.multiplyRateCollection
} }
}, },
watch: { watch: {
@ -470,12 +476,13 @@ export default {
} }
if (!this.isEmptyValue(value)) { if (!this.isEmptyValue(value)) {
this.$store.dispatch('conversionMultiplyRate', { this.$store.dispatch('conversionMultiplyRate', {
containerUuid: 'Collection',
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid, conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid, currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value currencyToUuid: value
}) })
} else { } else {
this.$store.commit('currencyMultiplyRate', 1) this.$store.commit('currencyMultiplyRateCollection', 1)
} }
}, },
convertAllPayment(value) { convertAllPayment(value) {
@ -487,6 +494,7 @@ export default {
converCurrency(value) { converCurrency(value) {
if (!this.isEmptyValue(value)) { if (!this.isEmptyValue(value)) {
this.$store.dispatch('conversionMultiplyRate', { this.$store.dispatch('conversionMultiplyRate', {
containerUuid: 'Collection',
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid, conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid, currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value currencyToUuid: value
@ -632,6 +640,9 @@ export default {
this.$store.dispatch('conversionDivideRate', 1) this.$store.dispatch('conversionDivideRate', 1)
this.$store.commit('currencyMultiplyRate', 1) this.$store.commit('currencyMultiplyRate', 1)
}, },
exit() {
this.$store.commit('setShowPOSCollection', false)
},
getPriceApplyingDiscount(price, discount) { getPriceApplyingDiscount(price, discount) {
if (this.isEmptyValue(price)) { if (this.isEmptyValue(price)) {
price = 0 price = 0

View File

@ -410,7 +410,7 @@ export default {
}, },
currencyUuid() { currencyUuid() {
return this.$store.getters.getValueOfField({ return this.$store.getters.getValueOfField({
containerUuid: this.containerUuid, containerUuid: 'Collection-Convert-Amount',
columnName: 'C_Currency_ID_UUID' columnName: 'C_Currency_ID_UUID'
}) })
}, },
@ -434,6 +434,7 @@ export default {
converCurrency(value) { converCurrency(value) {
if (!this.isEmptyValue(value)) { if (!this.isEmptyValue(value)) {
this.$store.dispatch('conversionMultiplyRate', { this.$store.dispatch('conversionMultiplyRate', {
containerUuid: 'Order',
conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid, conversionTypeUuid: this.$store.getters.getCurrentPOS.conversionTypeUuid,
currencyFromUuid: this.currencyPoint.uuid, currencyFromUuid: this.currencyPoint.uuid,
currencyToUuid: value currencyToUuid: value
@ -449,7 +450,7 @@ export default {
this.newOrder() this.newOrder()
}, },
openCollectionPanel() { openCollectionPanel() {
this.$store.commit('setShowPOSCollection', !this.$store.getters.getShowCollectionPos) this.$store.commit('setShowPOSCollection', true)
this.isShowedPOSKeyLayout = true this.isShowedPOSKeyLayout = true
this.$store.commit('setShowPOSOptions', false) this.$store.commit('setShowPOSOptions', false)
}, },

View File

@ -224,10 +224,12 @@ export default {
containerUuid: this.metadata.containerUuid containerUuid: this.metadata.containerUuid
}) })
values = this.convertValuesToSend(values) values = this.convertValuesToSend(values)
const point = this.$store.getters.getPointOfSalesUuid
this.$store.dispatch('listOrdersFromServer', { if (!this.isEmptyValue(point)) {
...values this.$store.dispatch('listOrdersFromServer', {
}) ...values
})
}
}, },
handleChangePage(newPage) { handleChangePage(newPage) {
this.$store.dispatch('setOrdersListPageNumber', newPage) this.$store.dispatch('setOrdersListPageNumber', newPage)

View File

@ -7,7 +7,9 @@ const collection = {
state: { state: {
paymentBox: [], paymentBox: [],
multiplyRate: 1, multiplyRate: 1,
divideRate: 1 divideRate: 1,
multiplyRateCollection: 1,
divideRateCollection: 1
}, },
mutations: { mutations: {
addPaymentBox(state, paymentBox) { addPaymentBox(state, paymentBox) {
@ -18,6 +20,12 @@ const collection = {
}, },
currencyDivideRate(state, divideRate) { currencyDivideRate(state, divideRate) {
state.divideRate = divideRate state.divideRate = divideRate
},
currencyMultiplyRateCollection(state, multiplyRateCollection) {
state.multiplyRateCollection = multiplyRateCollection
},
currencyDivideRateCollection(state, divideRateCollection) {
state.divideRateCollection = divideRateCollection
} }
}, },
actions: { actions: {
@ -25,12 +33,16 @@ const collection = {
* creating boxes with the payment list * creating boxes with the payment list
*/ */
setPaymentBox({ state, commit, getters }, params) { setPaymentBox({ state, commit, getters }, params) {
const payments = undefined const payments = getters.getPaymentBox.find(element => {
if (params.tenderType === 'X' && element.currency.id === params.currency.id) {
return element
}
})
if (isEmptyValue(payments)) { if (isEmptyValue(payments)) {
commit('addPaymentBox', params) commit('addPaymentBox', params)
} else { } else {
const addPayment = getters.getPaymentBox.map(item => { const addPayment = getters.getPaymentBox.map(item => {
if (item.tenderType === params.tenderType && item.currency.id === params.currency.id) { if ((item.tenderType === params.tenderType) && item.currency.id === params.currency.id) {
return { return {
...item, ...item,
payAmt: item.payAmt + params.payAmt, payAmt: item.payAmt + params.payAmt,
@ -58,7 +70,11 @@ const collection = {
}) })
.then(response => { .then(response => {
const divideRate = isEmptyValue(response.divideRate) ? 1 : response.divideRate const divideRate = isEmptyValue(response.divideRate) ? 1 : response.divideRate
commit('currencyDivideRate', divideRate) if (params.containerUuid === 'Collection') {
commit('currencyDivideRateCollection', divideRate)
} else {
commit('currencyDivideRate', divideRate)
}
}) })
.catch(error => { .catch(error => {
console.warn(`conversionDivideRate: ${error.message}. Code: ${error.code}.`) console.warn(`conversionDivideRate: ${error.message}. Code: ${error.code}.`)
@ -70,6 +86,7 @@ const collection = {
}) })
}, },
conversionMultiplyRate({ commit }, { conversionMultiplyRate({ commit }, {
containerUuid,
conversionTypeUuid, conversionTypeUuid,
currencyFromUuid, currencyFromUuid,
currencyToUuid currencyToUuid
@ -82,9 +99,12 @@ const collection = {
// conversionDate // conversionDate
}) })
.then(response => { .then(response => {
const multiplyRate = isEmptyValue(response.multiplyRate) ? 1 : response.multiplyRate const multiplyRate = isEmptyValue(response.multiplyRate) ? 0 : response.multiplyRate
if (containerUuid === 'Collection') {
commit('currencyMultiplyRate', multiplyRate) commit('currencyMultiplyRateCollection', multiplyRate)
} else {
commit('currencyMultiplyRate', multiplyRate)
}
}) })
.catch(error => { .catch(error => {
console.warn(`conversionMultiplyRate: ${error.message}. Code: ${error.code}.`) console.warn(`conversionMultiplyRate: ${error.message}. Code: ${error.code}.`)
@ -111,6 +131,12 @@ const collection = {
}, },
getDivideRate: (state) => { getDivideRate: (state) => {
return state.divideRate return state.divideRate
},
getMultiplyRateCollection: (state) => {
return state.multiplyRateCollection
},
getDivideRateCollection: (state) => {
return state.divideRateCollection
} }
} }
} }