Zmiany w nagłówkach zamówień
This commit is contained in:
@@ -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<string>();
|
||||
const filteredRoutes = ref<Array<Route>>();
|
||||
const showRoutesDropdown = ref<boolean>(false);
|
||||
const routeInput = ref(null);
|
||||
const invoices = ref();
|
||||
|
||||
const showErrorNotification = ref<boolean>(false);
|
||||
const showSuccessNotification = ref<boolean>(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<OrderProduct>
|
||||
};
|
||||
|
||||
@@ -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 () {
|
||||
<div>
|
||||
<div class="box mb-5">
|
||||
<div class="mb-3">
|
||||
<h1 class="title is-5"><b>ZAMÓWIENIE</b></h1>
|
||||
<h1 class="subtitle is-5" v-if="uuid != undefined" ><b>{{ uuid }}</b></h1>
|
||||
<h1 class="title is-5" v-if="uuid == undefined"><b>NOWE ZAMÓWIENIE</b></h1>
|
||||
<h1 class="title is-5" v-else-if="order != undefined"><b>ZAMÓWIENIE NR {{order.MZN_MZNID}}</b></h1>
|
||||
</div>
|
||||
<div class="field mb-3">
|
||||
<label class="label is-small">Klient</label>
|
||||
@@ -249,6 +275,22 @@ onBeforeUnmount( function () {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field mb-3">
|
||||
<DataTable :value="invoices" scrollable v-if="invoices != undefined && invoices.length > 0">
|
||||
<Column field="BZd_NumerPelny" header="Numer faktury" frozen/>
|
||||
<Column field="BZd_DataDok" header="Data"/>
|
||||
<Column field="BZd_Termin" header="Termin zapłaty"/>
|
||||
<Column field="BZd_KwotaSys" header="Kwota faktury"/>
|
||||
<Column field="BZd_KwotaRozSys" header="Kwota rozliczona"/>
|
||||
<ColumnGroup type="footer">
|
||||
<Row>
|
||||
<Column footer="Kwota zadłużenia" :colspan="4" footerStyle="text-align:right" />
|
||||
<Column :footer="totalAmountUnpaid" />
|
||||
</Row>
|
||||
</ColumnGroup>
|
||||
</DataTable>
|
||||
<span v-else>Brak nierozliczonych faktur</span>
|
||||
</div>
|
||||
<div class="field mb-3">
|
||||
<label class="label is-small">Data dostawy</label>
|
||||
<div class="field is-small">
|
||||
|
||||
Reference in New Issue
Block a user