Skip to content

Commit

Permalink
Bugfix/reload product price (#850)
Browse files Browse the repository at this point in the history
* Reload Product Price

* minimal change

* Format of values ( Date, Price, Quantity )

Co-authored-by: elsiosanchez <[email protected]>
  • Loading branch information
elsiosanchez and elsiosanchez authored May 14, 2021
1 parent 8da6ff7 commit e831205
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 35 deletions.
165 changes: 139 additions & 26 deletions src/components/ADempiere/Form/VPOS/Order/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,16 @@
import formMixin from '@/components/ADempiere/Form/formMixin.js'
import orderLineMixin from './orderLineMixin.js'
import fieldsListOrder from './fieldsListOrder.js'
import posMixin from '@/components/ADempiere/Form/VPOS/posMixin.js'
import BusinessPartner from '@/components/ADempiere/Form/VPOS/BusinessPartner'
import fieldLine from '@/components/ADempiere/Form/VPOS/Order/line/index'
import ProductInfo from '@/components/ADempiere/Form/VPOS/ProductInfo'
import convertAmount from '@/components/ADempiere/Form/VPOS/Collection/convertAmount/index'
// Format of values ( Date, Price, Quantity )
import {
formatDate,
formatPrice,
formatQuantity
} from '@/utils/ADempiere/valueFormat.js'

export default {
name: 'Order',
Expand All @@ -318,8 +323,7 @@ export default {
},
mixins: [
formMixin,
orderLineMixin,
posMixin
orderLineMixin
],
data() {
return {
Expand Down Expand Up @@ -393,37 +397,72 @@ export default {
},
labelButtonCollections() {
return this.isDisabled ? this.$t('form.pos.order.collections') : this.$t('form.pos.order.collect')
},
currentPointOfSales() {
return this.$store.getters.posAttributes.currentPointOfSales
},
// Currency Point Of Sales
pointOfSalesCurrency() {
// const currency = this.currentPointOfSales
if (!this.isEmptyValue(this.currentPointOfSales.priceList)) {
return {
...this.currentPointOfSales.priceList.currency,
amountConvertion: 1
}
}
return {
uuid: '',
iSOCode: '',
curSymbol: '',
amountConvertion: 1
}
},
listPointOfSales() {
return this.$store.getters.posAttributes.listPointOfSales
},
ordersList() {
if (this.isEmptyValue(this.currentPointOfSales)) {
return []
}
return this.currentPointOfSales.listOrder
},
currentOrder() {
if (this.isEmptyValue(this.currentPointOfSales)) {
return {
documentType: {},
documentStatus: {
value: ''
},
totalLines: 0,
grandTotal: 0,
salesRepresentative: {},
businessPartner: {
value: '',
uuid: ''
}
}
}
return this.currentPointOfSales.currentOrder
},
isDisabled() {
return this.currentPointOfSales.currentOrder.isProcessed
},
listOrderLine() {
if (this.isEmptyValue(this.currentOrder)) {
return []
}
return this.currentOrder.lineOrder
}
},
// watch: {
// currencyUuid(value) {
// if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPointOfSales)) {
// this.$store.dispatch('conversionDivideRate', {
// conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
// currencyFromUuid: this.pointOfSalesCurrency.uuid,
// currencyToUuid: value
// })
// }
// },
// converCurrency(value) {
// if (!this.isEmptyValue(value) && !this.isEmptyValue(this.currentPointOfSales)) {
// this.$store.dispatch('conversionMultiplyRate', {
// containerUuid: 'Order',
// conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
// currencyFromUuid: this.pointOfSalesCurrency.uuid,
// currencyToUuid: value
// })
// } else {
// this.$store.commit('currencyMultiplyRate', 1)
// }
// }
// },
mounted() {
if (!this.isEmptyValue(this.$route.query.action)) {
this.$store.dispatch('reloadOrder', { orderUuid: this.$route.query.action })
}
},
methods: {
formatDate,
formatPrice,
formatQuantity,
openCollectionPanel() {
this.isShowedPOSKeyLayout = !this.isShowedPOSKeyLayout
this.$store.commit('setShowPOSCollection', true)
Expand All @@ -436,6 +475,80 @@ export default {
if (!this.seeConversion) {
this.seeConversion = true
}
},
getOrderTax(currency) {
return this.formatPrice(this.currentOrder.grandTotal - this.currentOrder.totalLines, currency)
},
newOrder() {
this.$router.push({
params: {
...this.$route.params
},
query: {
pos: this.currentPointOfSales.id
}
}).catch(() => {
}).finally(() => {
this.$store.commit('setListPayments', [])
const { templateBusinessPartner } = this.currentPointOfSales
this.$store.commit('updateValuesOfContainer', {
containerUuid: this.metadata.containerUuid,
attributes: [{
columnName: 'UUID',
value: undefined
},
{
columnName: 'ProductValue',
value: undefined
},
{
columnName: 'C_BPartner_ID',
value: templateBusinessPartner.id
},
{
columnName: 'DisplayColumn_C_BPartner_ID',
value: templateBusinessPartner.name
},
{
columnName: ' C_BPartner_ID_UUID',
value: templateBusinessPartner.uuid
}]
})
this.$store.dispatch('setOrder', {
documentType: {},
documentStatus: {
value: ''
},
totalLines: 0,
grandTotal: 0,
salesRepresentative: {},
businessPartner: {
value: '',
uuid: ''
}
})
this.$store.commit('setShowPOSCollection', false)
this.$store.dispatch('listOrderLine', [])
})
},
changePos(posElement) {
this.$store.dispatch('setCurrentPOS', posElement)
this.newOrder()
},
arrowTop() {
if (this.currentTable > 0) {
this.currentTable--
this.$refs.linesTable.setCurrentRow(this.listOrderLine[this.currentTable])
this.currentOrderLine = this.listOrderLine[this.currentTable]
}
},
arrowBottom() {
const top = this.listOrderLine.length - 1
if (this.currentTable < top) {
this.currentTable++
this.$refs.linesTable.setCurrentRow(this.listOrderLine[this.currentTable])
this.currentOrderLine = this.listOrderLine[this.currentTable]
}
}
}
}
Expand Down
9 changes: 0 additions & 9 deletions src/store/modules/ADempiere/pointOfSales/point/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export default {
},
setCurrentPOS({ commit, dispatch }, posToSet) {
commit('currentPointOfSales', posToSet)
const currentPOS = posToSet
const oldRoute = router.app._route
router.push({
name: oldRoute.name,
Expand All @@ -78,13 +77,5 @@ export default {
commit('setIsReloadProductPrice')
commit('setIsReloadListOrders')
commit('setShowPOSKeyLayout', false)

// Maintain Order and Product List
dispatch('listOrdersFromServer', {
posUuid: currentPOS.uuid
})
dispatch('listProductPriceFromServer', {
currentPOS
})
}
}

0 comments on commit e831205

Please sign in to comment.