fixed calendar
This commit is contained in:
		@@ -3,7 +3,7 @@ import { useOrdersStore } from '@/stores/orders.store'
 | 
				
			|||||||
import { storeToRefs } from 'pinia'
 | 
					import { storeToRefs } from 'pinia'
 | 
				
			||||||
import VueDatePicker from '@vuepic/vue-datepicker'
 | 
					import VueDatePicker from '@vuepic/vue-datepicker'
 | 
				
			||||||
import { useSiteControlStore } from '@/stores/siteControl.store'
 | 
					import { useSiteControlStore } from '@/stores/siteControl.store'
 | 
				
			||||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
 | 
					import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
 | 
				
			||||||
import { useCategoriesStore } from '@/stores/categories.store'
 | 
					import { useCategoriesStore } from '@/stores/categories.store'
 | 
				
			||||||
import type { Order, OrderProduct, Product } from '@/main'
 | 
					import type { Order, OrderProduct, Product } from '@/main'
 | 
				
			||||||
import { useRoutesStore } from '@/stores/routes.store'
 | 
					import { useRoutesStore } from '@/stores/routes.store'
 | 
				
			||||||
@@ -27,6 +27,35 @@ const orderByRouteAndNipRef = ref<Map<string, Map<number, {
 | 
				
			|||||||
  products: OrderProduct[]
 | 
					  products: OrderProduct[]
 | 
				
			||||||
}>>>(new Map<string, Map<number, { orders: Order[]; products: OrderProduct[] }>>)
 | 
					}>>>(new Map<string, Map<number, { orders: Order[]; products: OrderProduct[] }>>)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const watchSearchDate = watch(searchDate, async (oldSearchDate, newSeatchDate) => {
 | 
				
			||||||
 | 
					  if (oldSearchDate != newSeatchDate) {
 | 
				
			||||||
 | 
					    await fetchOrders()
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const watchConfirmedOrders = watch(confirmedOrders, async (oldConfirmedOrders, newConfirmedOrders) => {
 | 
				
			||||||
 | 
					  if (oldConfirmedOrders != newConfirmedOrders) {
 | 
				
			||||||
 | 
					    await fetchOrders()
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function fetchOrders() {
 | 
				
			||||||
 | 
					  isLoading.value = true
 | 
				
			||||||
 | 
					  orders.value = await ordersStore.fetchOrdersByDateStartAndEnd(searchDate.value != undefined ? searchDate.value : new Date(Date.now()),
 | 
				
			||||||
 | 
					    searchDate.value != undefined ? searchDate.value : new Date(Date.now()),
 | 
				
			||||||
 | 
					    (confirmedOrders.value) ? false : null)
 | 
				
			||||||
 | 
					  const productsMap = await categoriesStore.sumProductsFromOrders(orders.value)
 | 
				
			||||||
 | 
					  summedProducts.value = []
 | 
				
			||||||
 | 
					  for (const product of productsMap.values()) {
 | 
				
			||||||
 | 
					    if (product.SummedQuantity > 0) {
 | 
				
			||||||
 | 
					      summedProducts.value.push(product)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  await prepareProductsFromOrders()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  isLoading.value = false
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function addRoutes() {
 | 
					function addRoutes() {
 | 
				
			||||||
  for (const route of routes.value) {
 | 
					  for (const route of routes.value) {
 | 
				
			||||||
    ordersByRoute.value.set(route.MZT_Nazwa1, [])
 | 
					    ordersByRoute.value.set(route.MZT_Nazwa1, [])
 | 
				
			||||||
@@ -63,71 +92,7 @@ function prepareProductsFromOrders() {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
  console.log(orders.value)
 | 
					  console.log(orders.value)
 | 
				
			||||||
  console.log(ordersByRoute.value)
 | 
					  console.log(ordersByRoute.value)
 | 
				
			||||||
  const newOrder: Order = {
 | 
					  groupByNip()
 | 
				
			||||||
    loading: false,
 | 
					 | 
				
			||||||
    MZN_Bufor: 0,
 | 
					 | 
				
			||||||
    MZN_Anulowane: 0,
 | 
					 | 
				
			||||||
    MZN_DataDos: "2025-02-27",
 | 
					 | 
				
			||||||
    MZN_DataZam: "2025-02-27",
 | 
					 | 
				
			||||||
    MZN_MZNID: 12345,
 | 
					 | 
				
			||||||
    MZN_OpeID: 6789,
 | 
					 | 
				
			||||||
    MZN_PodID: 1001,
 | 
					 | 
				
			||||||
    MZN_PodKodPocztowy: "00-001",
 | 
					 | 
				
			||||||
    MZN_PodMiasto: "Warszawa",
 | 
					 | 
				
			||||||
    MZN_PodNazwa1: "Firma XYZ",
 | 
					 | 
				
			||||||
    MZN_PodNazwa2: "Oddział Główny",
 | 
					 | 
				
			||||||
    MZN_PodNazwa3: "",
 | 
					 | 
				
			||||||
    MZN_PodNipE: "8991446786",
 | 
					 | 
				
			||||||
    MZN_PodNrDomu: "10A",
 | 
					 | 
				
			||||||
    MZN_PodUlica: "Marszałkowska",
 | 
					 | 
				
			||||||
    MZN_PodWojewodztwo: "Mazowieckie",
 | 
					 | 
				
			||||||
    MZN_TypDokumentu: 1,
 | 
					 | 
				
			||||||
    MZN_UUID: "550e8400-e29b-41d4-a716-446655440000",
 | 
					 | 
				
			||||||
    MZN_Uwagi: "Brak uwag",
 | 
					 | 
				
			||||||
    MZN_MZTID: 2002,
 | 
					 | 
				
			||||||
    MZamElem: [
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        MZE_MZEID: 1,
 | 
					 | 
				
			||||||
        MZE_MZNID: 12345,
 | 
					 | 
				
			||||||
        MZE_TwrCena: "12.00",
 | 
					 | 
				
			||||||
        MZE_TwrId: 2323,
 | 
					 | 
				
			||||||
        MZE_TwrIlosc: "150.00",
 | 
					 | 
				
			||||||
        MZE_TwrJm: "kg",
 | 
					 | 
				
			||||||
        MZE_TwrNazwa: 'Twaróg półtłusty "suchy" - luz',
 | 
					 | 
				
			||||||
        MZE_TwrKod: "TWS-LUZ",
 | 
					 | 
				
			||||||
        MZE_TwrStawka: "8%",
 | 
					 | 
				
			||||||
        suma: 1800.00
 | 
					 | 
				
			||||||
      },
 | 
					 | 
				
			||||||
      {
 | 
					 | 
				
			||||||
        MZE_MZEID: 2,
 | 
					 | 
				
			||||||
        MZE_MZNID: 12345,
 | 
					 | 
				
			||||||
        MZE_TwrCena: "25.50",
 | 
					 | 
				
			||||||
        MZE_TwrId: 102,
 | 
					 | 
				
			||||||
        MZE_TwrIlosc: "10.00",
 | 
					 | 
				
			||||||
        MZE_TwrJm: "szt",
 | 
					 | 
				
			||||||
        MZE_TwrNazwa: "Ekologiczne jajka klasy premium",
 | 
					 | 
				
			||||||
        MZE_TwrKod: "EKO-JAJ",
 | 
					 | 
				
			||||||
        MZE_TwrStawka: "5%",
 | 
					 | 
				
			||||||
        suma: 255.00
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    ],
 | 
					 | 
				
			||||||
    products: []
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
  const produkciki = newOrder.MZamElem.map(product => ({
 | 
					 | 
				
			||||||
    kod: product.MZE_TwrKod,
 | 
					 | 
				
			||||||
    nazwa: product.MZE_TwrNazwa,
 | 
					 | 
				
			||||||
    ilosc: Number(product.MZE_TwrIlosc).toFixed(2),
 | 
					 | 
				
			||||||
    jm: product.MZE_TwrJm,
 | 
					 | 
				
			||||||
    cena: Number(product.MZE_TwrCena).toFixed(2),
 | 
					 | 
				
			||||||
    suma: Number(Number(product.MZE_TwrCena) * Number(product.MZE_TwrIlosc)).toFixed(2)
 | 
					 | 
				
			||||||
  }));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Aktualizacja newOrder z dodanymi produktami
 | 
					 | 
				
			||||||
  newOrder.products = produkciki;
 | 
					 | 
				
			||||||
  ordersByRoute.value.get("Wrocław")?.push(newOrder);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  console.log(newOrder);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function groupByNip() {
 | 
					function groupByNip() {
 | 
				
			||||||
@@ -148,7 +113,7 @@ function groupByNip() {
 | 
				
			|||||||
        if (existingProduct) {
 | 
					        if (existingProduct) {
 | 
				
			||||||
          existingProduct.MZE_TwrCena =String(Number(existingProduct.MZE_TwrCena).toFixed(2))
 | 
					          existingProduct.MZE_TwrCena =String(Number(existingProduct.MZE_TwrCena).toFixed(2))
 | 
				
			||||||
          existingProduct.MZE_TwrIlosc = String(
 | 
					          existingProduct.MZE_TwrIlosc = String(
 | 
				
			||||||
            Number(Number(existingProduct.MZE_TwrIlosc) + Number(element.MZE_TwrIlosc)).toFixed(0)
 | 
					            Number(Number(existingProduct.MZE_TwrIlosc) + Number(element.MZE_TwrIlosc)).toFixed(2)
 | 
				
			||||||
          )
 | 
					          )
 | 
				
			||||||
          existingProduct.suma = Number(Number(existingProduct.MZE_TwrIlosc) * Number(existingProduct.MZE_TwrCena)).toFixed(2)
 | 
					          existingProduct.suma = Number(Number(existingProduct.MZE_TwrIlosc) * Number(existingProduct.MZE_TwrCena)).toFixed(2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -178,7 +143,7 @@ onMounted(async () => {
 | 
				
			|||||||
    await prepareProductsFromOrders();
 | 
					    await prepareProductsFromOrders();
 | 
				
			||||||
    console.log(products.value);
 | 
					    console.log(products.value);
 | 
				
			||||||
    isLoading.value=false;
 | 
					    isLoading.value=false;
 | 
				
			||||||
    groupByNip()
 | 
					
 | 
				
			||||||
  console.log(ordersByRoute.value)
 | 
					  console.log(ordersByRoute.value)
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user