@@ -87,17 +87,20 @@ const eventTimesSchema = Yup.array().when(
8787
8888const getPriceGroupsSchema = (
8989 isRegistrationPlanned : boolean ,
90- priceGroupOptions : PriceGroupOption [ ]
90+ priceGroupOptions : PriceGroupOption [ ] ,
91+ offersVatPercentage ?: string
9192) => {
92- return isRegistrationPlanned
93+ // Only validate price groups if registration is planned AND we have VAT percentage
94+ return isRegistrationPlanned && offersVatPercentage
9395 ? Yup . array ( ) . of ( getPriceGroupSchema ( priceGroupOptions ) )
9496 : Yup . array ( ) ;
9597} ;
9698
9799const createPaidOfferSchema = (
98100 isRegistrationPlanned : boolean ,
99101 eventInfoLanguage : string [ ] ,
100- priceGroupOptions : PriceGroupOption [ ]
102+ priceGroupOptions : PriceGroupOption [ ] ,
103+ offersVatPercentage ?: string
101104) =>
102105 Yup . object ( ) . shape ( {
103106 [ EVENT_OFFER_FIELDS . OFFER_PRICE ] : createMultiLanguageValidation (
@@ -124,7 +127,8 @@ const createPaidOfferSchema = (
124127 ? {
125128 [ EVENT_OFFER_FIELDS . OFFER_PRICE_GROUPS ] : getPriceGroupsSchema (
126129 isRegistrationPlanned ,
127- priceGroupOptions
130+ priceGroupOptions ,
131+ offersVatPercentage
128132 ) ,
129133 }
130134 : /* istanbul ignore next */
@@ -177,14 +181,16 @@ const validateOffers = (
177181 isRegistrationPlanned ,
178182 eventInfoLanguage ,
179183 priceGroupOptions ,
180- ] = values as [ boolean , boolean , string [ ] , PriceGroupOption [ ] ] ;
184+ offersVatPercentage ,
185+ ] = values as [ boolean , boolean , string [ ] , PriceGroupOption [ ] , string ] ;
181186
182187 return hasPrice
183188 ? schema . of (
184189 createPaidOfferSchema (
185190 isRegistrationPlanned ,
186191 eventInfoLanguage ,
187- priceGroupOptions
192+ priceGroupOptions ,
193+ offersVatPercentage
188194 )
189195 )
190196 : schema . of ( createFreeOfferSchema ( eventInfoLanguage ) ) ;
@@ -515,6 +521,7 @@ export const publicEventSchema = Yup.object().shape(
515521 EVENT_FIELDS . IS_REGISTRATION_PLANNED ,
516522 EVENT_FIELDS . EVENT_INFO_LANGUAGES ,
517523 EVENT_FIELDS . PRICE_GROUP_OPTIONS ,
524+ EVENT_FIELDS . OFFERS_VAT_PERCENTAGE ,
518525 ] ,
519526 validateOffers
520527 ) ,
@@ -603,7 +610,13 @@ export const draftEventSchema = Yup.object().shape(
603610 [ EVENT_FIELDS . OFFERS ] : Yup . array ( )
604611 . min ( 1 , VALIDATION_MESSAGE_KEYS . OFFERS_REQUIRED )
605612 . when (
606- [ EVENT_FIELDS . HAS_PRICE , EVENT_FIELDS . EVENT_INFO_LANGUAGES ] ,
613+ [
614+ EVENT_FIELDS . HAS_PRICE ,
615+ EVENT_FIELDS . IS_REGISTRATION_PLANNED ,
616+ EVENT_FIELDS . EVENT_INFO_LANGUAGES ,
617+ EVENT_FIELDS . PRICE_GROUP_OPTIONS ,
618+ EVENT_FIELDS . OFFERS_VAT_PERCENTAGE ,
619+ ] ,
607620 validateOffers
608621 ) ,
609622 [ EVENT_FIELDS . INFO_URL ] : createMultiLanguageValidationByInfoLanguages (
0 commit comments