302302import formMixin from ' @/components/ADempiere/Form/formMixin.js'
303303import orderLineMixin from ' ./orderLineMixin.js'
304304import fieldsListOrder from ' ./fieldsListOrder.js'
305- import posMixin from ' @/components/ADempiere/Form/VPOS/posMixin.js'
306305import BusinessPartner from ' @/components/ADempiere/Form/VPOS/BusinessPartner'
307306import fieldLine from ' @/components/ADempiere/Form/VPOS/Order/line/index'
308307import ProductInfo from ' @/components/ADempiere/Form/VPOS/ProductInfo'
309308import 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
311316export 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}
0 commit comments