Skip to content

Commit

Permalink
Merge branch 'master' into campaign-news-functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
igoychev committed Jun 27, 2023
2 parents 65d34eb + 0db1b71 commit db23038
Show file tree
Hide file tree
Showing 39 changed files with 849 additions and 205 deletions.
14 changes: 8 additions & 6 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ JWT_SECRET_KEY=VerySecretPrivateKey

## Iris Bank Imports ##
##########
IRIS_API_URL = https://developer.sandbox.irispay.bg/api/8
IRIS_AGENT_HASH =
IRIS_USER_HASH =
BANK_BIC = UNCRBGSF
PLATFORM_IBAN =
IMPORT_TRX_TASK_INTERVAL_MINUTES = 60
IRIS_API_URL=https://developer.sandbox.irispay.bg/api/8
IRIS_AGENT_HASH=
IRIS_USER_HASH=
BANK_BIC=UNCRBGSF
PLATFORM_IBAN=
IMPORT_TRX_TASK_INTERVAL_MINUTES=60
CHECK_IRIS_CONSENT_TASK_HOUR=10
BILLING_ADMIN_MAIL=[email protected]
15 changes: 9 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,12 @@ JWT_SECRET_KEY=VerySecretPrivateKey

## Iris Bank Imports ##
##########
IRIS_API_URL = https://developer.sandbox.irispay.bg/api/8
IRIS_AGENT_HASH =
IRIS_USER_HASH =
BANK_BIC = UNCRBGSF
PLATFORM_IBAN =
IMPORT_TRX_TASK_INTERVAL_MINUTES = 60
IRIS_API_URL=https://developer.sandbox.irispay.bg/api/8
IRIS_AGENT_HASH=
IRIS_USER_HASH=
BANK_BIC=UNCRBGSF
PLATFORM_IBAN=
IMPORT_TRX_TASK_INTERVAL_MINUTES=60
#which hour of the day to run the check for consent
CHECK_IRIS_CONSENT_TASK_HOUR=10
BILLING_ADMIN_MAIL=[email protected]
2 changes: 1 addition & 1 deletion apps/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import { ExportModule } from '../export/export.module'
import { JwtModule } from '@nestjs/jwt'
import { NotificationModule } from '../sockets/notifications/notification.module'
import { ScheduleModule } from '@nestjs/schedule'
import { TasksModule } from '../tasks//bank-import/tasks.module'
import { TasksModule } from '../tasks/tasks.module'
import { BankTransactionsModule } from '../bank-transactions/bank-transactions.module'
import { CampaignNewsModule } from '../campaign-news/campaign-news.module'
import { CampaignNewsFileModule } from '../campaign-news-file/campaign-news-file.module'
Expand Down
3 changes: 3 additions & 0 deletions apps/api/src/assets/templates/expiring-iris-consent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"subject": "Изтичащо съгласие за достъп до банкова информация"
}
72 changes: 72 additions & 0 deletions apps/api/src/assets/templates/expiring-iris-consent.mjml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<mjml>
<mj-body background-color="#ffffff" font-size="13px">
<mj-section
background-color="#009FE3"
vertical-align="top"
padding-bottom="0px"
padding-top="0">
<mj-column vertical-align="top" width="100%">
<mj-text
align="left"
color="#ffffff"
font-size="45px"
font-weight="bold"
font-family="open Sans Helvetica, Arial, sans-serif"
padding-left="25px"
padding-right="25px"
padding-bottom="30px"
padding-top="50px">
Засечени са неразпознати банкови дарения
</mj-text>
</mj-column>
</mj-section>
<mj-section background-color="#009fe3" padding-bottom="20px" padding-top="20px">
<mj-column vertical-align="middle" width="100%">
<mj-text
align="left"
color="#ffffff"
font-size="22px"
font-family="open Sans Helvetica, Arial, sans-serif"
padding-left="25px"
padding-right="25px">
<br /><br />
</mj-text>
<mj-text
align="left"
color="#ffffff"
font-size="15px"
font-family="open Sans Helvetica, Arial, sans-serif"
padding-left="25px"
padding-right="25px">
Остават <strong> {{daysToExpire}} дни </strong> до изтичането на разрешението за достъп до
банковата информация, необходимо за извличане на транзакциите в системата на Podkrepi.bg.
Дата на изтичане е <strong> {{expiresAt}} </strong>. Можете да подновите разрешението за
още 90 дни(максимален период) като кликнете на бутона:
</mj-text>

