-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHome.vue
85 lines (72 loc) · 2.32 KB
/
Home.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<script lang="ts" setup>
import {type PropType, computed, ref} from 'vue';
import {formatNumber, formatPrice} from '@/helpers';
import type InventoryMovement from '@/models/InventoryMovement';
import MovementForm from '@/components/InventoryMovements/Form.vue';
import MovementsTable from '@/components/InventoryMovements/Table.vue';
const props = defineProps({
movements: {
type: Array as PropType<InventoryMovement[]>,
required: true,
},
});
const availableOnly = ref(false);
const availableMovements = computed(() => props.movements.filter(m => m.remainingQuantity > 0));
const totalAvailableQuantity = computed(() => availableMovements.value.reduce(
(total, movement) => total + movement.remainingQuantity,
0,
));
const totalAvailableValuation = computed(() => availableMovements.value.reduce(
(total, movement) => total + movement.remainingQuantity * movement.unitPrice,
0,
));
</script>
<template>
<main class="container py-4">
<MovementForm />
<ul class="nav nav-tabs mt-3">
<li class="nav-item">
<a
class="nav-link"
:class="{active: !availableOnly}"
href="#"
@click="availableOnly = false"
>
All Movements
</a>
</li>
<li class="nav-item">
<a
class="nav-link"
:class="{active: availableOnly}"
href="#"
@click="availableOnly = true"
>
Available Units
</a>
</li>
</ul>
<MovementsTable
:available-only="availableOnly"
:movements="movements"
/>
<table class="text-end fw-bold ms-auto">
<tr>
<td>
Total Available Quantity:
</td>
<td>
{{ formatNumber(totalAvailableQuantity) }}
</td>
</tr>
<tr>
<td>
Total Available Valuation:
</td>
<td class="ps-4">
{{ formatPrice(totalAvailableValuation) }}
</td>
</tr>
</table>
</main>
</template>