Skip to content

Commit

Permalink
refactor(Price add): show count & sum of already added prices (receip…
Browse files Browse the repository at this point in the history
…ts) (#1074)
  • Loading branch information
raphodn authored Dec 2, 2024
1 parent 382cbff commit 9be00ed
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/components/PriceAlreadyUploadedListCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,39 @@
<template #append>
<v-icon icon="mdi-checkbox-marked-circle" color="success" />
</template>

<v-divider />

<v-card-text>
<v-row>
<v-col v-for="productPriceUploaded in proofPriceUploadedList" :key="productPriceUploaded" cols="12">
<PriceCard :price="productPriceUploaded" :product="productPriceUploaded.product" :hideProductBarcode="false" :hidePriceFooterRow="true" :readonly="true" />
</v-col>
</v-row>
</v-card-text>

<v-divider v-if="proofPriceUploadedList.length" />

<v-card-actions v-if="proofPriceUploadedList.length">
<v-row>
<v-col cols="12">
<v-chip class="mr-1" label size="small" density="comfortable">
{{ $t('Common.PriceCount', { count: proofPriceUploadedList.length }) }}
</v-chip>
<v-chip class="mr-1" label size="small" density="comfortable">
{{ getPriceValueDisplay(proofPriceUploadedListSum) }}
</v-chip>
</v-col>
</v-row>
</v-card-actions>

<v-overlay v-model="disableCard" scrim="#E8F5E9" contained persistent />
</v-card>
</template>

<script>
import { defineAsyncComponent } from 'vue'
import utils from '../utils.js'
export default {
components: {
Expand All @@ -47,7 +66,21 @@ export default {
computed: {
showCard() {
return this.hideCardIfNoProofPriceUploaded && this.proofPriceUploadedList.length > 0
},
proofPriceUploadedListSum() {
return this.proofPriceUploadedList.reduce((acc, priceUploaded) => {
return acc + parseFloat(priceUploaded.price)
}, 0)
}
},
methods: {
getPriceValue(priceValue, priceCurrency) {
return utils.prettyPrice(priceValue, priceCurrency)
},
getPriceValueDisplay(price) {
price = parseFloat(price)
return this.getPriceValue(price, this.proofPriceUploadedList[0].currency)
},
}
}
</script>

0 comments on commit 9be00ed

Please sign in to comment.