Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
-- Test draft_payment
set client_min_messages to warning ;
create extension if not exists pgtap ;
reset client_min_messages ;
begin ;
2024-03-14 21:08:01 +00:00
select plan ( 17 ) ;
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
set search_path to camper , public ;
2024-03-14 21:08:01 +00:00
select has_function ( ' camper ' , ' draft_payment ' , array [ ' uuid ' , ' date ' , ' date ' , ' uuid ' , ' integer ' , ' integer ' , ' integer ' , ' integer ' , ' text ' , ' boolean ' , ' option_units[] ' ] ) ;
select function_lang_is ( ' camper ' , ' draft_payment ' , array [ ' uuid ' , ' date ' , ' date ' , ' uuid ' , ' integer ' , ' integer ' , ' integer ' , ' integer ' , ' text ' , ' boolean ' , ' option_units[] ' ] , ' plpgsql ' ) ;
select function_returns ( ' camper ' , ' draft_payment ' , array [ ' uuid ' , ' date ' , ' date ' , ' uuid ' , ' integer ' , ' integer ' , ' integer ' , ' integer ' , ' text ' , ' boolean ' , ' option_units[] ' ] , ' payment ' ) ;
select isnt_definer ( ' camper ' , ' draft_payment ' , array [ ' uuid ' , ' date ' , ' date ' , ' uuid ' , ' integer ' , ' integer ' , ' integer ' , ' integer ' , ' text ' , ' boolean ' , ' option_units[] ' ] ) ;
select volatility_is ( ' camper ' , ' draft_payment ' , array [ ' uuid ' , ' date ' , ' date ' , ' uuid ' , ' integer ' , ' integer ' , ' integer ' , ' integer ' , ' text ' , ' boolean ' , ' option_units[] ' ] , ' volatile ' ) ;
select function_privs_are ( ' camper ' , ' draft_payment ' , array [ ' uuid ' , ' date ' , ' date ' , ' uuid ' , ' integer ' , ' integer ' , ' integer ' , ' integer ' , ' text ' , ' boolean ' , ' option_units[] ' ] , ' guest ' , array [ ' EXECUTE ' ] ) ;
select function_privs_are ( ' camper ' , ' draft_payment ' , array [ ' uuid ' , ' date ' , ' date ' , ' uuid ' , ' integer ' , ' integer ' , ' integer ' , ' integer ' , ' text ' , ' boolean ' , ' option_units[] ' ] , ' employee ' , array [ ' EXECUTE ' ] ) ;
select function_privs_are ( ' camper ' , ' draft_payment ' , array [ ' uuid ' , ' date ' , ' date ' , ' uuid ' , ' integer ' , ' integer ' , ' integer ' , ' integer ' , ' text ' , ' boolean ' , ' option_units[] ' ] , ' admin ' , array [ ' EXECUTE ' ] ) ;
select function_privs_are ( ' camper ' , ' draft_payment ' , array [ ' uuid ' , ' date ' , ' date ' , ' uuid ' , ' integer ' , ' integer ' , ' integer ' , ' integer ' , ' text ' , ' boolean ' , ' option_units[] ' ] , ' authenticator ' , array [ ] : : text [ ] ) ;
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
set client_min_messages to warning ;
2024-03-14 21:08:01 +00:00
truncate acsi_option cascade ;
truncate acsi_calendar cascade ;
truncate acsi cascade ;
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
truncate payment_option cascade ;
truncate payment cascade ;
truncate campsite_type_option_cost cascade ;
truncate campsite_type_option cascade ;
truncate campsite_type_pet_cost cascade ;
truncate campsite_type_cost cascade ;
truncate campsite_type cascade ;
truncate media cascade ;
truncate media_content cascade ;
truncate season_calendar cascade ;
truncate season cascade ;
truncate company cascade ;
reset client_min_messages ;
2024-02-27 18:45:47 +00:00
insert into company ( company_id , business_name , vatin , trade_name , phone , email , web , address , city , province , postal_code , rtc_number , tourist_tax , tourist_tax_max_days , country_code , currency_code , default_lang_tag )
values ( 2 , ' Company 2 ' , ' XX123 ' , ' ' , ' 555-555-555 ' , ' a@a ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , 350 , 7 , ' ES ' , ' EUR ' , ' ca ' )
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
;
insert into season ( season_id , company_id , name )
values ( 4 , 2 , ' High ' )
, ( 6 , 2 , ' Shoulder ' )
, ( 8 , 2 , ' Offseason ' )
;
insert into season_calendar ( season_id , season_range )
2024-02-13 22:45:25 +00:00
values ( 4 , daterange ( current_date , current_date + 60 ) )
, ( 6 , daterange ( current_date + 60 , current_date + 64 ) )
, ( 8 , daterange ( current_date + 64 , current_date + 69 ) )
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
;
insert into media_content ( media_type , bytes )
values ( ' image/x-xpixmap ' , ' static char *s[]={"1 1 1 1","a c #ffffff","a"}; ' )
;
insert into media ( media_id , company_id , original_filename , content_hash )
values ( 10 , 2 , ' cover2.xpm ' , sha256 ( ' static char *s[]={"1 1 1 1","a c #ffffff","a"}; ' ) )
;
insert into campsite_type ( campsite_type_id , slug , company_id , name , media_id , max_campers , bookable_nights , overflow_allowed )
values ( 12 , ' c1b6f4fc-32c1-4cd5-b796-0c5059152a52 ' , 2 , ' Plots ' , 10 , 6 , ' [1, 7] ' , true )
, ( 14 , ' b065f4e3-2cc8-491d-a413-d015d7d00183 ' , 2 , ' Bungalow ' , 10 , 6 , ' [1, 7] ' , false )
;
insert into campsite_type_cost ( campsite_type_id , season_id , cost_per_night , cost_per_adult , cost_per_teenager , cost_per_child )
values ( 12 , 4 , 400 , 795 , 795 , 640 )
, ( 12 , 6 , 200 , 740 , 740 , 590 )
, ( 12 , 8 , 0 , 660 , 660 , 540 )
, ( 14 , 4 , 17000 , 0 , 0 , 0 )
, ( 14 , 6 , 13500 , 0 , 0 , 0 )
, ( 14 , 8 , 10500 , 0 , 0 , 0 )
;
insert into campsite_type_pet_cost ( campsite_type_id , cost_per_night )
values ( 12 , 350 )
;
insert into campsite_type_option ( campsite_type_option_id , campsite_type_id , name , range , per_night )
values ( 16 , 12 , ' Big tent ' , ' [0, 4) ' , true )
, ( 18 , 12 , ' Car ' , ' [0, 4) ' , true )
, ( 20 , 12 , ' Electricity ' , ' [0, 5) ' , false )
;
insert into campsite_type_option_cost ( campsite_type_option_id , season_id , cost )
values ( 16 , 4 , 800 )
, ( 16 , 6 , 720 )
, ( 16 , 8 , 620 )
, ( 18 , 4 , 700 )
, ( 18 , 6 , 630 )
, ( 18 , 8 , 530 )
, ( 20 , 4 , 690 )
, ( 20 , 6 , 610 )
, ( 20 , 8 , 590 )
;
2024-03-14 21:08:01 +00:00
insert into payment ( payment_id , slug , company_id , campsite_type_id , arrival_date , departure_date , subtotal_nights , number_adults , subtotal_adults , number_teenagers , subtotal_teenagers , number_children , subtotal_children , number_dogs , subtotal_dogs , subtotal_tourist_tax , total , currency_code , zone_preferences , acsi_card , payment_status , created_at , updated_at )
values ( 22 , ' 7cccfe16-695e-486d-a6a5-1162fb85cafb ' , 2 , 12 , current_date + 60 , current_date + 62 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , ' USD ' , ' ' , false , ' draft ' , ' 2024-01-01 01:01:01 ' , ' 2024-01-01 01:01:01 ' )
, ( 24 , ' 6eeae04c-2fea-4d67-97dc-a4b8a83df99f ' , 2 , 12 , current_date + 61 , current_date + 62 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , ' USD ' , ' ' , false , ' pending ' , ' 2024-01-01 02:02:02 ' , ' 2024-01-01 02:02:02 ' )
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
;
insert into payment_option ( payment_id , campsite_type_option_id , units , subtotal )
values ( 22 , 16 , 1 , 0 )
, ( 22 , 18 , 1 , 0 )
2024-02-13 19:16:12 +00:00
, ( 24 , 16 , 2 , 0 )
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
;
2024-03-14 21:08:01 +00:00
insert into acsi ( campsite_type_id , number_adults , number_teenagers , number_children , number_dogs , cost_per_night )
values ( 12 , 2 , 0 , 0 , 1 , 2300 ) ;
insert into acsi_calendar ( campsite_type_id , acsi_range )
values ( 12 , daterange ( current_date + 60 , current_date + 61 ) )
, ( 12 , daterange ( current_date + 64 , current_date + 65 ) )
;
insert into acsi_option ( campsite_type_id , campsite_type_option_id , units )
values ( 12 , 16 , 1 )
, ( 12 , 18 , 1 )
;
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
select lives_ok (
2024-03-14 21:08:01 +00:00
$ $ select draft_payment ( null , current_date + 59 , current_date + 64 , ' b065f4e3-2cc8-491d-a413-d015d7d00183 ' , 1 , 2 , 3 , 0 , null , true , null ) $ $ ,
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
' Should be able to create a new draft for Bungalows '
) ;
select lives_ok (
2024-03-14 21:08:01 +00:00
$ $ select draft_payment ( null , current_date + 6 , current_date + 11 , ' b065f4e3-2cc8-491d-a413-d015d7d00183 ' , 1 , 2 , 3 , 0 , null , true , null ) $ $ ,
2024-02-13 22:45:25 +00:00
' A payment for a reservation in less than a week has a 100 % of downpayment '
) ;
2024-02-27 18:45:47 +00:00
select lives_ok (
2024-03-14 21:08:01 +00:00
$ $ select draft_payment ( null , current_date + 10 , current_date + 58 , ' b065f4e3-2cc8-491d-a413-d015d7d00183 ' , 2 , 3 , 4 , 0 , null , true , null ) $ $ ,
2024-02-27 18:45:47 +00:00
' All reservations incur a tourist tax for the first tourist_tax_max_days days '
) ;
2024-02-13 22:45:25 +00:00
select lives_ok (
2024-03-14 21:08:01 +00:00
$ $ select draft_payment ( ' 7cccfe16-695e-486d-a6a5-1162fb85cafb ' , current_date + 58 , current_date + 65 , ' c1b6f4fc-32c1-4cd5-b796-0c5059152a52 ' , 2 , 4 , 6 , 3 , ' pref I before E ' , false , array [ ( 16 , 2 ) , ( 20 , 3 ) ] : : option_units [ ] ) $ $ ,
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
' Should be able to update the draft for Plots '
) ;
2024-02-13 19:16:12 +00:00
select results_ne (
2024-03-14 21:08:01 +00:00
$ $ select slug : : text from draft_payment ( ' 6eeae04c-2fea-4d67-97dc-a4b8a83df99f ' , current_date + 31 , current_date + 36 , ' b065f4e3-2cc8-491d-a413-d015d7d00183 ' , 2 , 1 , 1 , 1 , ' under a tree ' , true , array [ ( 16 , 1 ) , ( 18 , 1 ) ] : : option_units [ ] ) $ $ ,
2024-02-13 19:16:12 +00:00
$ $ values ( ' 6eeae04c-2fea-4d67-97dc-a4b8a83df99f ' ) $ $ ,
' When trying to draft a payment already pending, completed, failed, or refunded, create a new instead '
) ;
2024-03-14 21:08:01 +00:00
select lives_ok (
$ $ select draft_payment ( null , current_date + 58 , current_date + 65 , ' c1b6f4fc-32c1-4cd5-b796-0c5059152a52 ' , 3 , 1 , 1 , 1 , ' ' , true , array [ ( 16 , 2 ) , ( 18 , 3 ) , ( 20 , 4 ) ] : : option_units [ ] ) $ $ ,
' Should be able to draft a payment for plots with ACSI discount during the days that is valid '
) ;
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
select bag_eq (
2024-02-14 03:54:42 +00:00
$ $ select company_id , campsite_type_id , arrival_date , departure_date , subtotal_nights , number_adults , subtotal_adults , number_teenagers , subtotal_teenagers , number_children , subtotal_children , number_dogs , subtotal_dogs , subtotal_tourist_tax , total , currency_code , down_payment_percent , zone_preferences , payment_status , created_at , updated_at from payment $ $ ,
2024-03-20 17:17:58 +00:00
$ $ values ( 2 , 12 , current_date + 58 , current_date + 65 , 3200 , 2 , 10420 , 4 , 20840 , 6 , 25080 , 3 , 7350 , 4900 , 84060 , ' EUR ' , 0 . 3 , ' pref I before E ' , ' draft ' , ' 2024-01-01 01:01:01 ' , current_timestamp )
2024-02-14 03:54:42 +00:00
, ( 2 , 14 , current_date + 59 , current_date + 64 , 71000 , 1 , 0 , 2 , 0 , 3 , 0 , 0 , 0 , 1750 , 72750 , ' EUR ' , 0 . 3 , ' ' , ' draft ' , current_timestamp , current_timestamp )
2024-02-27 18:45:47 +00:00
, ( 2 , 14 , current_date + 10 , current_date + 58 , 1632000 , 2 , 0 , 3 , 0 , 4 , 0 , 0 , 0 , 4900 , 1636900 , ' EUR ' , 0 . 3 , ' ' , ' draft ' , current_timestamp , current_timestamp )
2024-02-14 03:54:42 +00:00
, ( 2 , 14 , current_date + 6 , current_date + 11 , 85000 , 1 , 0 , 2 , 0 , 3 , 0 , 0 , 0 , 1750 , 86750 , ' EUR ' , 1 . 0 , ' ' , ' draft ' , current_timestamp , current_timestamp )
, ( 2 , 12 , current_date + 61 , current_date + 62 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , ' USD ' , 1 . 0 , ' ' , ' pending ' , ' 2024-01-01 02:02:02 ' , ' 2024-01-01 02:02:02 ' )
, ( 2 , 14 , current_date + 31 , current_date + 36 , 85000 , 2 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 3500 , 96000 , ' EUR ' , 0 . 3 , ' under a tree ' , ' draft ' , current_timestamp , current_timestamp )
2024-03-14 21:08:01 +00:00
, ( 2 , 12 , current_date + 58 , current_date + 65 , 6000 , 3 , 12830 , 1 , 5210 , 1 , 4180 , 1 , 1750 , 7350 , 61130 , ' EUR ' , 0 . 3 , ' ' , ' draft ' , current_timestamp , current_timestamp )
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
$ $ ,
' Should have added and updated payments '
) ;
select bag_eq (
2024-02-13 19:16:12 +00:00
$ $ select case payment_id when 22 then ' a ' when 24 then ' b ' else ' c ' end , campsite_type_option_id , units , subtotal from payment_option $ $ ,
$ $ values ( ' a ' , 16 , 2 , 10200 )
2024-03-14 21:08:01 +00:00
, ( ' a ' , 20 , 3 , 2070 )
, ( ' b ' , 16 , 2 , 0 )
, ( ' c ' , 16 , 1 , 4000 )
, ( ' c ' , 18 , 1 , 3500 )
, ( ' c ' , 16 , 2 , 8860 )
, ( ' c ' , 18 , 3 , 12190 )
, ( ' c ' , 20 , 4 , 2760 )
Add payment relation and use it to compute the booking’s cart
I had to add the payment concept separate from the booking, unlike other
eCommerce solutions that subsume the two into a single “order”, like
WooCommerce, because bookings should be done in a separate Camper
instance that will sync to the public instance, but the payment is done
by the public instance. There will be a queue or something between
the public and the private instance to pass along the booking
information once the payment is complete, but the public instance still
needs to keep track of payments without creating bookings.
To compute the total for that payment i had to do the same as was doing
until now for the cart. To prevent duplications, or having functions
with complex return types, i now create a “draft” payment while the
user is filling in the form, and compute the cart there; from Go i only
have to retrieve the data from the relation, that simplifies the work,
actually.
Since the payment is computed way before customers enter their details,
i can not have that data in the same payment relation, unless i allow
NULL values. Allowing NULL values means that i can create a payment
without customer, thus i moved all customer details to a separate
relation. It still allows payment without customer, but at least there
are no NULL values.
Draft payments should be removed after a time, but i believe this needs
to be done in a cronjob or similar, not in the Go application.
To update the same payment while filling the same booking form, i now
have a hidden field with the payment slug. A competent developer would
have used a cookie or something like that; i am not competent.
2024-02-12 04:21:00 +00:00
$ $ ,
' Should have added, updated, and removed payment options '
) ;
select *
from finish ( ) ;
rollback ;