<mj-button
background-color="#feeb35"
font-family="Helvetica, Arial, sans-serif"
font-size="16px"
border-radius="30px"
color="#000000"
padding="15px 30px"
href="{{renewLink}}"
target="_blank">
Поднови банковото разрешение
</mj-button>

<mj-text
align="left"
color="#ffffff"
font-size="15px"
font-family="open Sans Helvetica, Arial, sans-serif"
padding-left="25px"
padding-right="25px">
Поздрави, <br />
Екипът на Подкрепи.бг
</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
3 changes: 3 additions & 0 deletions apps/api/src/assets/templates/unrecognized-donation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"subject": "Неразпознато банково дарение/я"
}
94 changes: 94 additions & 0 deletions apps/api/src/assets/templates/unrecognized-donation.mjml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<mjml>
<mj-body background-color="#ffffff" font-size="13px">
<mj-section
background-color="#009FE3"
vertical-align="top"
padding-bottom="0px"
padding-top="0">
<mj-column vertical-align="top" width="100%">
<mj-text
align="left"
color="#ffffff"
font-size="45px"
font-weight="bold"
font-family="open Sans Helvetica, Arial, sans-serif"
padding-left="25px"
padding-right="25px"
padding-bottom="30px"
padding-top="50px">
Засечени са неразпознати банкови дарения
</mj-text>
</mj-column>
</mj-section>
<mj-section background-color="#009fe3" padding-bottom="20px" padding-top="20px">
<mj-column vertical-align="middle" width="100%">
<mj-text
align="left"
color="#ffffff"
font-size="22px"
font-family="open Sans Helvetica, Arial, sans-serif"
padding-left="25px"
padding-right="25px">
<br /><br />
</mj-text>
<mj-text
align="left"
color="#ffffff"
font-size="15px"
font-family="open Sans Helvetica, Arial, sans-serif"
padding-left="25px"
padding-right="25px">
При последния извършен импорт на банкови дарения от {{ importDate}} бяха засечени
транзакции, чиито код на кампания не е бил разпознат или импортът е бил неуспешен:
</mj-text>

