Merge pull request 'fix(timesheet-approval): fix issue where expense wouldn't show correct expense type an refuse to update' (#66) from dev/nicolas/staging-prep into main
Reviewed-on: Targo/targo_frontend#66
This commit is contained in:
commit
0178cb610a
|
|
@ -33,6 +33,8 @@
|
||||||
const period_start_date = computed(() => timesheet_store.pay_period?.period_start.replaceAll('-', '/') ?? '');
|
const period_start_date = computed(() => timesheet_store.pay_period?.period_start.replaceAll('-', '/') ?? '');
|
||||||
const period_end_date = computed(() => timesheet_store.pay_period?.period_end.replaceAll('-', '/') ?? '');
|
const period_end_date = computed(() => timesheet_store.pay_period?.period_end.replaceAll('-', '/') ?? '');
|
||||||
|
|
||||||
|
const expense = defineModel<Expense>({ default: new Expense(new Date().toISOString().slice(0, 10)) })
|
||||||
|
|
||||||
const expense_options: ExpenseOption[] = [
|
const expense_options: ExpenseOption[] = [
|
||||||
{ label: t('timesheet.expense.types.PER_DIEM'), value: 'PER_DIEM', icon: getExpenseIcon('PER_DIEM') },
|
{ label: t('timesheet.expense.types.PER_DIEM'), value: 'PER_DIEM', icon: getExpenseIcon('PER_DIEM') },
|
||||||
{ label: t('timesheet.expense.types.EXPENSES'), value: 'EXPENSES', icon: getExpenseIcon('EXPENSES') },
|
{ label: t('timesheet.expense.types.EXPENSES'), value: 'EXPENSES', icon: getExpenseIcon('EXPENSES') },
|
||||||
|
|
@ -55,6 +57,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const requestExpenseCreationOrUpdate = async () => {
|
const requestExpenseCreationOrUpdate = async () => {
|
||||||
|
if (expenses_store.mode === 'update')
|
||||||
|
await expenses_api.upsertExpense(expenses_store.current_expense, timesheet_store.current_pay_period_overview?.email);
|
||||||
|
else
|
||||||
await expenses_api.upsertExpense(expenses_store.current_expense);
|
await expenses_api.upsertExpense(expenses_store.current_expense);
|
||||||
|
|
||||||
expenses_store.is_showing_create_form = true;
|
expenses_store.is_showing_create_form = true;
|
||||||
|
|
@ -63,13 +68,18 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
expense_selected.value = expense_options.find(expense => expense.value === expenses_store.current_expense.type);
|
if (expense.value)
|
||||||
|
expense_selected.value = expense_options.find(expense_option => expense_option.value === expense.value.type);
|
||||||
|
else
|
||||||
|
expense_selected.value = expense_options[1];
|
||||||
|
|
||||||
|
console.log('expense mount triggered: current expense type is ', expenses_store.current_expense.type, ', matching option is: ', expense_selected.value);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<q-form
|
<q-form
|
||||||
v-if="!timesheet_store.timesheets?.every(timesheet => timesheet.is_approved)"
|
v-if="!expenses_store.current_expense.is_approved"
|
||||||
flat
|
flat
|
||||||
@submit.prevent="requestExpenseCreationOrUpdate"
|
@submit.prevent="requestExpenseCreationOrUpdate"
|
||||||
class="full-width q-mt-md q-px-md"
|
class="full-width q-mt-md q-px-md"
|
||||||
|
|
@ -288,7 +298,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
:deep(.q-field--standout.q-field--readonly .q-field__control::before) {
|
:deep(.q-field--standout.q-field--readonly .q-field__control::before) {
|
||||||
border: transparent;
|
border: transparent;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -212,6 +212,6 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<ExpenseDialogForm />
|
<ExpenseDialogForm v-model="expense" />
|
||||||
</q-expansion-item>
|
</q-expansion-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -8,18 +8,19 @@ export const useExpensesApi = () => {
|
||||||
const expenses_store = useExpensesStore();
|
const expenses_store = useExpensesStore();
|
||||||
const timesheet_store = useTimesheetStore();
|
const timesheet_store = useTimesheetStore();
|
||||||
|
|
||||||
const upsertExpense = async (expense: Expense): Promise<void> => {
|
const upsertExpense = async (expense: Expense, employee_email?: string): Promise<void> => {
|
||||||
const success = await expenses_store.upsertExpense(expense);
|
const success = await expenses_store.upsertExpense(expense, employee_email);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
expenses_store.current_expense = new Expense(date.formatDate( new Date(), 'YYYY-MM-DD'));
|
expenses_store.current_expense = new Expense(date.formatDate( new Date(), 'YYYY-MM-DD'));
|
||||||
timesheet_store.getTimesheetsByOptionalEmployeeEmail();
|
timesheet_store.getTimesheetsByOptionalEmployeeEmail(employee_email);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteExpenseById = async (expense_id: number): Promise<void> => {
|
const deleteExpenseById = async (expense_id: number, employee_email?: string): Promise<void> => {
|
||||||
const success = await expenses_store.deleteExpenseById(expense_id);
|
const success = await expenses_store.deleteExpenseById(expense_id);
|
||||||
if (success) {
|
if (success) {
|
||||||
timesheet_store.getTimesheetsByOptionalEmployeeEmail();
|
timesheet_store.getTimesheetsByOptionalEmployeeEmail(employee_email);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,16 @@
|
||||||
import { useAuthStore } from "src/stores/auth-store";
|
|
||||||
import { useShiftStore } from "src/stores/shift-store";
|
import { useShiftStore } from "src/stores/shift-store";
|
||||||
import { useTimesheetStore } from "src/stores/timesheet-store";
|
import { useTimesheetStore } from "src/stores/timesheet-store";
|
||||||
|
|
||||||
export const useShiftApi = () => {
|
export const useShiftApi = () => {
|
||||||
const timesheet_store = useTimesheetStore();
|
const timesheet_store = useTimesheetStore();
|
||||||
const shift_store = useShiftStore();
|
const shift_store = useShiftStore();
|
||||||
const auth_store = useAuthStore();
|
|
||||||
|
|
||||||
const deleteShiftById = async (shift_id: number, employee_email?: string) => {
|
const deleteShiftById = async (shift_id: number, employee_email?: string) => {
|
||||||
timesheet_store.is_loading = true;
|
timesheet_store.is_loading = true;
|
||||||
const success = await shift_store.deleteShiftById(shift_id, employee_email);
|
const success = await shift_store.deleteShiftById(shift_id, employee_email);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
await timesheet_store.getTimesheetsByOptionalEmployeeEmail(auth_store.user?.email ?? '');
|
await timesheet_store.getTimesheetsByOptionalEmployeeEmail(employee_email);
|
||||||
}
|
}
|
||||||
|
|
||||||
timesheet_store.is_loading = false;
|
timesheet_store.is_loading = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user