-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a new internal campaing for members and their fees. (#527)
* Create a new internal campaing for members only. This way we can pay the annual fees using stripe and the subscriptions we support. * Do not insert the campaign if there is no beneficiary. We cannot execute this on an empty db. There are simply too many records to provide if the db is empty (person, city, country...)
- Loading branch information
Showing
4 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
migrations/20230802161354_insert_membership_campaign_type/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Add a new campaign type for membership campaigns | ||
|
||
INSERT INTO api.campaign_types (name, slug, description, parent_id, category) | ||
VALUES ('Membership', 'membership', 'Membership Campaigns', null, 'others'); | ||
|
55 changes: 55 additions & 0 deletions
55
migrations/20230802163505_insert_membership_campaign/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--insert an internal campaign for members only and their membership fee | ||
--insert an internal campaign for members only and their membership fee | ||
DO $$ | ||
DECLARE | ||
v_coordinator_id UUID; | ||
v_beneficiary_id UUID; | ||
v_campaign_type_id UUID; | ||
|
||
BEGIN | ||
|
||
select id INTO v_coordinator_id from coordinators limit 1; | ||
select id INTO v_beneficiary_id from beneficiaries where coordinator_id = v_coordinator_id limit 1; | ||
select id INTO v_campaign_type_id from campaign_types where name = 'Membership'; | ||
|
||
IF v_beneficiary_id IS NULL THEN | ||
RETURN; | ||
END IF; | ||
|
||
insert into campaigns ( | ||
state, | ||
slug, | ||
title, | ||
coordinator_id, | ||
beneficiary_id, | ||
campaign_type_id, | ||
essence, | ||
description, | ||
target_amount, | ||
start_date, | ||
end_date, | ||
created_at, | ||
updated_at, | ||
currency, | ||
allow_donation_on_complete, | ||
payment_reference) | ||
values ('approved', | ||
'podkrepi-membership', | ||
'Podkrepi.bg membership', | ||
v_coordinator_id, | ||
v_beneficiary_id, | ||
v_campaign_type_id, | ||
'Internal campaign for members only', | ||
'Internal campaign for members only. Here you can pay your membership fee. Subscribe it as an annual donation in this campaign.', | ||
10000000, | ||
NOW(), | ||
'2123-08-01', | ||
NOW(), | ||
NOW(), | ||
'BGN', | ||
true, | ||
'46M3-3ARQ-R326' | ||
); | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
|