Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const env = {
MANAGEMENT_FEES_BILLING_ITEM: process.env.MANAGEMENT_FEES_BILLING_ITEM,
TRAINER_FEES_BILLING_ITEM: process.env.TRAINER_FEES_BILLING_ITEM,
CONSULTING_PROGRAM_IDS: process.env.CONSULTING_PROGRAM_IDS,
BILLING_COMPANI_EMAIL: process.env.BILLING_COMPANI_EMAIL,
};

export const parseEnv = environment => Object.keys(environment).reduce((acc, key) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@
<router-link :to="goToCourse" @click.stop>
<span class="text-weight-bold text-copper-500 clickable-name">{{ courseName }}</span>
</router-link>
<div v-if="hasPlannedSalary">Honoraires prévus : {{ formatPrice(course.plannedSalary) }}</div>
<div :class="{ 'text-red-800': course.plannedSalary && course.invoicedAmount > course.plannedSalary }">
Montant déjà facturé : {{ formatPrice(course.invoicedAmount) }}
</div>
<div>Montant réglé : {{ formatPrice(course.paidAmount) }}</div>
<template v-if="!isPaidBeforeBillingSystem">
<div v-if="hasPlannedSalary">Honoraires prévus : {{ formatPrice(course.plannedSalary) }}</div>
<div :class="{ 'text-red-800': course.plannedSalary && course.invoicedAmount > course.plannedSalary }">
Montant déjà facturé : {{ formatPrice(course.invoicedAmount) }}
</div>
<div>Montant réglé : {{ formatPrice(course.paidAmount) }}</div>
</template>
<div :class="['text-weight-bold', TRAINER_COURSE_BILLING_STATUS_COLORS[course.status]]">
<span v-if="formattedBillingDates">
{{ TRAINER_COURSE_BILLING_STATUS[course.status] }} le {{ formattedBillingDates }}
</span>
<span v-else>{{ TRAINER_COURSE_BILLING_STATUS[course.status] }}</span>
</div>
</div>
<ni-primary-button v-if="isTrainer" label="Facturer le groupe" :disabled="isBilled"
<ni-primary-button v-if="isTrainer" label="Facturer le groupe" :disabled="isBilled || isPaidBeforeBillingSystem"
@click="$emit('bill', course)" />
</div>
</q-card>
Expand Down Expand Up @@ -62,6 +64,9 @@ export default {

const isBilled = computed(() => hasPlannedSalary.value && [INVOICED, PAID].includes(course.value.status));

// Courses ended before trainer billing was tracked in the app (01/10/2026) are paid without any bill
const isPaidBeforeBillingSystem = computed(() => course.value.status === PAID && !course.value.invoicedAmount);

const goToCourse = computed(() => ({
name: isTrainer.value ? 'trainers courses info' : 'ni management blended courses info',
params: { courseId: course.value._id },
Expand All @@ -82,6 +87,7 @@ export default {
courseName,
hasPlannedSalary,
isBilled,
isPaidBeforeBillingSystem,
goToCourse,
formattedBillingDates,
// Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<template #header>
<div class="full-width items-center">
<span class="text-copper-500">{{ formatIdentity(trainer.identity, 'FL') }}</span>
<div class="q-py-sm">
<div class="q-py-sm" v-if="displayTotals">
<span class="text-weight-bold text-orange-500">
Non facturé : {{ formatPrice(totals.notInvoiced) }}
<template v-if="hasMissingPlannedSalary">&nbsp;(honoraires manquants)</template>
Expand All @@ -25,6 +25,7 @@
import { computed, ref, toRefs } from 'vue';
import { formatIdentity, formatPrice } from '@helpers/utils';
import { add, subtract, isGreaterThan, toNumber } from '@helpers/numbers';
import { PAID } from '@data/constants';
import CollectiveCourseBillingItem from 'src/modules/vendor/components/billing/CollectiveCourseBillingItem';

export default {
Expand All @@ -43,17 +44,21 @@ export default {
const totals = computed(() => {
const { invoiced, notInvoiced, paid } = (trainer.value.courses || []).reduce((acc, course) => {
const remaining = subtract(course.plannedSalary || 0, course.invoicedAmount);
const isNotInvoiced = course.status !== PAID && isGreaterThan(remaining, 0);
Comment thread
ulysseferreira marked this conversation as resolved.
Resolved

return {
invoiced: add(acc.invoiced, course.invoicedAmount),
notInvoiced: isGreaterThan(remaining, 0) ? add(acc.notInvoiced, remaining) : acc.notInvoiced,
notInvoiced: isNotInvoiced ? add(acc.notInvoiced, remaining) : acc.notInvoiced,
paid: add(acc.paid, course.paidAmount),
};
}, { invoiced: 0, notInvoiced: 0, paid: 0 });

return { invoiced: toNumber(invoiced), notInvoiced: toNumber(notInvoiced), paid: toNumber(paid) };
});

const displayTotals = computed(() => Object.values(trainer.value.courses || {})
.some(course => course.status !== PAID));

const hasMissingPlannedSalary = computed(() => (trainer.value.courses || []).some(c => !c.plannedSalary));

return {
Expand All @@ -62,6 +67,7 @@ export default {
// Computed
totals,
hasMissingPlannedSalary,
displayTotals,
// Methods
formatIdentity,
formatPrice,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<template>
<div>
<ni-banner icon="warning" class="bg-peach-200">
<template #message>
Les groupes de formation terminés et archivés avant le 01/09/2026 sont considérés réglés dans l'outil.
</template>
</ni-banner>
<div class="row justify-end">
<ni-button icon="chevron_left" class="no-shadow" @click="goToPreviousMonth" />
<ni-date-range class="col-md-6 col-xs-12" caption="Période" v-model="dateRange" :error="v$.dateRange.$error"
Expand Down Expand Up @@ -29,6 +34,7 @@ import useVuelidate from '@vuelidate/core';
import DateRange from '@components/form/DateRange';
import Select from '@components/form/Select';
import Button from '@components/Button';
import Banner from '@components/Banner';
import { NotifyWarning } from '@components/popup/notify';
import { MONTH } from '@data/constants';
import CompaniDate from '@helpers/dates/companiDates';
Expand All @@ -42,6 +48,7 @@ export default {
'ni-date-range': DateRange,
'ni-select': Select,
'ni-button': Button,
'ni-banner': Banner,
'collective-courses-billing-card': CollectiveCoursesBillingCard,
},
setup () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
Facturé : {{ formatStringToPrice(totals.invoiced) }} / Réglé : {{ formatStringToPrice(totals.paid) }}
</template>
</ni-banner>
<ni-banner icon="warning" class="bg-peach-200">
<template #message>
Les groupes de formation terminés et archivés avant le 01/09/2026 sont considérés réglés dans l'outil.
Si vous ne les avez pas encore facturés, merci d’envoyer vos factures à {{ BILLING_COMPANI_EMAIL }}.
</template>
</ni-banner>
<div class="reset-filters" @click="resetFilters">Effacer les filtres</div>
<div class="filters-container">
<ni-select caption="Programme de formation" clearable :options="programOptions" v-model="selectedProgram" />
Expand Down Expand Up @@ -39,6 +45,7 @@ import { NotifyNegative, NotifyPositive, NotifyWarning } from '@components/popup
import TrainerBills from '@api/TrainerBills';
import { formatPrice, formatStringToPrice } from '@helpers/utils';
import { add } from '@helpers/numbers';
import { PAID } from '@data/constants';
import { strictPositiveNumber } from '@helpers/vuelidateCustomVal';
import { useTrainerCollectiveCoursesBillingInfos } from '@composables/trainerCollectiveCoursesBillingInfos';
import CollectiveCourseBillingItem from 'src/modules/vendor/components/billing/CollectiveCourseBillingItem';
Expand All @@ -57,7 +64,7 @@ export default {

const $store = useStore();
const $q = useQuasar();

const { BILLING_COMPANI_EMAIL } = process.env;
const loggedUser = computed(() => $store.state.main.loggedUser);
const userProfile = computed(() => $store.state.userProfile.userProfile);

Expand All @@ -80,11 +87,17 @@ export default {

const filteredCourses = computed(() => get(filteredData.value, '[0].courses') || []);

const totals = computed(() => trainerCourses.value.reduce((acc, course) => ({
plannedSalary: add(acc.plannedSalary, course.plannedSalary || 0),
invoiced: add(acc.invoiced, course.invoicedAmount),
paid: add(acc.paid, course.paidAmount),
}), { plannedSalary: 0, invoiced: 0, paid: 0 }));
const totals = computed(() => trainerCourses.value.reduce((acc, course) => {
const isPaidBeforeBillingSystem = course.status === PAID && !course.invoicedAmount;

return {
plannedSalary: isPaidBeforeBillingSystem
? acc.plannedSalary
: add(acc.plannedSalary, course.plannedSalary || 0),
invoiced: add(acc.invoiced, course.invoicedAmount),
paid: add(acc.paid, course.paidAmount),
};
}, { plannedSalary: 0, invoiced: 0, paid: 0 }));

const billModal = ref(false);
const billLoading = ref(false);
Expand Down Expand Up @@ -161,6 +174,7 @@ export default {
selectedCourse,
bill,
validations,
BILLING_COMPANI_EMAIL,
// Computed
filteredCourses,
programOptions,
Expand Down