Rebuild Inventory
Added Advance Invoices
This commit is contained in:
@@ -11,45 +11,79 @@ const toast = useToast()
|
||||
|
||||
const inventoryChangeData = ref({
|
||||
productId: "",
|
||||
spaceId: "",
|
||||
sourceSpaceId: null,
|
||||
sourceProjectId: null,
|
||||
destinationSpaceId: null,
|
||||
destinationProjectId: null,
|
||||
quantity: 1
|
||||
})
|
||||
|
||||
const createMovement = async () => {
|
||||
|
||||
if(mode.value === '' || !checkSpaceId(inventoryChangeData.value.spaceId) || !checkArticle(inventoryChangeData.value.productId)){
|
||||
let movements = []
|
||||
|
||||
} else {
|
||||
if(mode.value === 'incoming'){
|
||||
if(mode.value === 'incoming'){
|
||||
|
||||
const {error} = await supabase
|
||||
.from("movements")
|
||||
.insert([inventoryChangeData.value])
|
||||
.select()
|
||||
if(error) console.log(error)
|
||||
|
||||
|
||||
} else if (mode.value === 'outgoing'){
|
||||
inventoryChangeData.value.quantity *= -1
|
||||
|
||||
const {error} = await supabase
|
||||
.from("movements")
|
||||
.insert([inventoryChangeData.value])
|
||||
.select()
|
||||
if(error) console.log(error)
|
||||
} else if (mode.value === 'change'){}
|
||||
|
||||
|
||||
inventoryChangeData.value = {
|
||||
productId: "",
|
||||
spaceId: "",
|
||||
quantity: 1
|
||||
let movement = {
|
||||
productId: inventoryChangeData.value.productId,
|
||||
spaceId: inventoryChangeData.value.destinationSpaceId,
|
||||
projectId: inventoryChangeData.value.destinationProjectId,
|
||||
quantity: inventoryChangeData.value.quantity,
|
||||
profileId: dataStore.activeProfile.id,
|
||||
tenant: dataStore.currentTenant
|
||||
}
|
||||
|
||||
movements.push(movement)
|
||||
|
||||
dataStore.fetchMovements()
|
||||
/*const {error} = await supabase
|
||||
.from("movements")
|
||||
.insert([inventoryChangeData.value])
|
||||
.select()
|
||||
if(error) console.log(error)*/
|
||||
|
||||
|
||||
} else if (mode.value === 'outgoing'){
|
||||
|
||||
let movement = {
|
||||
productId: inventoryChangeData.value.productId,
|
||||
spaceId: inventoryChangeData.value.sourceSpaceId,
|
||||
projectId: inventoryChangeData.value.sourceProjectId,
|
||||
quantity: inventoryChangeData.value.quantity * -1,
|
||||
profileId: dataStore.activeProfile.id,
|
||||
tenant: dataStore.currentTenant
|
||||
}
|
||||
|
||||
movements.push(movement)
|
||||
} else if (mode.value === 'change'){
|
||||
let outMovement = {
|
||||
productId: inventoryChangeData.value.productId,
|
||||
spaceId: inventoryChangeData.value.sourceSpaceId,
|
||||
projectId: inventoryChangeData.value.sourceProjectId,
|
||||
quantity: inventoryChangeData.value.quantity * -1,
|
||||
profileId: dataStore.activeProfile.id,
|
||||
tenant: dataStore.currentTenant
|
||||
}
|
||||
let inMovement = {
|
||||
productId: inventoryChangeData.value.productId,
|
||||
spaceId: inventoryChangeData.value.destinationSpaceId,
|
||||
projectId: inventoryChangeData.value.destinationProjectId,
|
||||
quantity: inventoryChangeData.value.quantity,
|
||||
profileId: dataStore.activeProfile.id,
|
||||
tenant: dataStore.currentTenant
|
||||
}
|
||||
|
||||
movements.push(outMovement)
|
||||
movements.push(inMovement)
|
||||
}
|
||||
|
||||
console.log(movements)
|
||||
|
||||
const {error} = await supabase
|
||||
.from("movements")
|
||||
.insert(movements)
|
||||
.select()
|
||||
if(error) console.log(error)
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -63,13 +97,17 @@ defineShortcuts({
|
||||
})
|
||||
|
||||
|
||||
function checkArticle(productId) {
|
||||
function checkProductId(productId) {
|
||||
return dataStore.products.filter(product =>product.id === productId).length > 0;
|
||||
}
|
||||
function checkSpaceId(spaceId) {
|
||||
return dataStore.spaces.filter(space => space.id === spaceId).length > 0;
|
||||
}
|
||||
|
||||
function checkProjectId(projectId) {
|
||||
return dataStore.projects.some(i => i.id === projectId)
|
||||
}
|
||||
|
||||
function changeFocusToSpaceId() {
|
||||
document.getElementById('spaceIdInput').focus()
|
||||
}
|
||||
@@ -78,33 +116,154 @@ function changeFocusToQuantity() {
|
||||
document.getElementById('quantityInput').focus()
|
||||
}
|
||||
|
||||
function changeFocusToBarcode() {
|
||||
document.getElementById('barcodeInput').focus()
|
||||
}
|
||||
|
||||
|
||||
const findProductByBarcodeOrEAN = (input) => {
|
||||
return dataStore.products.find(i => i.barcode === input || i.ean === input)
|
||||
}
|
||||
|
||||
const findSpaceBySpaceNumber = (input) => {
|
||||
return dataStore.spaces.find(i => i.spaceNumber === input)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const barcodeInput = ref("")
|
||||
const showBarcodeTip = ref(true)
|
||||
|
||||
const processBarcodeInput = () => {
|
||||
if(findProductByBarcodeOrEAN(barcodeInput.value) && !findSpaceBySpaceNumber(barcodeInput.value)){
|
||||
//Set Product
|
||||
|
||||
inventoryChangeData.value.productId = findProductByBarcodeOrEAN(barcodeInput.value).id
|
||||
} else if (!findProductByBarcodeOrEAN(barcodeInput.value) && findSpaceBySpaceNumber(barcodeInput.value)){
|
||||
//Set Space
|
||||
|
||||
if(mode.value === 'incoming'){
|
||||
inventoryChangeData.value.destinationSpaceId = findSpaceBySpaceNumber(barcodeInput.value).id
|
||||
} else if(mode.value === 'outgoing') {
|
||||
inventoryChangeData.value.sourceSpaceId = findSpaceBySpaceNumber(barcodeInput.value).id
|
||||
} else if(mode.value === 'change') {
|
||||
if(!inventoryChangeData.value.sourceSpaceId){
|
||||
inventoryChangeData.value.sourceSpaceId = findSpaceBySpaceNumber(barcodeInput.value).id
|
||||
} else {
|
||||
inventoryChangeData.value.destinationSpaceId = findSpaceBySpaceNumber(barcodeInput.value).id
|
||||
}
|
||||
}
|
||||
//console.log(findSpaceBySpaceNumber(barcodeInput.value))
|
||||
}
|
||||
barcodeInput.value = ""
|
||||
//console.log(movementData.value)
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div id="main">
|
||||
|
||||
<div class="my-3">
|
||||
<div class="w-80 mx-auto mt-5">
|
||||
<div class="flex flex-col">
|
||||
<UButton
|
||||
@click="mode = 'incoming'"
|
||||
class="ml-3"
|
||||
class="my-2"
|
||||
:variant="mode === 'incoming' ? 'solid' : 'outline'"
|
||||
>Wareneingang</UButton>
|
||||
<UButton
|
||||
@click="mode = 'outgoing'"
|
||||
class="ml-1"
|
||||
class="my-2"
|
||||
:variant="mode === 'outgoing' ? 'solid' : 'outline'"
|
||||
>Warenausgang</UButton>
|
||||
<!-- <UButton
|
||||
<UButton
|
||||
@click="mode = 'change'"
|
||||
class="ml-1"
|
||||
disabled
|
||||
class="my-2"
|
||||
:variant="mode === 'change' ? 'solid' : 'outline'"
|
||||
>Umlagern</UButton>-->
|
||||
>Umlagern</UButton>
|
||||
</div>
|
||||
|
||||
<UAlert
|
||||
title="Info"
|
||||
variant="outline"
|
||||
color="primary"
|
||||
v-if="showBarcodeTip"
|
||||
@close="showBarcodeTip = false"
|
||||
:close-button="{ icon: 'i-heroicons-x-mark-20-solid', color: 'gray', variant: 'link', padded: false }"
|
||||
description="Über die Barcode Eingabe könenn folgende Werte automatisch erkannt werden: Quell Lagerplatz, Ziellagerplatz, Artikel(EAN oder Barcode). Es wird immer zuerst der Quell- und anschließend der Ziellagerplatz ausgefüllt."
|
||||
/>
|
||||
|
||||
<!-- <UTooltip
|
||||
text="Über die Barcode Eingabe könenn folgende Werte automatisch erkannt werden: Quell Lagerplatz, Ziellagerplatz, Artikel(EAN oder Barcode). Es wird immer zuerst der Quell- und anschließend der Ziellagerplatz ausgefüllt."
|
||||
>-->
|
||||
<UFormGroup
|
||||
label="Barcode:"
|
||||
class="mt-3"
|
||||
>
|
||||
<UInput
|
||||
@keyup.enter="processBarcodeInput"
|
||||
@focusout="processBarcodeInput"
|
||||
@input="processBarcodeInput"
|
||||
v-model="barcodeInput"
|
||||
id="barcodeInput"
|
||||
|
||||
/>
|
||||
|
||||
</UFormGroup>
|
||||
<!-- <template #text>
|
||||
<span class="text-wrap">Über die Barcode Eingabe könenn folgende Werte automatisch erkannt werden: Quell Lagerplatz, Ziellagerplatz, Artikel(EAN oder Barcode). Es wird immer zuerst der Quell- und anschließend der Ziellagerplatz ausgefüllt.</span>
|
||||
|
||||
</template>
|
||||
</UTooltip>-->
|
||||
|
||||
<UDivider
|
||||
class="mt-5 w-80"
|
||||
v-if="mode !== 'incoming'"
|
||||
/>
|
||||
|
||||
<UFormGroup
|
||||
label="Quell Lagerplatz:"
|
||||
class="mt-3 w-80"
|
||||
v-if="mode !== 'incoming' "
|
||||
>
|
||||
<USelectMenu
|
||||
:options="dataStore.spaces"
|
||||
searchable
|
||||
option-attribute="spaceNumber"
|
||||
:color="checkSpaceId(inventoryChangeData.sourceSpaceId) ? 'primary' : 'rose'"
|
||||
v-model="inventoryChangeData.sourceSpaceId"
|
||||
@change="inventoryChangeData.sourceProjectId = null"
|
||||
value-attribute="id"
|
||||
>
|
||||
<template #label>
|
||||
{{dataStore.spaces.find(space => space.id === inventoryChangeData.sourceSpaceId) ? dataStore.spaces.find(space => space.id === inventoryChangeData.sourceSpaceId).description : "Kein Lagerplatz ausgewählt"}}
|
||||
</template>
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
<UFormGroup
|
||||
label="Quell Projekt:"
|
||||
class="mt-3 w-80"
|
||||
v-if="mode !== 'incoming' "
|
||||
>
|
||||
<USelectMenu
|
||||
:options="dataStore.projects"
|
||||
searchable
|
||||
option-attribute="name"
|
||||
:color="checkProjectId(inventoryChangeData.sourceProjectId) ? 'primary' : 'rose'"
|
||||
v-model="inventoryChangeData.sourceProjectId"
|
||||
@change="inventoryChangeData.sourceSpaceId = null"
|
||||
value-attribute="id"
|
||||
>
|
||||
<template #label>
|
||||
{{dataStore.getProjectById(inventoryChangeData.sourceProjectId) ? dataStore.getProjectById(inventoryChangeData.sourceProjectId).name : "Kein Projekt ausgewählt"}}
|
||||
</template>
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
|
||||
<UDivider
|
||||
class="mt-5 w-80"
|
||||
/>
|
||||
|
||||
<UFormGroup
|
||||
label="Artikel:"
|
||||
@@ -117,7 +276,7 @@ function changeFocusToQuantity() {
|
||||
variant="outline"
|
||||
searchable
|
||||
:search-attributes="['name','ean', 'barcode']"
|
||||
:color="checkArticle(inventoryChangeData.productId) ? 'primary' : 'rose'"
|
||||
:color="checkProductId(inventoryChangeData.productId) ? 'primary' : 'rose'"
|
||||
v-model="inventoryChangeData.productId"
|
||||
v-on:select="changeFocusToSpaceId"
|
||||
>
|
||||
@@ -127,24 +286,53 @@ function changeFocusToQuantity() {
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
|
||||
<UDivider
|
||||
class="mt-5 w-80"
|
||||
v-if="mode !== 'outgoing'"
|
||||
/>
|
||||
|
||||
<UFormGroup
|
||||
label="Lagerplatz:"
|
||||
label="Ziel Lagerplatz:"
|
||||
class="mt-3 w-80"
|
||||
v-if="mode !== 'outgoing'"
|
||||
>
|
||||
<USelectMenu
|
||||
:options="dataStore.spaces"
|
||||
searchable
|
||||
option-attribute="spaceNumber"
|
||||
:color="checkSpaceId(inventoryChangeData.spaceId) ? 'primary' : 'rose'"
|
||||
v-model="inventoryChangeData.spaceId"
|
||||
v-on:select="changeFocusToQuantity"
|
||||
value-attribute="id"
|
||||
:options="dataStore.spaces"
|
||||
searchable
|
||||
option-attribute="spaceNumber"
|
||||
:color="checkSpaceId(inventoryChangeData.destinationSpaceId) ? 'primary' : 'rose'"
|
||||
v-model="inventoryChangeData.destinationSpaceId"
|
||||
@change="inventoryChangeData.destinationProjectId = null"
|
||||
value-attribute="id"
|
||||
>
|
||||
<template #label>
|
||||
{{dataStore.spaces.find(space => space.id === inventoryChangeData.spaceId) ? dataStore.spaces.find(space => space.id === inventoryChangeData.spaceId).description : "Kein Lagerplatz ausgewählt"}}
|
||||
{{dataStore.spaces.find(space => space.id === inventoryChangeData.destinationSpaceId) ? dataStore.spaces.find(space => space.id === inventoryChangeData.destinationSpaceId).description : "Kein Lagerplatz ausgewählt"}}
|
||||
</template>
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
<UFormGroup
|
||||
label="Ziel Projekt:"
|
||||
class="mt-3 w-80"
|
||||
v-if="mode !== 'outgoing'"
|
||||
>
|
||||
<USelectMenu
|
||||
:options="dataStore.projects"
|
||||
searchable
|
||||
option-attribute="name"
|
||||
:color="checkProjectId(inventoryChangeData.destinationProjectId) ? 'primary' : 'rose'"
|
||||
v-model="inventoryChangeData.destinationProjectId"
|
||||
value-attribute="id"
|
||||
@change="inventoryChangeData.destinationSpaceId = null"
|
||||
>
|
||||
<template #label>
|
||||
{{dataStore.getProjectById(inventoryChangeData.destinationProjectId) ? dataStore.getProjectById(inventoryChangeData.destinationProjectId).name : "Kein Projekt ausgewählt"}}
|
||||
</template>
|
||||
</USelectMenu>
|
||||
</UFormGroup>
|
||||
|
||||
<UDivider
|
||||
class="mt-5 w-80"
|
||||
/>
|
||||
|
||||
<UFormGroup
|
||||
label="Anzahl:"
|
||||
@@ -161,13 +349,33 @@ function changeFocusToQuantity() {
|
||||
</UFormGroup>
|
||||
<UButton
|
||||
@click="createMovement"
|
||||
:disabled="mode === '' && checkSpaceId(inventoryChangeData.spaceId) && checkArticle(inventoryChangeData.productId)"
|
||||
class="mt-3"
|
||||
:disabled="mode === '' && checkSpaceId(inventoryChangeData.spaceId) && checkProductId(inventoryChangeData.productId)"
|
||||
class="mt-3"
|
||||
>
|
||||
Bestätigen
|
||||
</UButton>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <div class="my-3">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-->
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user