aboutsummaryrefslogtreecommitdiff
path: root/src/views/EditInvoice.vue
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2023-12-07 05:01:08 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2023-12-07 05:01:08 +0530
commit4c48edc7905d6fb16b01ea707ee7e730dff78ced (patch)
tree343839b5c7bcd7abf24ba7ef9f3ba7c33ccf78f8 /src/views/EditInvoice.vue
parent464dac56714f4fb187785abda04bf3f2170af2a2 (diff)
added view invoice page with print button!0.3.0
Diffstat (limited to 'src/views/EditInvoice.vue')
-rw-r--r--src/views/EditInvoice.vue31
1 files changed, 4 insertions, 27 deletions
diff --git a/src/views/EditInvoice.vue b/src/views/EditInvoice.vue
index adc172b..69afc7e 100644
--- a/src/views/EditInvoice.vue
+++ b/src/views/EditInvoice.vue
@@ -1,12 +1,11 @@
<script setup lang="ts">
-import { ref, onMounted, toRaw } from 'vue'
+import { ref, onMounted } from 'vue'
import { useRoute } from "vue-router"
import { useToast } from 'vue-toast-notification'
import axios from 'axios'
-import currency from "currency.js"
import Invoice from "./../classes/invoice"
-import InvoiceItem from "./../classes/invoice_item"
+import { calculate } from "./../classes/invoice_item"
import invoiceHeader from './../components/invoice_header.vue'
import itemSelector from './../components/item_selector.vue'
@@ -25,28 +24,6 @@ const items = ref<any[]>([])
const invoiceIsLoading = ref(true)
const itemsTableIsLoading = ref(true)
-const processItems = (items: InvoiceItem[]) => items.map((x: InvoiceItem) => {
- const quantity = currency(x.Quantity)
- const unitPrice = currency(x.UnitPrice)
- const gstPercentage = currency(x.GSTPercentage)
- const gstValue = unitPrice.multiply(gstPercentage).divide(100)
- const totalGSTValue = gstValue.multiply(quantity)
- const amountWithoutGST = unitPrice.multiply(quantity)
-
- return({
- ...x
- , Quantity: quantity
- , UnitPrice: unitPrice
- , GSTValue: gstValue
- , TotalGSTValue: totalGSTValue
- , AmountWithoutGST: amountWithoutGST
- , TotalAmount: amountWithoutGST.add(totalGSTValue)
- })
-})
- //{{ currency(item.UnitPrice).add(currency(item.UnitPrice).multiply(currency(item.GSTPercentage)).divide(100)).multiply(currency(item.Quantity)) }}
- // {{ currency(item.UnitPrice).multiply(currency(item.Quantity)) }}
- // {{ currency(item.UnitPrice).multiply(currency(item.GSTPercentage)).divide(100).multiply(item.Quantity) }}
-
const getInvoice = async () => {
invoiceIsLoading.value = true
itemsTableIsLoading.value = true
@@ -54,7 +31,7 @@ const getInvoice = async () => {
try {
const r = await axios.get(`/invoice/${invoiceId}`)
invoice.value = r.data.data
- items.value = processItems(r.data.data.Items)
+ items.value = calculate(r.data.data.Items)
} catch (err) {
toast.error('An unhandled exception occoured. Please check logs')
console.error(err)
@@ -71,7 +48,7 @@ const refreshItems = async () => {
try {
const res = await axios.get(`/invoice/${invoiceId}/item`)
if (res.status === 200) {
- items.value = processItems(res.data.data)
+ items.value = calculate(res.data.data)
}
} catch (err) {
toast.error('An unhandled exception occoured. Please check logs')