support price checking (#930)
* support price checking * correcting comments Co-authored-by: elsiosanchez <elsiossanches@gmail.com>pull/3759/head
							parent
							
								
									9b64e66722
								
							
						
					
					
						commit
						587e8cb9c1
					
				| 
						 | 
				
			
			@ -73,7 +73,7 @@
 | 
			
		|||
 | 
			
		||||
              <div class="product-price amount">
 | 
			
		||||
                <span style="float: right;"> {{ formatPrice(productPrice.grandTotal, productPrice.currency.iSOCode) }} </span> <br>
 | 
			
		||||
                {{ formatPrice(productPrice.schemaGrandTotal, productPrice.schemaCurrency.iSOCode) }}
 | 
			
		||||
                <span v-if="!isEmptyValue(currentPointOfSales.displayCurrency)"> {{ formatPrice(productPrice.grandTotalConverted, currentPointOfSales.displayCurrency.iSOCode) }}</span>
 | 
			
		||||
              </div>
 | 
			
		||||
            </el-col>
 | 
			
		||||
          </el-row>
 | 
			
		||||
| 
						 | 
				
			
			@ -133,8 +133,17 @@ export default {
 | 
			
		|||
    defaultImage() {
 | 
			
		||||
      return require('@/image/ADempiere/priceChecking/no-image.jpg')
 | 
			
		||||
    },
 | 
			
		||||
    currentPoint() {
 | 
			
		||||
    currentPointOfSales() {
 | 
			
		||||
      return this.$store.getters.posAttributes.currentPointOfSales
 | 
			
		||||
    },
 | 
			
		||||
    pointOfSalesList() {
 | 
			
		||||
      return this.$store.getters.posAttributes.pointOfSalesList
 | 
			
		||||
    },
 | 
			
		||||
    convertionsList() {
 | 
			
		||||
      return this.$store.state['pointOfSales/point/index'].conversionsList
 | 
			
		||||
    },
 | 
			
		||||
    currentConvertion() {
 | 
			
		||||
      return this.convertionsList.find(convert => convert.currencyTo.id === this.currentPointOfSales.displayCurrency.id)
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  created() {
 | 
			
		||||
| 
						 | 
				
			
			@ -143,12 +152,23 @@ export default {
 | 
			
		|||
  mounted() {
 | 
			
		||||
    this.backgroundForm = this.defaultImage
 | 
			
		||||
    this.getImageFromSource(this.organizationImagePath)
 | 
			
		||||
    this.$store.dispatch('listPointOfSalesFromServer')
 | 
			
		||||
    if (this.isEmptyValue(this.pointOfSalesList)) {
 | 
			
		||||
      this.$store.dispatch('listPointOfSalesFromServer')
 | 
			
		||||
    }
 | 
			
		||||
    if (!this.isEmptyValue(this.pointOfSalesList) && this.isEmptyValue(this.currentConvertion)) {
 | 
			
		||||
      this.$store.dispatch('searchConversion', {
 | 
			
		||||
        conversionTypeUuid: this.currentPointOfSales.conversionTypeUuid,
 | 
			
		||||
        currencyFromUuid: this.currentPointOfSales.priceList.currency.uuid,
 | 
			
		||||
        currencyToUuid: this.currentPointOfSales.displayCurrency.uuid
 | 
			
		||||
      })
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  beforeDestroy() {
 | 
			
		||||
    this.unsubscribe()
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    formatPercent,
 | 
			
		||||
    formatPrice,
 | 
			
		||||
    focusProductValue() {
 | 
			
		||||
      if (!this.isEmptyValue(this.$refs.ProductValue[0])) {
 | 
			
		||||
        this.$refs.ProductValue[0].$children[0].$children[0].$children[1].$children[0].focus()
 | 
			
		||||
| 
						 | 
				
			
			@ -165,8 +185,10 @@ export default {
 | 
			
		|||
      })
 | 
			
		||||
      this.backgroundForm = image.uri
 | 
			
		||||
    },
 | 
			
		||||
    formatPercent,
 | 
			
		||||
    formatPrice,
 | 
			
		||||
    amountConvert(price, currency) {
 | 
			
		||||
      const convertion = this.convertionsList.find(convert => convert.currencyTo.id === currency.id)
 | 
			
		||||
      return price / convertion.divideRate
 | 
			
		||||
    },
 | 
			
		||||
    subscribeChanges() {
 | 
			
		||||
      return this.$store.subscribe((mutation, state) => {
 | 
			
		||||
        if ((mutation.type === 'currentPointOfSales') || (mutation.type === 'setListProductPrice') || (mutation.type === 'addFocusLost')) {
 | 
			
		||||
| 
						 | 
				
			
			@ -178,7 +200,7 @@ export default {
 | 
			
		|||
          if (!this.isEmptyValue(this.search) && this.search.length >= 4) {
 | 
			
		||||
            getProductPrice({
 | 
			
		||||
              searchValue: mutation.payload.value,
 | 
			
		||||
              priceListUuid: this.currentPoint.priceList.uuid
 | 
			
		||||
              posUuid: this.currentPointOfSales.uuid
 | 
			
		||||
            })
 | 
			
		||||
              .then(productPrice => {
 | 
			
		||||
                this.messageError = true
 | 
			
		||||
| 
						 | 
				
			
			@ -191,16 +213,12 @@ export default {
 | 
			
		|||
                  image,
 | 
			
		||||
                  grandTotal: this.getGrandTotal(priceBase, rate),
 | 
			
		||||
                  productName: product.name,
 | 
			
		||||
                  productDescription: product.description,
 | 
			
		||||
                  productDescription: product.help,
 | 
			
		||||
                  priceBase,
 | 
			
		||||
                  priceStandard: productPrice.priceStandard,
 | 
			
		||||
                  priceList: productPrice.priceList,
 | 
			
		||||
                  priceLimit: productPrice.priceLimit,
 | 
			
		||||
                  schemaCurrency: productPrice.schemaCurrency,
 | 
			
		||||
                  schemaGrandTotal: this.getGrandTotal(productPrice.schemaPriceStandard, rate),
 | 
			
		||||
                  schemaPriceStandard: productPrice.schemaPriceStandard,
 | 
			
		||||
                  schemaPriceList: productPrice.schemaPriceList,
 | 
			
		||||
                  schemaPriceLimit: productPrice.schemaPriceLimit,
 | 
			
		||||
                  grandTotalConverted: this.amountConvert(productPrice.priceStandard, this.currentPointOfSales.displayCurrency),
 | 
			
		||||
                  taxRate: rate,
 | 
			
		||||
                  taxName: taxRate.name,
 | 
			
		||||
                  taxIndicator: taxRate.taxIndicator,
 | 
			
		||||
| 
						 | 
				
			
			@ -235,7 +253,7 @@ export default {
 | 
			
		|||
            }
 | 
			
		||||
            getProductPrice({
 | 
			
		||||
              searchValue: mutation.payload.value,
 | 
			
		||||
              priceListUuid: this.currentPoint.priceList.uuid
 | 
			
		||||
              posUuid: this.currentPointOfSales.uuid
 | 
			
		||||
            })
 | 
			
		||||
              .then(productPrice => {
 | 
			
		||||
                this.messageError = true
 | 
			
		||||
| 
						 | 
				
			
			@ -253,7 +271,7 @@ export default {
 | 
			
		|||
                  priceList: productPrice.priceList,
 | 
			
		||||
                  priceLimit: productPrice.priceLimit,
 | 
			
		||||
                  schemaCurrency: productPrice.schemaCurrency,
 | 
			
		||||
                  schemaGrandTotal: this.getGrandTotal(productPrice.schemaPriceStandard, rate),
 | 
			
		||||
                  grandTotalConverted: this.amountConvert(productPrice.priceStandard, this.currentPointOfSales.displayCurrency),
 | 
			
		||||
                  schemaPriceStandard: productPrice.schemaPriceStandard,
 | 
			
		||||
                  schemaPriceList: productPrice.schemaPriceList,
 | 
			
		||||
                  schemaPriceLimit: productPrice.schemaPriceLimit,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue