Skip to content

Commit

Permalink
Merge branch 'hotfix/0.23.1' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
polosson committed Dec 16, 2023
2 parents 10af312 + e628010 commit 639c32a
Show file tree
Hide file tree
Showing 49 changed files with 415 additions and 218 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ Tous les changements notables sur le projet sont documentés dans ce fichier.

Ce projet adhère au principe du [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.23.1 (2023-12-16)

- Les fiches de sorties des événements peuvent être éditées même en l'absence d'un bénéficiaire.
- Désactive TEMPORAIREMENT la vérification de l'absence de pénuries dans les inventaires de départ / retour
en attendant la gestion horaire des événements / réservations (sans quoi cela pouvait être problématique
pour les événements / réservations avec retour / départ le même jour)
- Corrige une incohérence au niveau de la limitation de la remise applicable aux événements contenant du
matériel non remisable. Le système proposait de définir un pourcentage de remise sur la totalité du prix
(en fonction du matériel remisable) mais limitait l'application de ce pourcentage à la partie remisable (#402).
Seuls les nouveaux devis / factures utiliseront ce nouveau mode de fonctionnement, plus logique, les anciens
devis / factures ne seront évidemment pas modifies (les données étant de toute façon figées).
- Corrige une erreur 403 qui s'affichait lorsqu'un serveur HTTP de type Apache était utilisé pour "servir" l'application.

## 0.23.0 (2023-12-14)

- Mise à jour des dépendances du projet.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.23.0
0.23.1
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import Button from '@/themes/default/components/Button';

// @vue/component
export default {
name: 'BillingForm',
name: 'EventDetailsBillingForm',
props: {
discountRate: { type: Number, required: true },
discountTarget: { type: Number, required: true },
maxRate: { type: Object, default: () => new Decimal(100) },
minAmount: { type: Object, default: undefined },
maxAmount: { type: Object, default: undefined },
loading: { type: Boolean, default: false },
beneficiary: { type: Object, default: undefined },
Expand Down Expand Up @@ -41,30 +42,21 @@ export default {
methods: {
handleChangeRate(givenValue) {
const rate = new Decimal(givenValue);

if (rate.isNaN() || !rate.isFinite()) {
return;
}

const value = rate.clampedTo(0, this.maxRate);

this.$emit('change', { field: 'rate', value });
},

handleChangeAmount(givenValue) {
const amount = new Decimal(givenValue);

if (amount.isNaN() || !amount.isFinite()) {
return;
}

let max = new Decimal(Infinity);
if (amount.greaterThan(this.maxAmount ?? Infinity)) {
max = Decimal.clone(this.maxAmount);
}

const value = amount.clampedTo(0, max);

const value = amount.clampedTo(0, this.maxAmount ?? Infinity);
this.$emit('change', { field: 'amount', value });
},

Expand All @@ -85,6 +77,7 @@ export default {
saveLabel,
beneficiary,
maxRate,
minAmount,
maxAmount,
isDiscountable,
discountRate,
Expand All @@ -97,21 +90,21 @@ export default {

const classNames = [
'Form',
'BillingForm',
{ 'BillingForm--not-discountable': !isDiscountable },
'EventDetailsBillingForm',
{ 'EventDetailsBillingForm--not-discountable': !isDiscountable },
];

return (
<form class={classNames} onSubmit={handleSubmit}>
{!isDiscountable && (
<p class="BillingForm__no-discount">{__('no-discount-applicable')}</p>
<p class="EventDetailsBillingForm__no-discount">{__('no-discount-applicable')}</p>
)}
{isDiscountable && (
<Fragment>
<FormField
type="number"
label="wanted-discount-rate"
class="BillingForm__discount-input"
class="EventDetailsBillingForm__discount-input"
name="discountRate"
disabled={loading}
value={discountRate}
Expand All @@ -129,29 +122,29 @@ export default {
<FormField
type="number"
label="wanted-total-amount"
class="BillingForm__discount-target-input"
class="EventDetailsBillingForm__discount-target-input"
name="discountTarget"
disabled={loading}
value={targetAmount}
step={0.01}
min={0}
max={maxAmount.toNumber()}
min={minAmount?.toNumber() ?? undefined}
max={maxAmount?.toNumber() ?? undefined}
addon={currency}
onChange={handleChangeAmount}
/>
</Fragment>
)}
{!!beneficiary && (
<div class="BillingForm__beneficiary">
<div class="BillingForm__beneficiary__label">
<div class="EventDetailsBillingForm__beneficiary">
<div class="EventDetailsBillingForm__beneficiary__label">
{__('beneficiary')}
</div>
<div class="BillingForm__beneficiary__name">
<div class="EventDetailsBillingForm__beneficiary__name">
{beneficiary.full_name}
</div>
</div>
)}
<div class="BillingForm__save">
<div class="EventDetailsBillingForm__save">
<Button htmlType="submit" type="primary" loading={loading}>
{saveLabel}
</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@use '~@/themes/default/style/globals';

.BillingForm {
.EventDetailsBillingForm {
$block: &;

&__no-discount {
margin: 0;
text-align: center;
Expand Down Expand Up @@ -35,15 +37,15 @@
flex-direction: column;
align-items: center;

.BillingForm__beneficiary {
#{$block}__beneficiary {
text-align: center;

&__label {
flex: 0 0 auto;
}
}

.BillingForm__save {
#{$block}__save {
padding: 0;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,7 @@ const EventDetailsHeaderActions = defineComponent({

isPrintable() {
const { event, hasMaterials } = this;
return (
event.materials &&
hasMaterials &&
event.beneficiaries &&
event.beneficiaries.length > 0
);
return event.materials && hasMaterials;
},

isRemovable() {
Expand Down Expand Up @@ -285,7 +280,7 @@ const EventDetailsHeaderActions = defineComponent({
isDeleting,
hasStarted,
hasMaterials,
hasMaterialShortage,
// hasMaterialShortage,
isDepartureInventoryPeriodOpen,
isDepartureInventoryPeriodClosed,
isDepartureInventoryDone,
Expand All @@ -308,8 +303,15 @@ const EventDetailsHeaderActions = defineComponent({
(isDepartureInventoryDone || !isDepartureInventoryPeriodClosed)
);

const isReturnInventoryUnavailable = !isReturnInventoryDone && hasMaterialShortage;
const isDepartureInventoryUnavailable = !isDepartureInventoryDone && hasMaterialShortage;
// FIXME: À re-activer lorsque les inventaires de retour terminés
// rendront disponibles les stocks utilisés dans l'événement
// (en bougeant la date de fin de mobilisation) OU quand la
// gestion horaire aura été implémentée.
// Sans ça, pour les événements qui partent juste après un autre
// dont l'inventaire de retour a été terminé, sur un même jour,
// on est bloqué car le système pense qu'il y a une pénurie.
const isReturnInventoryUnavailable = false; // !isReturnInventoryDone && hasMaterialShortage;
const isDepartureInventoryUnavailable = false; // !isDepartureInventoryDone && hasMaterialShortage;

// - Si la période de tous les inventaires a commencé et qu'ils sont tous indisponible
// à cause du matériel manquant, on affiche qu'un seul bouton désactivé.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Actions from './Actions';

// @vue/component
export default {
name: 'CalendarEventDetailsHeader',
name: 'EventDetailsHeader',
props: {
event: { type: Object, required: true },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { Document } from '@/stores/api/documents';
import type { Event } from '@/stores/api/events';

type Props = {
/** L'événement dont on veut gérer les documents. */
/** L'événement dont on souhaite gérer les documents. */
event: Event,
};

Expand All @@ -23,7 +23,7 @@ type Data = {
documents: Document[],
};

// @vue/component
/** L'onglet "Documents" de la modale de détails d'un événement. */
const EventDetailsDocuments = defineComponent({
name: 'EventDetailsDocuments',
props: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { round } from '@/utils/decimalRound';
import Fragment from '@/components/Fragment';
import Icon from '@/themes/default/components/Icon';
import Button from '@/themes/default/components/Button';
import Form from '@/themes/default/components/BillingForm';
import Form from '../../components/BillingForm';
import Estimate from './Estimate';

// @vue/component
Expand Down Expand Up @@ -59,11 +59,19 @@ const EventDetailsEstimates = defineComponent({
maxDiscountRate() {
const { event, totalDiscountable } = this;
const { total_without_taxes: totalWithoutTaxes } = event;
if (totalWithoutTaxes <= 0) {
return new Decimal(0);
}

return (totalDiscountable.times(100)).div(totalWithoutTaxes);
return totalWithoutTaxes > 0
? (totalDiscountable.times(100)).div(totalWithoutTaxes)
: new Decimal(0);
},

minTotalAmount() {
const { event, totalDiscountable } = this;
const { total_without_taxes: totalWithoutTaxes } = event;

return totalWithoutTaxes > 0
? totalWithoutTaxes.sub(totalDiscountable)
: new Decimal(0);
},

discountRate: {
Expand All @@ -81,11 +89,12 @@ const EventDetailsEstimates = defineComponent({

discountTarget: {
get() {
const { event, discountRate, totalDiscountable } = this;
const { event, discountRate, minTotalAmount } = this;
const { total_without_taxes: totalWithoutTaxes } = event;
const discountAmount = totalDiscountable.times(discountRate / 100);

return totalWithoutTaxes.sub(discountAmount).toNumber();
const discountAmount = totalWithoutTaxes.times(discountRate / 100);
const totalAmount = totalWithoutTaxes.sub(discountAmount).toNumber();
return Math.max(totalAmount, minTotalAmount.toNumber());
},
set(value) {
const { event, totalDiscountable, maxDiscountRate } = this;
Expand All @@ -101,7 +110,7 @@ const EventDetailsEstimates = defineComponent({
discountAmount = totalDiscountable;
}

const rate = (discountAmount.div(totalDiscountable)).times(100).toNumber();
const rate = discountAmount.times(100).div(totalWithoutTaxes).toNumber();
this.unsavedDiscountRate = Math.min(round(rate, 4), maxDiscountRate.toNumber());
},
},
Expand Down Expand Up @@ -174,6 +183,7 @@ const EventDetailsEstimates = defineComponent({
discountRate,
discountTarget,
maxDiscountRate,
minTotalAmount,
isCreating,
hasInvoice,
hasEstimate,
Expand Down Expand Up @@ -269,6 +279,7 @@ const EventDetailsEstimates = defineComponent({
<Form
discountRate={discountRate}
discountTarget={discountTarget}
minAmount={minTotalAmount}
maxAmount={totalWithoutTaxes}
maxRate={maxDiscountRate}
beneficiary={event.beneficiaries[0]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import './index.scss';
import invariant from 'invariant';
import Decimal from 'decimal.js';
import { defineComponent } from '@vue/composition-api';
import getEventDiscountRate from '@/utils/getEventDiscountRate';
import { round } from '@/utils/decimalRound';
import apiEvents from '@/stores/api/events';
import { Group } from '@/stores/api/groups';
import Fragment from '@/components/Fragment';
import Icon from '@/themes/default/components/Icon';
import Button from '@/themes/default/components/Button';
import Link from '@/themes/default/components/Link';
import Form from '@/themes/default/components/BillingForm';
import Fragment from '@/components/Fragment';
import Form from '../../components/BillingForm';
import Invoice, { InvoiceLayout } from './Invoice';
import getEventDiscountRate from '@/utils/getEventDiscountRate';
import { round } from '@/utils/decimalRound';

// @vue/component
const EventDetailsInvoices = defineComponent({
Expand Down Expand Up @@ -68,11 +68,19 @@ const EventDetailsInvoices = defineComponent({
maxDiscountRate() {
const { event, totalDiscountable } = this;
const { total_without_taxes: totalWithoutTaxes } = event;
if (totalWithoutTaxes <= 0) {
return new Decimal(0);
}

return (totalDiscountable.times(100)).div(totalWithoutTaxes);
return totalWithoutTaxes > 0
? (totalDiscountable.times(100)).div(totalWithoutTaxes)
: new Decimal(0);
},

minTotalAmount() {
const { event, totalDiscountable } = this;
const { total_without_taxes: totalWithoutTaxes } = event;

return totalWithoutTaxes > 0
? totalWithoutTaxes.sub(totalDiscountable)
: new Decimal(0);
},

discountRate: {
Expand All @@ -90,11 +98,12 @@ const EventDetailsInvoices = defineComponent({

discountTarget: {
get() {
const { event, discountRate, totalDiscountable } = this;
const { event, discountRate, minTotalAmount } = this;
const { total_without_taxes: totalWithoutTaxes } = event;
const discountAmount = totalDiscountable.times(discountRate / 100);

return totalWithoutTaxes.sub(discountAmount).toNumber();
const discountAmount = totalWithoutTaxes.times(discountRate / 100);
const totalAmount = totalWithoutTaxes.sub(discountAmount).toNumber();
return Math.max(totalAmount, minTotalAmount.toNumber());
},
set(value) {
const { event, totalDiscountable, maxDiscountRate } = this;
Expand All @@ -110,7 +119,7 @@ const EventDetailsInvoices = defineComponent({
discountAmount = totalDiscountable;
}

const rate = (discountAmount.div(totalDiscountable)).times(100).toNumber();
const rate = discountAmount.times(100).div(totalWithoutTaxes).toNumber();
this.unsavedDiscountRate = Math.min(round(rate, 4), maxDiscountRate.toNumber());
},
},
Expand Down Expand Up @@ -181,6 +190,7 @@ const EventDetailsInvoices = defineComponent({
discountRate,
discountTarget,
maxDiscountRate,
minTotalAmount,
isCreating,
hasEstimate,
hasRequestedForm,
Expand Down Expand Up @@ -291,6 +301,7 @@ const EventDetailsInvoices = defineComponent({
<Form
discountRate={discountRate}
discountTarget={discountTarget}
minAmount={minTotalAmount}
maxAmount={totalWithoutTaxes}
maxRate={maxDiscountRate}
beneficiary={event.beneficiaries[0]}
Expand Down
Loading

0 comments on commit 639c32a

Please sign in to comment.