diff --git a/components.d.ts b/components.d.ts index 32c7d47..0654243 100644 --- a/components.d.ts +++ b/components.d.ts @@ -9,6 +9,7 @@ declare module 'vue' { export interface GlobalComponents { CancelationModal: typeof import('./src/components/CancelationModal.vue')['default'] Column: typeof import('primevue/column')['default'] + ColumnGroup: typeof import('primevue/columngroup')['default'] ConfirmationModal: typeof import('./src/components/ConfirmationModal.vue')['default'] ConfirmedForm: typeof import('./src/components/ConfirmedForm.vue')['default'] DataTable: typeof import('primevue/datatable')['default'] @@ -24,6 +25,7 @@ declare module 'vue' { OrdersSelector: typeof import('./src/components/OrdersSelector.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] + Row: typeof import('primevue/row')['default'] SummaryComponent: typeof import('./src/components/SummaryComponent.vue')['default'] } } diff --git a/src/components/ConfirmedForm.vue b/src/components/ConfirmedForm.vue index 4101a5d..a5bfb4a 100644 --- a/src/components/ConfirmedForm.vue +++ b/src/components/ConfirmedForm.vue @@ -30,8 +30,9 @@ function cancelOrder(event: Event) {
-

ZAMÓWIENIE

-

{{ uuid }}

+
+

ZAMÓWIENIE NR {{order.MZN_MZNID}}

+
@@ -76,6 +77,15 @@ function cancelOrder(event: Event) { readonly/>
+
+ +

+ {{ order.MZN_Uwagi }} +

+

+ Brak uwag. +

+
diff --git a/src/components/MainForm.vue b/src/components/MainForm.vue index 0f1c374..393d9d6 100644 --- a/src/components/MainForm.vue +++ b/src/components/MainForm.vue @@ -6,8 +6,9 @@ import { useContractorsStore } from '@/stores/contractors.store' import { useOrdersStore } from '@/stores/orders.store' import { storeToRefs } from 'pinia' import { useSiteControlStore } from '@/stores/siteControl.store' -import { onBeforeUnmount, onMounted, ref, watch } from 'vue' +import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue' import { useRoutesStore } from '@/stores/routes.store' +import { Order } from '@/main' const categoriesStore = useCategoriesStore(); const contractorsStore = useContractorsStore(); @@ -16,7 +17,7 @@ const siteControlStore = useSiteControlStore(); const routesStore = useRoutesStore(); const { contractor, contractors } = storeToRefs(contractorsStore); -const { deliveryDate, uuid, additionalNotes } = storeToRefs(ordersStore); +const { deliveryDate, uuid, order, additionalNotes } = storeToRefs(ordersStore); const { categories } = storeToRefs(categoriesStore); const { showConfirmationModal, showCancellationModal, isDarkTheme } = storeToRefs(siteControlStore); const { route, routes } = storeToRefs(routesStore); @@ -30,6 +31,7 @@ const routeSearch = ref(); const filteredRoutes = ref>(); const showRoutesDropdown = ref(false); const routeInput = ref(null); +const invoices = ref(); const showErrorNotification = ref(false); const showSuccessNotification = ref(false); @@ -52,6 +54,16 @@ watch(route, (route) => { } }, { immediate: true }); +const totalAmountUnpaid = computed(() => { + let total = 0; + let totalPaid = 0; + for(let invoice of invoices.value) { + total += Number(invoice.BZd_KwotaSys); + totalPaid += Number(invoice.BZd_KwotaRozSys); + } + return (total - totalPaid).toFixed(2); +}); + function createJSON(event: Event) { event.preventDefault(); console.log(deliveryDate.value); @@ -64,6 +76,7 @@ function createJSON(event: Event) { MZN_DataDos: deliveryDate.value != undefined ? deliveryDate.value.toISOString().split('T')[0] : null, MZN_PodID: contractor.value?.Knt_KntId, MZN_MZTID: route.value?.MZT_MZTID, + MZN_Uwagi: additionalNotes.value, MZamElem: new Array }; @@ -121,6 +134,9 @@ function createJSON(event: Event) { console.log(JSON.stringify(json)); axiosInstance.post('/zamowienie', JSON.stringify(json)).then( response => { uuid.value = response.data.MZN_UUID; + order.value = {} as Order; + order.value.MZN_MZNID = response.data.MZN_MZNID; + order.value.MZN_Bufor = 1; showSuccessNotification.value = true; successNotificationMessage.value = "Zamówienie zostało zapisane do bazy danych." }); @@ -166,6 +182,7 @@ function selectContractorFromDropdown(selectedContractor : Contractor) { console.log(selectedContractor); contractor.value = selectedContractor; showContractorsDropdown.value = false; + fetchInvoices(); } function filterRoutes() { @@ -205,8 +222,17 @@ function handleClickOutsideDropdown(event : Event) { } } +async function fetchInvoices() { + const response = await axiosInstance.get('/zaleglosci/' + contractor.value?.Knt_KntId); + invoices.value = response.data; + +} + onMounted(function (){ document.addEventListener('click', handleClickOutsideDropdown); + if(contractor.value != undefined) { + fetchInvoices(); + } }); onBeforeUnmount( function () { @@ -219,8 +245,8 @@ onBeforeUnmount( function () {
-

ZAMÓWIENIE

-

{{ uuid }}

+

NOWE ZAMÓWIENIE

+

ZAMÓWIENIE NR {{order.MZN_MZNID}}

@@ -249,6 +275,22 @@ onBeforeUnmount( function () {
+
+ + + + + + + + + + + + + + Brak nierozliczonych faktur +
diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue index 3921d80..697102c 100644 --- a/src/components/NavBar.vue +++ b/src/components/NavBar.vue @@ -54,10 +54,10 @@ function routeLogin() { -