diff --git a/src/components/PriceAlreadyUploadedListCard.vue b/src/components/PriceAlreadyUploadedListCard.vue index 33c4033bfdc..4f5bef09af6 100644 --- a/src/components/PriceAlreadyUploadedListCard.vue +++ b/src/components/PriceAlreadyUploadedListCard.vue @@ -16,7 +16,7 @@ - + @@ -77,7 +77,7 @@ export default { }, proofPriceUploadedListSum() { return this.proofPriceUploadedList.reduce((acc, priceUploaded) => { - return acc + parseFloat(priceUploaded.price) + return acc + parseFloat(priceUploaded.price)*parseInt(priceUploaded.receipt_quantity) }, 0) } }, diff --git a/src/components/PriceCard.vue b/src/components/PriceCard.vue index bb9dbbd13e3..0c0bc915e66 100644 --- a/src/components/PriceCard.vue +++ b/src/components/PriceCard.vue @@ -29,7 +29,7 @@

- + @@ -81,6 +81,10 @@ export default { type: Boolean, default: true }, + hidePriceReceiptQuantity: { + type: Boolean, + default: true + }, hidePriceFooterRow: { type: Boolean, default: false diff --git a/src/components/PriceInputRow.vue b/src/components/PriceInputRow.vue index f19c46ad794..6dc3c7dccd8 100644 --- a/src/components/PriceInputRow.vue +++ b/src/components/PriceInputRow.vue @@ -40,6 +40,17 @@ hide-details="auto" /> + + + ({ price: null, - currency: null, price_is_discounted: false, - price_without_discount: null + price_without_discount: null, + currency: null, + receipt_quantity: null, }) }, hideCurrencyChoice: { @@ -77,12 +89,17 @@ export default { type: Object, default: null }, + proofType: { + type: String, + default: null + }, }, emits: ['filled'], data() { return { // currency selection changeCurrencyDialog: false, + PROOF_TYPE_RECEIPT_ICON: constants.PROOF_TYPE_RECEIPT_ICON, } }, computed: { @@ -99,6 +116,9 @@ export default { let keys = ['price', 'currency'] return Object.keys(this.priceForm).filter(k => keys.includes(k)).every(k => !!this.priceForm[k]) }, + proofIsTypeReceipt() { + return this.proofType === constants.PROOF_TYPE_RECEIPT + }, }, watch: { priceFormFilled(newPriceFormFilled, oldPriceFormFilled) { // eslint-disable-line no-unused-vars diff --git a/src/components/PricePriceRow.vue b/src/components/PricePriceRow.vue index 99361e62a24..bd55b7450a5 100644 --- a/src/components/PricePriceRow.vue +++ b/src/components/PricePriceRow.vue @@ -4,11 +4,16 @@ {{ getPriceValueDisplay(price.price) }} ({{ getPricePerUnit(price.price) }}) - + {{ $t('PriceCard.Discount') }} {{ $t('PriceCard.FullPrice') }} {{ getPriceValueDisplay(price.price_without_discount) }} + + + x{{ price.receipt_quantity }} + + @@ -31,9 +36,9 @@ export default { type: String, default: constants.PRODUCT_QUANTITY_UNIT_G }, - hidePriceDate: { + hidePriceReceiptQuantity: { type: Boolean, - default: false + default: true }, }, data() { diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 17e1f03b73f..0759cdc0114 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -250,6 +250,9 @@ "ProofSelected": "Proof selected!", "ProofSelectedCount": "{count} proofs selected | {count} proof selected | {count} proofs selected", "Public": "Public", + "Quantity": "Quantity", + "QuantityBought": "Quantity bought", + "QuantityMissing": "Quantity missing", "Receipt": "Receipt", "Receipts": "Receipts", "ReceiptPriceCount": "Number of prices", diff --git a/src/services/api.js b/src/services/api.js index fadb040fe0b..43b0a8fc9ee 100644 --- a/src/services/api.js +++ b/src/services/api.js @@ -2,7 +2,7 @@ import { useAppStore } from '../store' import constants from '../constants' -const PRICE_UPDATE_FIELDS = ['price', 'price_is_discounted', 'price_without_discount', 'price_per', 'currency', 'date'] +const PRICE_UPDATE_FIELDS = ['price', 'price_is_discounted', 'price_without_discount', 'price_per', 'currency', 'receipt_quantity', 'date'] const PRICE_CREATE_FIELDS = PRICE_UPDATE_FIELDS.concat(['type', 'product_code', 'product_name', 'category_tag', 'labels_tags', 'origins_tags', 'location_id', 'location_osm_id', 'location_osm_type', 'proof_id']) const PROOF_UPDATE_FIELDS = ['type', 'date', 'currency', 'receipt_price_count', 'receipt_price_total'] const PROOF_CREATE_FIELDS = PROOF_UPDATE_FIELDS.concat(['location_id', 'location_osm_id', 'location_osm_type']) // 'file' diff --git a/src/views/AddPriceMultiple.vue b/src/views/AddPriceMultiple.vue index b7458407a26..f8515062f19 100644 --- a/src/views/AddPriceMultiple.vue +++ b/src/views/AddPriceMultiple.vue @@ -114,6 +114,7 @@ import { defineAsyncComponent } from 'vue' import { mapStores } from 'pinia' import { useAppStore } from '../store' import api from '../services/api' +import constants from '../constants' import utils from '../utils.js' export default { @@ -159,7 +160,8 @@ export default { price_per: null, price_is_discounted: false, price_without_discount: null, - currency: null // see initNewProductPriceForm + currency: null, // see initNewProductPriceForm + receipt_quantity: null, }, categoryPricePerList: [ {key: 'KILOGRAM', value: this.$t('AddPriceSingle.CategoryPricePer.PerKg'), icon: 'mdi-weight-kilogram'}, @@ -239,6 +241,9 @@ export default { this.productPriceForm.type = this.appStore.user.last_product_type_used // can be overriden in ProductInputRow this.productPriceForm.price_per = this.categoryPricePerList[0].key // init to 'KILOGRAM' because it's the most common use-case this.productPriceForm.currency = this.addPriceMultipleForm.currency || this.appStore.getUserLastCurrencyUsed // get currency from proof first + if (this.proofObject.type === constants.PROOF_TYPE_RECEIPT) { + this.productPriceForm.receipt_quantity = 1 + } // scroll to the form this.goTo('#product-price-form') }, diff --git a/src/views/AddPriceSingle.vue b/src/views/AddPriceSingle.vue index 4d9a062ca37..e4ace23b470 100644 --- a/src/views/AddPriceSingle.vue +++ b/src/views/AddPriceSingle.vue @@ -121,6 +121,7 @@ export default { price_is_discounted: false, price_without_discount: null, currency: null, // see initPriceSingleForm + receipt_quantity: null, location_id: null, location_osm_id: null, location_osm_type: '',