<mj-table color="#ffffff" width="100%">
<tr
style="border-bottom: 1px solid #ffffff"
align="left"
color="#ffffff"
font-size="15px"
font-family="open Sans Helvetica, Arial, sans-serif">
<th style="padding: 10px" width="16%">Транз. №</th>
<th style="padding: 10px" width="16%">Изпращач</th>
<th style="padding: 10px" width="16%">Сума</th>
<th style="padding: 10px" width="31%">Основание</th>
<th style="padding: 10px" width="16%">Статус</th>
</tr>
<mj-raw> {{#each transactions}} </mj-raw>
<tr style="border-bottom: 1px solid #ffffff">
<td style="padding: 10px">{{ id }}</td>
<td style="padding: 10px">{{ senderName }}</td>
<td style="padding: 10px">{{ amount }}</td>
<td style="padding: 10px; word-break: break-word">{{ description }}</td>
<td style="padding: 10px">{{ bankDonationStatus }}</td>
</tr>
<mj-raw> {{/each}} </mj-raw>
</mj-table>

<mj-button
background-color="#feeb35"
font-family="Helvetica, Arial, sans-serif"
font-size="16px"
border-radius="30px"
color="#000000"
padding="15px 30px"
href="{{link}}"
target="_blank">
Към Банкови Транзакции
</mj-button>

<mj-text
align="left"
color="#ffffff"
font-size="15px"
font-family="open Sans Helvetica, Arial, sans-serif"
padding-left="25px"
padding-right="25px">
Поздрави, <br />
Екипът на Подкрепи.бг
</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ function toNumber(value: string, opts: ToNumberOptions = {}): number | undefined
return newValue
}

function falsyToUndefined(value: any): any | undefined {
function falsyToUndefined(value: unknown): unknown | undefined {
if (!value || value === 'undefined') {
return undefined
}

return value
}

function handleDateTransform(value: any): Date | undefined {
function handleDateTransform(value: unknown): Date | undefined {
if (!value || value === 'undefined') {
return undefined
}

return new Date(value)
return new Date(value as string)
}

export class UpdateBankTransactionRefDto {
Expand Down
30 changes: 18 additions & 12 deletions apps/api/src/campaign-file/campaign-file.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,25 @@ export class CampaignFileService {
campaignId,
personId: person.id,
}
const dbFile = await this.prisma.campaignFile.create({ data: file })
// Check if the file already exists in the DB
let dbFile = await this.prisma.campaignFile.findFirst({ where: { role, campaignId, filename } })

// Use the DB primary key as the S3 key. This will make sure it is always unique.
await this.s3.uploadObject(
this.bucketName,
dbFile.id,
encodeURIComponent(filename),
mimetype,
buffer,
'Campaign',
campaignId,
person.id,
)
if (!dbFile) {
// If not, create a new record
dbFile = await this.prisma.campaignFile.create({ data: file })

// Use the DB primary key as the S3 key. This will make sure it is always unique.
await this.s3.uploadObject(
this.bucketName,
dbFile.id,
encodeURIComponent(filename),
mimetype,
buffer,
'Campaign',
campaignId,
person.id,
)
}

return dbFile.id
}
Expand Down
8 changes: 1 addition & 7 deletions apps/api/src/campaign/dto/list-campaigns.dto.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
BeneficiaryType,
CampaignFileRole,
CampaignState,
CampaignTypeCategory,
Prisma,
} from '@prisma/client'
import { CampaignFileRole, Prisma } from '@prisma/client'

export const AdminCampaignListItemSelect = Prisma.validator<Prisma.CampaignArgs>()({
select: {
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/common/dto/donation-query-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,18 @@ function toNumber(value: string, opts: ToNumberOptions = {}): number | undefined
return newValue
}

function falsyToUndefined(value: any): any | undefined {
function falsyToUndefined(value: unknown): unknown | undefined {
if (!value || value === 'undefined') {
return undefined
}

return value
}

function handleDateTransform(value: any): Date | undefined {
function handleDateTransform(value: unknown): Date | undefined {
if (!value || value === 'undefined') {
return undefined
}

return new Date(value)
return new Date(value as string)
}
4 changes: 3 additions & 1 deletion apps/api/src/config/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ export default () => ({
bankBIC: process.env.BANK_BIC,
platformIBAN: process.env.PLATFORM_IBAN,
apiUrl: process.env.IRIS_API_URL,
consentEndPoint: process.env.IRIS_API_URL + '/consent',
getConsentEndPoint: process.env.IRIS_API_URL + '/consent',
checkConsentEndPoint: process.env.IRIS_API_URL + '/consents/{ibanID}',
banksEndPoint: process.env.IRIS_API_URL + '/banks?country=bulgaria',
ibansEndPoint: process.env.IRIS_API_URL + '/ibans',
transactionsEndPoint: process.env.IRIS_API_URL + '/transactions',
billingAdminEmail: process.env.BILLING_ADMIN_MAIL,
},
tasks: {
import_transactions: { interval: process.env.IMPORT_TRX_TASK_INTERVAL_MINUTES },
Expand Down
3 changes: 1 addition & 2 deletions apps/api/src/country/dto/create-country.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ApiProperty } from '@nestjs/swagger'
import { City } from '@prisma/client'
import { Expose } from 'class-transformer'
import { IsISO31661Alpha2, IsOptional, IsString, IsUppercase } from 'class-validator'
import { IsISO31661Alpha2, IsString, IsUppercase } from 'class-validator'

@Expose()
export class CreateCountryDto {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export class CreateBankTransactionDto {
type: BankTransactionType
@ApiProperty({ enum: BankDonationStatus })
bankDonationStatus?: BankDonationStatus
notified?: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export class UpdateBankTransactionDto {
type?: BankTransactionType
@ApiProperty({ enum: BankDonationStatus })
bankDonationStatus?: BankDonationStatus
notified?: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export class BankTransaction {
matchedRef: string | null
type: BankTransactionType
bankDonationStatus: BankDonationStatus | null
notified: boolean | null
}
Loading

0 comments on commit db23038

Please sign in to comment.