-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
224b6c3
commit 7bcfdc6
Showing
26 changed files
with
732 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
apps/dashboard/src/modules/financial/components/invoice/create/InvoiceCreate.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<template> | ||
<CardComponent header="Create Invoice"> | ||
<ActionButton | ||
type="submit" | ||
:disabled="disabled" | ||
:label="t('common.create')" | ||
:submitting="form.context.isSubmitting.value" | ||
:result="form.success?.value != null" | ||
@click="form.submit" | ||
/> | ||
</CardComponent> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import CardComponent from "@/components/CardComponent.vue"; | ||
import { computed, type PropType } from "vue"; | ||
import { type Form, getProperty, setSubmit, setSuccess } from "@/utils/formUtils"; | ||
import * as yup from "yup"; | ||
import { createInvoiceObject } from "@/utils/validation-schema"; | ||
import ActionButton from "@/components/ActionButton.vue"; | ||
import { useI18n } from "vue-i18n"; | ||
import type { CreateInvoiceRequest } from "@sudosos/sudosos-client"; | ||
import { useAuthStore } from "@sudosos/sudosos-frontend-common"; | ||
import apiService from "@/services/ApiService"; | ||
import { useToast } from "primevue/usetoast"; | ||
import { handleError } from "@/utils/errorUtils"; | ||
const { t } = useI18n(); | ||
const toast = useToast(); | ||
const disabled = computed(() => { | ||
return !props.form?.context.meta.value.valid || getProperty(props.form, "forId") === undefined; | ||
}); | ||
const props = defineProps({ | ||
form: { | ||
type: Object as PropType<Form<yup.InferType<typeof createInvoiceObject>>>, | ||
required: true, | ||
}, | ||
}); | ||
const authStore = useAuthStore(); | ||
setSubmit(props.form, props.form.context.handleSubmit(async (values) => { | ||
const byId = authStore.user?.id; | ||
if (byId === undefined) { | ||
setSuccess(props.form, false); | ||
return; | ||
} | ||
const request: CreateInvoiceRequest = { | ||
forId: values.forId, | ||
byId, | ||
addressee: values.addressee, | ||
description: values.description, | ||
reference: values.reference, | ||
transactionIDs: values.transactionIDs, | ||
street: values.street, | ||
postalCode: values.postalCode, | ||
city: values.city, | ||
country: values.country, | ||
date: values.date, | ||
attention: values.attention, | ||
amount: values.transactionTotal, | ||
}; | ||
await apiService.invoices.createInvoice(request).then(() => { | ||
toast.add({ | ||
severity: 'success', | ||
summary: t('common.toast.success.success'), | ||
detail: t('common.toast.success.invoiceCreated'), | ||
life: 3000, | ||
}); | ||
setSuccess(props.form, true); | ||
props.form.context.resetForm(); | ||
}).catch((error) => { | ||
setSuccess(props.form, false); | ||
handleError(error, toast); | ||
}); | ||
})); | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
</style> |
35 changes: 35 additions & 0 deletions
35
...dashboard/src/modules/financial/components/invoice/create/InvoiceCreateAddressingCard.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<template> | ||
<FormCard :header="t('modules.financial.forms.invoice.addressing')" :enable-edit="false"> | ||
<div class="flex flex-column justify-content-between gap-2"> | ||
<InvoiceBaseAddressingForm :form="form" :edit="edit"/> | ||
</div> | ||
</FormCard> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import FormCard from "@/components/FormCard.vue"; | ||
import { computed, type PropType } from "vue"; | ||
import { createInvoiceObject } from "@/utils/validation-schema"; | ||
import { type Form, getProperty } from "@/utils/formUtils"; | ||
import { useI18n } from "vue-i18n"; | ||
import * as yup from "yup"; | ||
import InvoiceBaseAddressingForm from "@/modules/financial/components/invoice/forms/InvoiceBaseAddressingForm.vue"; | ||
const { t } = useI18n(); | ||
const edit = computed(() => { | ||
const forId = getProperty(props.form, "forId"); | ||
return forId !== undefined; | ||
}); | ||
const props = defineProps({ | ||
form: { | ||
type: Object as PropType<Form<yup.InferType<typeof createInvoiceObject>>>, | ||
required: true, | ||
}, | ||
}); | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
</style> |
36 changes: 36 additions & 0 deletions
36
apps/dashboard/src/modules/financial/components/invoice/create/InvoiceCreateSettingsCard.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<template> | ||
<FormCard :header="t('modules.financial.forms.invoice.settings')" :enable-edit="false"> | ||
<div class="flex flex-column justify-content-between gap-2"> | ||
<InvoiceBaseSettingsForm :form="form" :edit="edit"/> | ||
</div> | ||
</FormCard> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import FormCard from "@/components/FormCard.vue"; | ||
import { computed, type PropType } from "vue"; | ||
import { createInvoiceObject } from "@/utils/validation-schema"; | ||
import { type Form, getProperty } from "@/utils/formUtils"; | ||
import { useI18n } from "vue-i18n"; | ||
import * as yup from "yup"; | ||
import InvoiceBaseSettingsForm from "@/modules/financial/components/invoice/forms/InvoiceBaseSettingsForm.vue"; | ||
const { t } = useI18n(); | ||
const edit = computed(() => { | ||
const forId = getProperty(props.form, "forId"); | ||
return forId !== undefined; | ||
}); | ||
const props = defineProps({ | ||
form: { | ||
type: Object as PropType<Form<yup.InferType<typeof createInvoiceObject>>>, | ||
required: true, | ||
}, | ||
}); | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
</style> |
Oops, something went wrong.