mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
fix: Unicité des fees + utilisation de l'establishmentID [#44]
This commit is contained in:
@ -90,7 +90,7 @@ class PaymentModeType(models.IntegerChoices):
|
||||
CASH = 4, 'Espèce'
|
||||
|
||||
class Discount(models.Model):
|
||||
name = models.CharField(max_length=255, unique=True)
|
||||
name = models.CharField(max_length=255, null=True, blank=True)
|
||||
amount = models.DecimalField(max_digits=10, decimal_places=2, default=0)
|
||||
description = models.TextField(blank=True)
|
||||
discount_type = models.IntegerField(choices=DiscountType.choices, default=DiscountType.CURRENCY)
|
||||
@ -102,7 +102,7 @@ class Discount(models.Model):
|
||||
return self.name
|
||||
|
||||
class Fee(models.Model):
|
||||
name = models.CharField(max_length=255, unique=True)
|
||||
name = models.CharField(max_length=255, null=True, blank=True)
|
||||
base_amount = models.DecimalField(max_digits=10, decimal_places=2, default=0)
|
||||
description = models.TextField(blank=True)
|
||||
is_active = models.BooleanField(default=True)
|
||||
|
||||
@ -9,10 +9,10 @@ import MultiSelect from '@/components/MultiSelect';
|
||||
import LevelLabel from '@/components/CustomLabels/LevelLabel';
|
||||
import { DndProvider, useDrop } from 'react-dnd';
|
||||
import { HTML5Backend } from 'react-dnd-html5-backend';
|
||||
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
||||
import logger from '@/utils/logger';
|
||||
import ClasseDetails from '@/components/ClasseDetails';
|
||||
import SectionHeader from '@/components/SectionHeader';
|
||||
import { useEstablishment } from '@/context/EstablishmentContext';
|
||||
|
||||
const ItemTypes = {
|
||||
TEACHER: 'teacher',
|
||||
@ -28,6 +28,8 @@ const TeachersDropZone = ({
|
||||
classe.teachers_details || []
|
||||
);
|
||||
|
||||
const { selectedEstablishmentId } = useEstablishment();
|
||||
|
||||
useEffect(() => {}, [teachers]);
|
||||
|
||||
useEffect(() => {
|
||||
@ -194,7 +196,7 @@ const ClassesSection = ({
|
||||
number_of_students: '',
|
||||
school_year: '',
|
||||
teachers: [],
|
||||
establishment: ESTABLISHMENT_ID,
|
||||
establishment: selectedEstablishmentId,
|
||||
});
|
||||
setFormData({
|
||||
atmosphere_name: '',
|
||||
@ -203,7 +205,7 @@ const ClassesSection = ({
|
||||
number_of_students: '',
|
||||
school_year: '',
|
||||
teachers: [],
|
||||
establishment: ESTABLISHMENT_ID,
|
||||
establishment: selectedEstablishmentId,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -5,8 +5,8 @@ import Popup from '@/components/Popup';
|
||||
import CheckBox from '@/components/CheckBox';
|
||||
import InputText from '@/components/InputText';
|
||||
import logger from '@/utils/logger';
|
||||
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
||||
import SectionHeader from '@/components/SectionHeader';
|
||||
import { useEstablishment } from '@/context/EstablishmentContext';
|
||||
|
||||
const DiscountsSection = ({
|
||||
discounts,
|
||||
@ -29,6 +29,8 @@ const DiscountsSection = ({
|
||||
const [removePopupMessage, setRemovePopupMessage] = useState('');
|
||||
const [removePopupOnConfirm, setRemovePopupOnConfirm] = useState(() => {});
|
||||
|
||||
const { selectedEstablishmentId } = useEstablishment();
|
||||
|
||||
const handleAddDiscount = () => {
|
||||
setNewDiscount({
|
||||
id: Date.now(),
|
||||
@ -37,7 +39,7 @@ const DiscountsSection = ({
|
||||
description: '',
|
||||
discount_type: 0,
|
||||
type: type,
|
||||
establishment: ESTABLISHMENT_ID,
|
||||
establishment: selectedEstablishmentId,
|
||||
});
|
||||
};
|
||||
|
||||
@ -55,7 +57,11 @@ const DiscountsSection = ({
|
||||
|
||||
const handleSaveNewDiscount = () => {
|
||||
if (newDiscount.name && newDiscount.amount) {
|
||||
handleCreate(newDiscount)
|
||||
const discountData = {
|
||||
...newDiscount,
|
||||
establishment: selectedEstablishmentId,
|
||||
};
|
||||
handleCreate(discountData)
|
||||
.then((createdDiscount) => {
|
||||
setDiscounts([createdDiscount, ...discounts]);
|
||||
setNewDiscount(null);
|
||||
|
||||
@ -6,8 +6,7 @@ import CheckBox from '@/components/CheckBox';
|
||||
import InputText from '@/components/InputText';
|
||||
import logger from '@/utils/logger';
|
||||
import SectionHeader from '@/components/SectionHeader';
|
||||
|
||||
import { ESTABLISHMENT_ID } from '@/utils/Url';
|
||||
import { useEstablishment } from '@/context/EstablishmentContext';
|
||||
|
||||
const FeesSection = ({
|
||||
fees,
|
||||
@ -33,6 +32,7 @@ const FeesSection = ({
|
||||
const labelTypeFrais =
|
||||
type === 0 ? "Frais d'inscription" : 'Frais de scolarité';
|
||||
|
||||
const { selectedEstablishmentId } = useEstablishment();
|
||||
// Récupération des messages d'erreur
|
||||
const getError = (field) => {
|
||||
return localErrors?.[field]?.[0];
|
||||
@ -48,7 +48,7 @@ const FeesSection = ({
|
||||
validity_end_date: '',
|
||||
discounts: [],
|
||||
type: type,
|
||||
establishment: ESTABLISHMENT_ID,
|
||||
establishment: selectedEstablishmentId,
|
||||
});
|
||||
};
|
||||
|
||||
@ -64,7 +64,12 @@ const FeesSection = ({
|
||||
|
||||
const handleSaveNewFee = () => {
|
||||
if (newFee.name && newFee.base_amount) {
|
||||
handleCreate(newFee)
|
||||
const feeData = {
|
||||
...newFee,
|
||||
establishment: selectedEstablishmentId,
|
||||
};
|
||||
|
||||
handleCreate(feeData)
|
||||
.then((createdFee) => {
|
||||
setFees([createdFee, ...fees]);
|
||||
setNewFee(null);
|
||||
|
||||
@ -49,9 +49,6 @@ export const BE_SCHOOL_ESTABLISHMENT_URL = `${BASE_URL}/Establishment/establishm
|
||||
export const BE_PLANNING_PLANNINGS_URL = `${BASE_URL}/Planning/plannings`;
|
||||
export const BE_PLANNING_EVENTS_URL = `${BASE_URL}/Planning/events`;
|
||||
|
||||
// FIXME : En attendant la gestion des sessions
|
||||
export const ESTABLISHMENT_ID = 1;
|
||||
|
||||
// GESTION MESSAGERIE
|
||||
export const BE_GESTIONMESSAGERIE_MESSAGES_URL = `${BASE_URL}/GestionMessagerie/messages`;
|
||||
export const BE_GESTIONMESSAGERIE_MESSAGERIE_URL = `${BASE_URL}/GestionMessagerie/messagerie`;
|
||||
|
||||
Reference in New Issue
Block a user