diff --git a/src/components/common/vnDiscount.vue b/src/components/common/vnDiscount.vue
new file mode 100644
index 000000000..49f95d51c
--- /dev/null
+++ b/src/components/common/vnDiscount.vue
@@ -0,0 +1,139 @@
+
+
+
+
+
+ {{ t('Mana') }} {{ toCurrency(props.mana) }}
+
+ $event.target.select()"
+ min="0"
+ max="100"
+ :disable="isLoading"
+ :hint="newAmount"
+ :rules="[
+ (value) => value.length > 0 || t('Enter a value'),
+ (value) => (value >= 0 && value <= 100) || t('Invalid discount amount'),
+ ]"
+ />
+
+
+
+
+
+
+
+
+es:
+ New amount: Nuevo importe
+ Update discount: Actualizar descuento
+ Mana: ManĂ¡
+ Enter a value: Introduce un valor
+ Invalid discount amount: Cantidad de descuento incorrecta
+ Cancel: Cancelar
+ Update: Actualizar
+
diff --git a/src/pages/Claim/Card/ClaimLines.vue b/src/pages/Claim/Card/ClaimLines.vue
index 8fc0838d4..ce7d8c585 100644
--- a/src/pages/Claim/Card/ClaimLines.vue
+++ b/src/pages/Claim/Card/ClaimLines.vue
@@ -11,6 +11,7 @@ import FetchData from 'components/FetchData.vue';
import VnConfirm from 'src/components/ui/VnConfirm.vue';
import { toDate, toCurrency, toPercentage } from 'src/filters';
+import VnDiscount from 'components/common/vnDiscount.vue';
const quasar = useQuasar();
const route = useRoute();
@@ -90,13 +91,18 @@ const columns = computed(() => [
name: 'discount',
label: t('Discount'),
field: ({ sale }) => sale.discount,
- format: (value) => toPercentage(value),
+ format: (value) => toPercentage(value / 100),
sortable: true,
},
{
name: 'total',
label: t('Total'),
- field: ({ sale }) => sale.price * sale.quantity,
+ field: ({ sale }) => {
+ const amount = sale.price * sale.quantity;
+ const appliedDiscount = (sale.discount * amount) / 100;
+
+ return amount - appliedDiscount;
+ },
format: (value) => toCurrency(value),
sortable: true,
},
@@ -106,6 +112,7 @@ const columns = computed(() => [
},
]);
+const selected = ref([]);
const mana = ref(0);
async function fetchMana() {
const ticketId = claim.value.ticketFk;
@@ -118,7 +125,25 @@ async function updateQuantity({ id, quantity }) {
await axios.patch(`ClaimBeginnings/${id}`, { quantity });
}
-async function updateDiscount({ id, discount }) {}
+async function updateDiscount({ saleFk, discount, canceller }) {
+ const body = { salesIds: [saleFk], newDiscount: discount };
+ const claimId = claim.value.ticketFk;
+ const query = `Tickets/${claimId}/updateDiscount`;
+
+ await axios.post(query, body, {
+ signal: canceller.signal,
+ });
+}
+
+function onUpdateDiscount(response) {
+ const row = store.data[response.rowIndex];
+ row.sale.discount = response.discount;
+ //store.data[response.rowIndex].sale.discount = response.discount;
+ quasar.notify({
+ message: t('Discount updated'),
+ type: 'positive',
+ });
+}
async function confirmRemove(id, index) {
quasar
@@ -141,9 +166,6 @@ async function remove({ id }) {
message: t('globals.rowRemoved'),
});
}
-
-const manaTitle = computed(() => `${t('Mana')} ${toCurrency(mana.value)}`);
-const totalClaimed = 0;
@@ -184,6 +206,8 @@ const totalClaimed = 0;
:dense="$q.screen.lt.md"
:pagination="{ rowsPerPage: 0 }"
row-key="id"
+ selection="multiple"
+ v-model:selected="selected"
hide-pagination
>
@@ -209,16 +233,32 @@ const totalClaimed = 0;
-
+
{{ value }}
+
-
+
+ {{ t('Mana') }} {{ toCurrency(mana) }}
+
$event.target.select()"
/>
-
+ New amount:
+ -->
@@ -295,5 +336,5 @@ es:
Amount: Total
Amount Claimed: Cantidad reclamada
Delete claimed sale: Eliminar venta reclamada
- Mana: ManĂ¡
+ Discount updated: Descuento actualizado