Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(Price add): show count & sum of already added prices (receipts) #1074

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading