Skip to content

Commit e831205

Browse files
elsiosanchezelsiosanchez
andauthored
Bugfix/reload product price (#850)
* Reload Product Price * minimal change * Format of values ( Date, Price, Quantity ) Co-authored-by: elsiosanchez <elsiossanches@gmail.com>
1 parent 8da6ff7 commit e831205

File tree

2 files changed

+139
-35
lines changed
  • src
    • components/ADempiere/Form/VPOS/Order
    • store/modules/ADempiere/pointOfSales/point

2 files changed

+139
-35
lines changed

src/components/ADempiere/Form/VPOS/Order/index.vue

Lines changed: 139 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,16 @@
302302
import formMixin from '@/components/ADempiere/Form/formMixin.js'
303303
import orderLineMixin from './orderLineMixin.js'
304304
import fieldsListOrder from './fieldsListOrder.js'
305-
import posMixin from '@/components/ADempiere/Form/VPOS/posMixin.js'
306305
import BusinessPartner from '@/components/ADempiere/Form/VPOS/BusinessPartner'
307306
import fieldLine from '@/components/ADempiere/Form/VPOS/Order/line/index'
308307
import ProductInfo from '@/components/ADempiere/Form/VPOS/ProductInfo'
309308
import convertAmount from '@/components/ADempiere/Form/VPOS/Collection/convertAmount/index'
309+
// Format of values ( Date, Price, Quantity )
310+
import {
311+
formatDate,
312+
formatPrice,
313+
formatQuantity
314+
} from '@/utils/ADempiere/valueFormat.js'
310315
311316
export default {
312317
name: 'Order',
@@ -318,8 +323,7 @@ export default {
318323
},
319324
mixins: [
320325
formMixin,
321-
orderLineMixin,
322-
posMixin
326+
orderLineMixin
323327
],
324328
data() {
325329
return {
@@ -393,37 +397,72 @@ export default {
393397
},
394398
labelButtonCollections() {
395399
return this.isDisabled ? this.$t('form.pos.order.collections') : this.$t('form.pos.order.collect')
400+
},
401+
currentPointOfSales() {
402+
return this.$store.getters.posAttributes.currentPointOfSales
403+
},
404+
// Currency Point Of Sales
405+
pointOfSalesCurrency() {
406+
// const currency = this.currentPointOfSales
407+
if (!this.isEmptyValue(this.currentPointOfSales.priceList)) {
408+
return {
409+
...this.currentPointOfSales.priceList.currency,
410+
amountConvertion: 1
411+
}
412+
}
413+
return {
414+
uuid: '',
415+
iSOCode: '',
416+
curSymbol: '',
417+
amountConvertion: 1
418+
}
419+
},
420+
listPointOfSales() {
421+
return this.$store.getters.posAttributes.listPointOfSales
422+
},
423+
ordersList() {
424+
if (this.isEmptyValue(this.currentPointOfSales)) {
425+
return []
426+
}
427+
return this.currentPointOfSales.listOrder
428+
},
429+
currentOrder() {
430+
if (this.isEmptyValue(this.currentPointOfSales)) {
431+
return {
432+
documentType: {},
433+
documentStatus: {
434+
value: ''
435+
},
436+
totalLines: 0,
437+
grandTotal: 0,
438+
salesRepresentative: {},
439+
businessPartner: {
440+
value: '',
441+
uuid: ''
442+
}
443+
}
444+
}
445+
return this.currentPointOfSales.currentOrder
446+
},
447+
isDisabled() {
448+
return this.currentPointOfSales.currentOrder.isProcessed
449+
},
450+
listOrderLine() {
451+
if (this.isEmptyValue(this.currentOrder)) {
452+
return []
453+
}
454+
return this.currentOrder.lineOrder
396455
}
397456
},
398-
// watch: {
399-
// currencyUuid(value) {
400-
// if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPointOfSales)) {
401-
// this.$store.dispatch('conversionDivideRate', {
402-
// conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
403-
// currencyFromUuid: this.pointOfSalesCurrency.uuid,
404-
// currencyToUuid: value
405-
// })
406-
// }
407-
// },
408-
// converCurrency(value) {
409-
// if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPointOfSales)) {
410-
// this.$store.dispatch('conversionMultiplyRate', {
411-
// containerUuid: 'Order',
412-
// conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
413-
// currencyFromUuid: this.pointOfSalesCurrency.uuid,
414-
// currencyToUuid: value
415-
// })
416-
// } else {
417-
// this.$store.commit('currencyMultiplyRate', 1)
418-
// }
419-
// }
420-
// },
421457
mounted() {
422458
if (!this.isEmptyValue(this.$route.query.action)) {
423459
this.$store.dispatch('reloadOrder', { orderUuid: this.$route.query.action })
424460
}
425461
},
426462
methods: {
463+
formatDate,
464+
formatPrice,
465+
formatQuantity,
427466
openCollectionPanel() {
428467
this.isShowedPOSKeyLayout = !this.isShowedPOSKeyLayout
429468
this.$store.commit('setShowPOSCollection', true)
@@ -436,6 +475,80 @@ export default {
436475
if (!this.seeConversion) {
437476
this.seeConversion = true
438477
}
478+
},
479+
getOrderTax(currency) {
480+
return this.formatPrice(this.currentOrder.grandTotal - this.currentOrder.totalLines, currency)
481+
},
482+
newOrder() {
483+
this.$router.push({
484+
params: {
485+
...this.$route.params
486+
},
487+
query: {
488+
pos: this.currentPointOfSales.id
489+
}
490+
}).catch(() => {
491+
}).finally(() => {
492+
this.$store.commit('setListPayments', [])
493+
const { templateBusinessPartner } = this.currentPointOfSales
494+
this.$store.commit('updateValuesOfContainer', {
495+
containerUuid: this.metadata.containerUuid,
496+
attributes: [{
497+
columnName: 'UUID',
498+
value: undefined
499+
},
500+
{
501+
columnName: 'ProductValue',
502+
value: undefined
503+
},
504+
{
505+
columnName: 'C_BPartner_ID',
506+
value: templateBusinessPartner.id
507+
},
508+
{
509+
columnName: 'DisplayColumn_C_BPartner_ID',
510+
value: templateBusinessPartner.name
511+
},
512+
{
513+
columnName: ' C_BPartner_ID_UUID',
514+
value: templateBusinessPartner.uuid
515+
}]
516+
})
517+
this.$store.dispatch('setOrder', {
518+
documentType: {},
519+
documentStatus: {
520+
value: ''
521+
},
522+
totalLines: 0,
523+
grandTotal: 0,
524+
salesRepresentative: {},
525+
businessPartner: {
526+
value: '',
527+
uuid: ''
528+
}
529+
})
530+
this.$store.commit('setShowPOSCollection', false)
531+
this.$store.dispatch('listOrderLine', [])
532+
})
533+
},
534+
changePos(posElement) {
535+
this.$store.dispatch('setCurrentPOS', posElement)
536+
this.newOrder()
537+
},
538+
arrowTop() {
539+
if (this.currentTable > 0) {
540+
this.currentTable--
541+
this.$refs.linesTable.setCurrentRow(this.listOrderLine[this.currentTable])
542+
this.currentOrderLine = this.listOrderLine[this.currentTable]
543+
}
544+
},
545+
arrowBottom() {
546+
const top = this.listOrderLine.length - 1
547+
if (this.currentTable < top) {
548+
this.currentTable++
549+
this.$refs.linesTable.setCurrentRow(this.listOrderLine[this.currentTable])
550+
this.currentOrderLine = this.listOrderLine[this.currentTable]
551+
}
439552
}
440553
}
441554
}

src/store/modules/ADempiere/pointOfSales/point/actions.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export default {
6060
},
6161
setCurrentPOS({ commit, dispatch }, posToSet) {
6262
commit('currentPointOfSales', posToSet)
63-
const currentPOS = posToSet
6463
const oldRoute = router.app._route
6564
router.push({
6665
name: oldRoute.name,
@@ -78,13 +77,5 @@ export default {
7877
commit('setIsReloadProductPrice')
7978
commit('setIsReloadListOrders')
8079
commit('setShowPOSKeyLayout', false)
81-
82-
// Maintain Order and Product List
83-
dispatch('listOrdersFromServer', {
84-
posUuid: currentPOS.uuid
85-
})
86-
dispatch('listProductPriceFromServer', {
87-
currentPOS
88-
})
8980
}
9081
}

0 commit comments

Comments
 (0)