1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-22 11:52:21 +01:00

Merge branch 'pre_inscription' into staging

This commit is contained in:
Du Peng 2023-08-31 17:15:35 +02:00
commit 35735a7405
6 changed files with 107 additions and 8 deletions

View File

@ -238,7 +238,10 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', '
$scope.changeNbPlaces = function (priceType) {
let reservedPlaces = 0;
if ($scope.event.event_type === 'family') {
reservedPlaces = $scope.reservations.reduce((sum, reservation) => {
const reservations = $scope.reservations.filter((reservation) => {
return !reservation.slots_reservations_attributes[0].canceled_at;
});
reservedPlaces = reservations.reduce((sum, reservation) => {
return sum + reservation.booking_users_attributes.length;
}, 0);
}
@ -742,7 +745,10 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', '
}
}
}
for (const r of $scope.reservations) {
const reservations = $scope.reservations.filter((reservation) => {
return !reservation.slots_reservations_attributes[0].canceled_at;
});
for (const r of reservations) {
for (const user of r.booking_users_attributes) {
const key = user.booked_type === 'User' ? `user_${user.booked_id}` : `child_${user.booked_id}`;
if (key === userKey) {
@ -784,7 +790,10 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', '
*/
const updateNbReservePlaces = function () {
if ($scope.event.event_type === 'family' && $scope.ctrl.member.id) {
const reservedPlaces = $scope.reservations.reduce((sum, reservation) => {
const reservations = $scope.reservations.filter((reservation) => {
return !reservation.slots_reservations_attributes[0].canceled_at;
});
const reservedPlaces = reservations.reduce((sum, reservation) => {
return sum + reservation.booking_users_attributes.length;
}, 0);
const maxPlaces = $scope.children.length + 1 - reservedPlaces;

View File

@ -69,13 +69,17 @@ class ReservationConfirmPaymentService
[@reservation],
@reservation.user
)
return invoice if Setting.get('prevent_invoices_zero') && price[:total].zero?
if Setting.get('prevent_invoices_zero') && price[:total].zero?
@reservation.slots_reservations.first.update(is_confirm: true)
return invoice
end
ActiveRecord::Base.transaction do
WalletService.debit_user_wallet(invoice, @reservation.user)
invoice.save
invoice.post_save
@reservation.slots_reservations.first.update(is_confirm: true)
end
invoice
end

View File

@ -88,7 +88,7 @@ json.events_reservations @member.reservations.where(reservable_type: 'Event').jo
json.event_title sr.reservation.reservable.title
json.event_pre_registration sr.reservation.reservable.pre_registration
json.is_valid sr.is_valid
json.is_paid sr.reservation.invoice_items.count.positive?
json.is_paid sr.is_confirm
json.amount sr.reservation.invoice_items.sum(:amount)
json.canceled_at sr.canceled_at
json.booking_users_attributes sr.reservation.booking_users.order(booked_type: :desc) do |bu|

View File

@ -43,4 +43,4 @@ json.booking_users_attributes reservation.booking_users.order(booked_type: :desc
json.age ((Time.zone.now - bu.booked.birthday.to_time) / 1.year.seconds).floor if bu.booked_type == 'Child'
end
json.is_valid reservation.slots_reservations[0].is_valid
json.is_paid reservation.invoice_items.count.positive?
json.is_paid reservation.slots_reservations[0].is_confirm

View File

@ -0,0 +1,16 @@
# frozen_string_literal: true
# add is_confirm to slots_reservations
class AddIsConfirmToSlotsReservations < ActiveRecord::Migration[7.0]
def up
add_column :slots_reservations, :is_confirm, :boolean
SlotsReservation.reset_column_information
SlotsReservation.all.each do |sr|
sr.update_column(:is_confirm, true) if sr.is_valid && sr.reservation.invoice_items.count.positive?
end
end
def down
remove_column :slots_reservations, :is_confirm
end
end

View File

@ -2240,6 +2240,41 @@ CREATE SEQUENCE public.payment_gateway_objects_id_seq
ALTER SEQUENCE public.payment_gateway_objects_id_seq OWNED BY public.payment_gateway_objects.id;
--
-- Name: payment_infos; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.payment_infos (
id bigint NOT NULL,
data jsonb,
state character varying,
payment_for character varying,
service character varying,
statistic_profile_id bigint,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL
);
--
-- Name: payment_infos_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.payment_infos_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: payment_infos_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.payment_infos_id_seq OWNED BY public.payment_infos.id;
--
-- Name: payment_schedule_items; Type: TABLE; Schema: public; Owner: -
--
@ -3315,7 +3350,8 @@ CREATE TABLE public.slots_reservations (
ex_end_at timestamp without time zone,
canceled_at timestamp without time zone,
offered boolean DEFAULT false,
is_valid boolean
is_valid boolean,
is_confirm boolean
);
@ -4869,6 +4905,13 @@ ALTER TABLE ONLY public.organizations ALTER COLUMN id SET DEFAULT nextval('publi
ALTER TABLE ONLY public.payment_gateway_objects ALTER COLUMN id SET DEFAULT nextval('public.payment_gateway_objects_id_seq'::regclass);
--
-- Name: payment_infos id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.payment_infos ALTER COLUMN id SET DEFAULT nextval('public.payment_infos_id_seq'::regclass);
--
-- Name: payment_schedule_items id; Type: DEFAULT; Schema: public; Owner: -
--
@ -5798,6 +5841,14 @@ ALTER TABLE ONLY public.payment_gateway_objects
ADD CONSTRAINT payment_gateway_objects_pkey PRIMARY KEY (id);
--
-- Name: payment_infos payment_infos_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.payment_infos
ADD CONSTRAINT payment_infos_pkey PRIMARY KEY (id);
--
-- Name: payment_schedule_items payment_schedule_items_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@ -6996,6 +7047,13 @@ CREATE INDEX index_payment_gateway_objects_on_item_type_and_item_id ON public.pa
CREATE INDEX index_payment_gateway_objects_on_payment_gateway_object_id ON public.payment_gateway_objects USING btree (payment_gateway_object_id);
--
-- Name: index_payment_infos_on_statistic_profile_id; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX index_payment_infos_on_statistic_profile_id ON public.payment_infos USING btree (statistic_profile_id);
--
-- Name: index_payment_schedule_items_on_invoice_id; Type: INDEX; Schema: public; Owner: -
--
@ -7820,6 +7878,14 @@ ALTER TABLE ONLY public.payment_schedules
ADD CONSTRAINT fk_rails_00308dc223 FOREIGN KEY (wallet_transaction_id) REFERENCES public.wallet_transactions(id);
--
-- Name: payment_infos fk_rails_0308366a58; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.payment_infos
ADD CONSTRAINT fk_rails_0308366a58 FOREIGN KEY (statistic_profile_id) REFERENCES public.statistic_profiles(id);
--
-- Name: cart_item_event_reservation_booking_users fk_rails_0964335a37; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@ -9184,4 +9250,8 @@ INSERT INTO "schema_migrations" (version) VALUES
('20230718134350'),
('20230720085857'),
('20230728072726'),
('20230728090257');
('20230728090257'),
('20230825101952'),
('20230831103208');