Skip to content

Commit

Permalink
General: Fix donation certificates (#1021)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkue authored Jan 24, 2025
1 parent 79b50af commit fc7c259
Show file tree
Hide file tree
Showing 73 changed files with 291 additions and 828 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ jobs:
echo SENDGRID_API_KEY=${{ secrets.SENDGRID_API_KEY }} >> .env
echo STRIPE_API_READ_KEY=${{ (inputs.project == 'social-income-prod' && secrets.STRIPE_API_READ_KEY) || secrets.STRIPE_API_READ_KEY_STAGING }} >> .env
echo STRIPE_WEBHOOK_SECRET=${{ (inputs.project == 'social-income-prod' && secrets.STRIPE_WEBHOOK_SECRET) || secrets.STRIPE_WEBHOOK_SECRET_STAGING }} >> .env
echo TWILIO_SENDER_PHONE=${{ secrets.TWILIO_SENDER_PHONE }} >> .env
echo TWILIO_SID=${{ secrets.TWILIO_SID }} >> .env
echo TWILIO_TOKEN=${{ secrets.TWILIO_TOKEN }} >> .env
- name: Build functions
run: npm run functions:build
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ jobs:
uses: ./.github/workflows/actions/init

- name: Run tests
env:
TWILIO_SID: ${{ secrets.TWILIO_TEST_SID }}
TWILIO_TOKEN: ${{ secrets.TWILIO_TEST_TOKEN }}
TWILIO_SENDER_PHONE: ${{ secrets.TWILIO_TEST_SENDER_PHONE }}
env: {}
run: npm run functions:test

# TODO: re-enable
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,5 @@ jobs:
uses: ./.github/workflows/actions/init

- name: Run tests
env:
TWILIO_SID: ${{ secrets.TWILIO_TEST_SID }}
TWILIO_TOKEN: ${{ secrets.TWILIO_TEST_TOKEN }}
TWILIO_SENDER_PHONE: ${{ secrets.TWILIO_TEST_SENDER_PHONE }}
env: {}
run: npm run shared:test
6 changes: 3 additions & 3 deletions admin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
import { adminsCollection } from './collections/Admins';
import { campaignsCollection } from './collections/Campaigns';
import { buildContributionsCollection } from './collections/Contributions';
import { contributorsCollection } from './collections/Contributors';
import { expensesCollection } from './collections/Expenses';
import { buildPartnerOrganisationsCollection } from './collections/PartnerOrganisations';
import { buildPaymentForecastCollection } from './collections/PaymentForecast';
import { usersCollection } from './collections/Users';
import { buildRecipientsCollection } from './collections/recipients/Recipients';
import { buildRecipientsPaymentsCollection } from './collections/recipients/RecipientsPayments';
import { buildSurveysCollection } from './collections/surveys/Surveys';
Expand Down Expand Up @@ -49,14 +49,14 @@ export default function App() {
const collections = [
buildRecipientsCollection(),
buildRecipientsPaymentsCollection(),
contributorsCollection,
buildContributionsCollection({ collectionGroup: true }),
buildPartnerOrganisationsCollection(),
buildSurveysCollection({ collectionGroup: true }),
adminsCollection,
expensesCollection,
buildPaymentForecastCollection(),
usersCollection,
campaignsCollection,
buildContributionsCollection({ collectionGroup: true }),
];

const views: CMSView[] = [
Expand Down
7 changes: 3 additions & 4 deletions admin/src/actions/CreateDonationCertificatesAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getFunctions, httpsCallable } from 'firebase/functions';
import { CollectionActionsProps, useAuthController, useSnackbarController } from 'firecms';
import _ from 'lodash';
import React from 'react';
import { CreateDonationCertificatesFunctionProps } from '../../../functions/src/webhooks/admin/donation-certificates';
import { CreateDonationCertificatesProps } from '../../../functions/src/lib/donation-certificates';

const style = {
position: 'absolute' as 'absolute',
Expand Down Expand Up @@ -44,7 +44,7 @@ export function CreateDonationCertificatesAction({ selectionController }: Collec
if (!isGlobalAdmin) return null;

const functions = getFunctions(undefined, DEFAULT_REGION);
const createDonationCertificatesFunction = httpsCallable<CreateDonationCertificatesFunctionProps, string>(
const createDonationCertificatesFunction = httpsCallable<CreateDonationCertificatesProps, string>(
functions,
'createDonationCertificates',
);
Expand All @@ -54,8 +54,7 @@ export function CreateDonationCertificatesAction({ selectionController }: Collec
if ((year && selectedEntities?.length > 0) || createAll) {
createDonationCertificatesFunction({
year: year,
userIds: selectedEntities,
createAll: createAll,
userIds: selectedEntities.length > 0 ? selectedEntities : undefined,
})
.then((result) => {
snackbarController.open({
Expand Down
93 changes: 0 additions & 93 deletions admin/src/actions/InviteWhatsappAction.tsx

This file was deleted.

9 changes: 1 addition & 8 deletions admin/src/actions/PaymentProcessAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getFunctions, httpsCallable } from 'firebase/functions';
import { useSnackbarController } from 'firecms';
import { DateTime } from 'luxon';
import { useState } from 'react';
import { PaymentProcessProps } from '../../../functions/src/webhooks/admin/payment-process';
import type { PaymentProcessProps } from '../../../functions/src/functions/webhooks/admin/payment-process';

const BOX_STYLE = {
position: 'absolute',
Expand Down Expand Up @@ -113,13 +113,6 @@ export function PaymentProcessAction() {
Confirm
</Button>
)}
<Button
disabled={true}
variant="outlined"
onClick={() => triggerFirebaseFunction(PaymentProcessTaskType.SendNotifications)}
>
Notify recipients (in development)
</Button>{' '}
<Button variant="outlined" color="error" onClick={handleClose}>
Close
</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { COUNTRY_CODES } from '@socialincome/shared/src/types/country';
import { LANGUAGE_CODES } from '@socialincome/shared/src/types/language';
import { USER_FIRESTORE_PATH, User, UserReferralSource } from '@socialincome/shared/src/types/user';
import { buildProperties } from 'firecms';
import { CreateDonationCertificatesAction } from '../actions/CreateDonationCertificatesAction';
import { buildContributionsCollection } from './Contributions';
import { donationCertificateCollection } from './DonationCertificate';
import { buildAuditedCollection } from './shared';

// @ts-ignore
export const usersCollection = buildAuditedCollection<User>({
export const contributorsCollection = buildAuditedCollection<User>({
path: USER_FIRESTORE_PATH,
group: 'Contributors',
icon: 'VolunteerActivism',
icon: 'Person',
name: 'Contributors',
singularName: 'Contributor',
description: 'Lists all contributors',
Expand Down Expand Up @@ -81,6 +82,9 @@ export const usersCollection = buildAuditedCollection<User>({
name: 'Country',
dataType: 'string',
validation: { required: true },
enumValues: {
...COUNTRY_CODES.map((code) => ({ id: code, label: code })),
},
},
city: {
name: 'City',
Expand All @@ -103,6 +107,7 @@ export const usersCollection = buildAuditedCollection<User>({
language: {
name: 'Language',
dataType: 'string',
enumValues: { ...LANGUAGE_CODES.map((code) => ({ id: code, label: code })) },
},
currency: {
name: 'Currency',
Expand Down
28 changes: 6 additions & 22 deletions admin/src/collections/DonationCertificate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,23 @@ import {
DONATION_CERTIFICATE_FIRESTORE_PATH,
DonationCertificate,
} from '@socialincome/shared/src/types/donation-certificate';
import { AdditionalFieldDelegate, buildProperties } from 'firecms';
import { buildProperties } from 'firecms';
import { buildAuditedCollection } from './shared';

const DownloadLinkColumn: AdditionalFieldDelegate<DonationCertificate> = {
id: 'download_link',
name: 'Download Link',
Builder: ({ entity }) => {
return (
<a href={entity.values.url} target="_blank" rel="noreferrer">
Download
</a>
);
},
dependencies: ['url'],
};

export const donationCertificateCollection = buildAuditedCollection<DonationCertificate>({
name: 'Donation Certificates',
group: 'Finances',
path: DONATION_CERTIFICATE_FIRESTORE_PATH,
textSearchEnabled: false,
initialSort: ['year', 'desc'],
customId: true,
additionalFields: [DownloadLinkColumn],

permissions: {
edit: true,
create: true,
delete: true,
},
properties: buildProperties<DonationCertificate>({
url: {
dataType: 'string',
name: 'URL',
disabled: {
hidden: true,
},
},
country: {
dataType: 'string',
name: 'Created for country',
Expand All @@ -50,5 +29,10 @@ export const donationCertificateCollection = buildAuditedCollection<DonationCert
name: 'Year',
disabled: true,
},
storage_path: {
dataType: 'string',
name: 'Storage path',
disabled: true,
},
}),
});
36 changes: 0 additions & 36 deletions admin/src/collections/Messages.ts

This file was deleted.

3 changes: 1 addition & 2 deletions admin/src/collections/recipients/Recipients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { toDateTime } from '@socialincome/shared/src/utils/date';
import { AdditionalFieldDelegate, buildProperties } from 'firecms';
import { EntityCollection, PropertiesOrBuilders } from 'firecms/dist/types';
import { messagesCollection } from '../Messages';
import { paymentsCollection } from '../Payments';
import { buildAuditedCollection } from '../shared';
import { buildSurveysCollection } from '../surveys/Surveys';
Expand Down Expand Up @@ -94,7 +93,7 @@ export const buildRecipientsCollection = () => {
si_start_date: SIStartDateProperty,
test_recipient: TestRecipientProperty,
}),
subcollections: [paymentsCollection, buildSurveysCollection(), messagesCollection],
subcollections: [paymentsCollection, buildSurveysCollection()],
};
return buildAuditedCollection<Partial<Recipient>>(collection);
};
5 changes: 0 additions & 5 deletions functions/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,3 @@ POSTFINANCE_FTP_HOST=ftp.postfinance.example
POSTFINANCE_FTP_PORT=21
POSTFINANCE_FTP_USER=example
POSTFINANCE_FTP_RSA_PRIVATE_KEY_BASE64="CKSLI...."

# To work with the Twilio API locally, configure the test credentials from Twilio in your .env file
TWILIO_SID=ACXXXXXXXXXXXXXXXXXXXX
TWILIO_TOKEN=yyyyyyyyyyyyyyyyyyyyy
TWILIO_SENDER_PHONE=+15005550006
1 change: 0 additions & 1 deletion functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"ssh2-sftp-client": "^11.0.0",
"stripe": "^17.1.0",
"tmp-promise": "^3.0.3",
"twilio": "^5.3.3",
"xpath": "^0.0.34"
}
}
4 changes: 0 additions & 4 deletions functions/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,4 @@ export const POSTFINANCE_FTP_HOST = process.env.POSTFINANCE_FTP_HOST!;
export const POSTFINANCE_FTP_PORT = process.env.POSTFINANCE_FTP_PORT!;
export const POSTFINANCE_FTP_USER = process.env.POSTFINANCE_FTP_USER!;

export const TWILIO_SID = process.env.TWILIO_SID!;
export const TWILIO_TOKEN = process.env.TWILIO_TOKEN!;
export const TWILIO_SENDER_PHONE = process.env.TWILIO_SENDER_PHONE!;

export const EXCHANGE_RATES_API = process.env.EXCHANGE_RATES_API!;
Loading

0 comments on commit fc7c259

Please sign in to comment.