Skip to content

Commit

Permalink
Merge pull request madisona#68 from arossoftware/nordea
Browse files Browse the repository at this point in the history
Nordea ISO 20022
  • Loading branch information
dlenskyi authored Dec 23, 2020
2 parents c700a90 + 739fc80 commit 88f0c42
Show file tree
Hide file tree
Showing 18 changed files with 409 additions and 24 deletions.
45 changes: 35 additions & 10 deletions frontend/src-admin/views/BankExportView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@
</template>
</i18n>
</b-alert>
<b-alert
v-if="adminMarket
&& adminMarket.bank_file_format === NORDEA_ISO_20022
&& (
!adminMarket.nordea_agreement_number
||
!adminMarket.nordea_signer_id
)
"
show
variant="warning">
<i18n path="pages.bank_export.missing_nordea_data" tag="div">
<template v-slot:link>
<router-link :to="{name: 'market-settings'}"
>{{ $t('navigation.admin.market_settings') }}</router-link>
</template>
</i18n>
</b-alert>
<content-table
:primaryKey="primaryKey"
:defaultSortBy="sortBy"
Expand Down Expand Up @@ -179,6 +197,7 @@
import ContentTable from '@base/components/ContentTable.vue'
import SearchField from '@base/components/SearchField.vue'
import {
NORDEA_ISO_20022,
AVAILABLE_BANK_FORMATS,
DATE_FORMAT,
BANK_REG_NUMBER_LENGTH,
Expand Down Expand Up @@ -216,7 +235,7 @@
primaryKey: 'user_number',
sortBy: 'user_number',
sortDesc: true,
availableBankFormats: AVAILABLE_BANK_FORMATS,
NORDEA_ISO_20022: NORDEA_ISO_20022,
fields: [
{ key: 'user_number', label: this.$t('form.bank_export.user_number'), class: 'text-center', sortable: true },
{ key: 'first_name', label: this.$t('form.bank_export.name'), class: 'text-center' },
Expand Down Expand Up @@ -453,14 +472,6 @@
return
this.loading = true
this.loader = this.$loading.show(this.$_loaderOptions)
const filename = this.$t(
'pages.bank_export.filename',
{
filetype: this.bankFileFormatSingleLabel,
description: this.bankExportTransactions[0].receiver
}
)
const filetype = 'text/plain'
salesPeriods({
url: `${this.$route.params.id}/bank_export/`,
params: {
Expand All @@ -469,7 +480,21 @@
},
})
.then((response) => {
saveFile(response.data['file'], filename, filetype)
const filename = this.$t(
'pages.bank_export.filename',
{
filetype: this.bankFileFormatSingleLabel,
description: this.bankExportTransactions[0].receiver,
extension: response.data.extension,
}
)
const filetypes = {
'txt': 'text/plain',
'xml': 'application/xml',
}
saveFile(
response.data.file, filename, filetypes[response.data.extension]
)
})
.catch((error) => {
this.$_notifyError(error.response, this)
Expand Down
108 changes: 105 additions & 3 deletions frontend/src-admin/views/MarketSettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,40 @@
></b-form-input>
</b-form-group>

<!--NORDEA AGREEMENT NUMBER-->
<b-form-group
id="nordea-agreement-number-group"
:label="$t('form.market.settings.nordea_agreement_number')"
:invalid-feedback="invalidNordeaAgreementNumber"
:state="stateNordeaAgreementNumber"
label-for="nordea-agreement-number"
>
<b-form-input
id="nordea-agreement-number"
v-model="marketSettingsForm.nordea_agreement_number"
:state="stateNordeaAgreementNumberInput"
:placeholder="$t(
'form.market.settings.nordea_agreement_number'
)"
></b-form-input>
</b-form-group>

<!--NORDEA SIGNER ID-->
<b-form-group
id="nordea-signer-id-group"
:label="$t('form.market.settings.nordea_signer_id')"
:invalid-feedback="invalidNordeaSignerID"
:state="stateNordeaSignerID"
label-for="nordea-signer-id"
>
<b-form-input
id="nordea-signer-id"
v-model="marketSettingsForm.nordea_signer_id"
:state="stateNordeaSignerIDInput"
:placeholder="$t('form.market.settings.nordea_signer_id')"
></b-form-input>
</b-form-group>

<!--BANK FILE FORMAT-->
<b-form-group
id="bank-format-group"
Expand Down Expand Up @@ -436,7 +470,7 @@
</b-form-group>
</b-col>
</b-row>

<b-row class="justify-content-around">
<b-button
type="submit"
Expand All @@ -455,7 +489,7 @@
{{ $t('form.market.settings.button_reset_settings') }}
</b-button>
</b-row>

</b-form>
<div class="mt-5 text-center" v-if="!marketSettingsForm.flexpos_api_valid">
<h1>{{ $t('pages.market_settings.wrong_api_settings_title') }}</h1>
Expand Down Expand Up @@ -497,6 +531,8 @@
support_phone: '',
bank_reg_number: '',
bank_account: '',
nordea_agreement_number: '',
nordea_signer_id: '',
bank_file_format: '',
instagram_url: '',
facebook_url: '',
Expand Down Expand Up @@ -525,6 +561,10 @@
AVAILABLE_BANK_FORMATS,
BANK_REG_NUMBER_LENGTH,
MAX_BANK_ACCOUNT_LENGTH,
MIN_NORDEA_AGREEMENT_NUMBER_LENGTH,
MAX_NORDEA_AGREEMENT_NUMBER_LENGTH,
MIN_NORDEA_SIGNER_ID_LENGTH,
MAX_NORDEA_SIGNER_ID_LENGTH,
} from '@base/configs'
import HeadBlock from '@base/components/HeadBlock.vue'
import ObjectUtils from '@base/mixins/ObjectUtils.vue'
Expand Down Expand Up @@ -560,7 +600,7 @@
loading: false
}
},
validations: {
phoneNumberData: {
required
Expand Down Expand Up @@ -599,6 +639,16 @@
numeric,
maxLength: maxLength(MAX_BANK_ACCOUNT_LENGTH),
},
nordea_agreement_number: {
numeric,
minLength: minLength(MIN_NORDEA_AGREEMENT_NUMBER_LENGTH),
maxLength: maxLength(MAX_NORDEA_AGREEMENT_NUMBER_LENGTH),
},
nordea_signer_id: {
numeric,
minLength: minLength(MIN_NORDEA_SIGNER_ID_LENGTH),
maxLength: maxLength(MAX_NORDEA_SIGNER_ID_LENGTH),
},
instagram_url: {
instagramUrlValidator,
},
Expand Down Expand Up @@ -663,6 +713,8 @@
bank_reg_number: this.marketSettingsForm.bank_reg_number,
bank_account: this.marketSettingsForm.bank_account ?
this.marketSettingsForm.bank_account.padStart(MAX_BANK_ACCOUNT_LENGTH, '0') : '',
nordea_agreement_number: this.marketSettingsForm.nordea_agreement_number,
nordea_signer_id: this.marketSettingsForm.nordea_signer_id,
bank_file_format: this.marketSettingsForm.bank_file_format ? this.marketSettingsForm.bank_file_format.code : '',
economic_agreement_token: this.marketSettingsForm.economic_agreement_token,
flexpos_api_key: this.marketSettingsForm.flexpos_api_key,
Expand Down Expand Up @@ -740,6 +792,56 @@
}
return null
},
stateNordeaAgreementNumberInput () {
return this.$v.marketSettingsForm.nordea_agreement_number.$error ? false : null
},
stateNordeaAgreementNumber () {
return (!this.$v.marketSettingsForm.nordea_agreement_number.$error)
},
invalidNordeaAgreementNumber () {
if (this.$v.marketSettingsForm.nordea_agreement_number.$error) {
if (!this.$v.marketSettingsForm.nordea_agreement_number.numeric)
return this.$t('validation.numeric', {
field: this.$t('form.market.settings.nordea_agreement_number'),
})
else if (!this.$v.marketSettingsForm.nordea_agreement_number.minLength)
return this.$t('validation.min_length', {
field: this.$t('form.market.settings.nordea_agreement_number'),
minLength: this.$v.marketSettingsForm.nordea_agreement_number.$params.minLength.min
})
else if (!this.$v.marketSettingsForm.nordea_agreement_number.maxLength)
return this.$t('validation.max_length', {
field: this.$t('form.market.settings.nordea_agreement_number'),
maxLength: this.$v.marketSettingsForm.nordea_agreement_number.$params.maxLength.max
})
}
return null
},
stateNordeaSignerIDInput () {
return this.$v.marketSettingsForm.nordea_signer_id.$error ? false : null
},
stateNordeaSignerID () {
return (!this.$v.marketSettingsForm.nordea_signer_id.$error)
},
invalidNordeaSignerID () {
if (this.$v.marketSettingsForm.nordea_signer_id.$error) {
if (!this.$v.marketSettingsForm.nordea_signer_id.numeric)
return this.$t('validation.numeric', {
field: this.$t('form.market.settings.nordea_signer_id'),
})
else if (!this.$v.marketSettingsForm.nordea_signer_id.minLength)
return this.$t('validation.min_length', {
field: this.$t('form.market.settings.nordea_signer_id'),
minLength: this.$v.marketSettingsForm.nordea_signer_id.$params.minLength.min
})
else if (!this.$v.marketSettingsForm.nordea_signer_id.maxLength)
return this.$t('validation.max_length', {
field: this.$t('form.market.settings.nordea_signer_id'),
maxLength: this.$v.marketSettingsForm.nordea_signer_id.$params.maxLength.max
})
}
return null
},
stateBankAccountInput () {
return this.$v.marketSettingsForm.bank_account.$error ? false : null
},
Expand Down
19 changes: 14 additions & 5 deletions frontend/src-base/configs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export const MIN_POSTAL_CODE_LENGTH = 3
export const MAX_POSTAL_CODE_LENGTH = 12
export const MAX_BANK_ACCOUNT_LENGTH = 10
export const BANK_REG_NUMBER_LENGTH = 4
export const MIN_NORDEA_AGREEMENT_NUMBER_LENGTH = 10
export const MAX_NORDEA_AGREEMENT_NUMBER_LENGTH = 18
export const MIN_NORDEA_SIGNER_ID_LENGTH = 1
export const MAX_NORDEA_SIGNER_ID_LENGTH = 13

export const MIN_SHELF_AMOUNT = 1
export const MAX_SHELF_AMOUNT = 1000
Expand Down Expand Up @@ -189,11 +193,12 @@ export const LEVEL_CHOICES = {
[ERROR]: 'danger',
}

const SDC = 'sdc'
const BEC = 'bec'
const DANSKE_BANK = 'danske_bank'
const NORDEA = 'nordea'
const BANKDATA = 'bankdata'
export const SDC = 'sdc'
export const BEC = 'bec'
export const DANSKE_BANK = 'danske_bank'
export const NORDEA = 'nordea'
export const NORDEA_ISO_20022 = 'nordea_iso_20022'
export const BANKDATA = 'bankdata'

export const AVAILABLE_BANK_FORMATS = [
{
Expand All @@ -212,6 +217,10 @@ export const AVAILABLE_BANK_FORMATS = [
code: NORDEA,
name: i18n.t(`multiselect.single_label.bank_export.${NORDEA}`),
},
{
code: NORDEA_ISO_20022,
name: i18n.t(`multiselect.single_label.bank_export.${NORDEA_ISO_20022}`),
},
{
code: BANKDATA,
name: i18n.t(`multiselect.single_label.bank_export.${BANKDATA}`),
Expand Down
6 changes: 5 additions & 1 deletion frontend/src-base/locale/da/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@
},
"bank_export": {
"missing_bank_data": "Udfyld butikkens reg. og konto nr. i {link}.",
"missing_nordea_data": "Indsæt aftalenummer og Signer ID in {link}.",
"missing_bank_format": "Udfyld butikken bank fil format i {link}.",
"filename": "{filetype} {description}.txt",
"filename": "{filetype} {description}.{extension}",
"back_button": "Tilbage"
},
"economic_settings": {
Expand Down Expand Up @@ -184,6 +185,7 @@
"bec": "BEC",
"danske_bank": "Danske Bank",
"nordea": "Nordea",
"nordea_iso_20022": "Nordea ISO 20022",
"bankdata": "Bankdata"
}
}
Expand Down Expand Up @@ -532,6 +534,8 @@
"support_email": "E-mail",
"bank_reg_number": "Bank reg. nr.",
"bank_account": "Bank konto nr.",
"nordea_agreement_number": "Nordea aftalenummer",
"nordea_signer_id": "Nordea Signer ID",
"bank_file_format": "Bank fil format",
"instagram_url": "Instagram link",
"facebook_url": "Facebook link",
Expand Down
6 changes: 5 additions & 1 deletion frontend/src-base/locale/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@
},
"bank_export": {
"missing_bank_data": "Please specify your reg number and account number in {link}.",
"missing_nordea_data": "Please specify your Nordea Agreement no. and Signer ID in {link}.",
"missing_bank_format": "Please specify your bank format in {link}.",
"filename": "{filetype} {description}.txt",
"filename": "{filetype} {description}.{extension}",
"back_button": "Back"
},
"economic_settings": {
Expand Down Expand Up @@ -184,6 +185,7 @@
"bec": "BEC",
"danske_bank": "Danske Bank",
"nordea": "Nordea",
"nordea_iso_20022": "Nordea ISO 20022",
"bankdata": "Bankdata"
}
}
Expand Down Expand Up @@ -536,6 +538,8 @@
"support_email": "Email",
"bank_reg_number": "Bank reg number",
"bank_account": "Bank account",
"nordea_agreement_number": "Nordea Agreement no.",
"nordea_signer_id": "Nordea Signer ID",
"bank_file_format": "Bank file format",
"instagram_url": "Instagram URL",
"facebook_url": "Facebook URL",
Expand Down
5 changes: 4 additions & 1 deletion loppeonline/api/v1/admin/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,10 @@ def bank_export(self, request, pk=None):
)
raise RestValidationError({'error': message})

return Response({'file': b64encode(data)})
return Response({
'file': b64encode(data),
'extension': exporter.extension,
})


class AdminBankExportTransactionViewSet(
Expand Down
22 changes: 22 additions & 0 deletions loppeonline/api/v1/admin/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,26 @@ class AdminMarketModelSerializer(serializers.ModelSerializer):
required=False,
allow_blank=True,
)
nordea_agreement_number = serializers.RegexField(
regex=r'^[0-9]{10,18}$',
error_messages={
'invalid': _(
'This field must be numeric and contain 10 to 18 digits.'
)
},
required=False,
allow_blank=True,
)
nordea_signer_id = serializers.RegexField(
regex=r'^[0-9]{1,13}$',
error_messages={
'invalid': _(
'This field must be numeric and contain max. 13 digits.'
)
},
required=False,
allow_blank=True,
)
bank_file_format = fields.ChoiceField(
choices=Market.BANK_FILE_FORMAT_CHOICES,
allow_blank=True,
Expand Down Expand Up @@ -300,6 +320,8 @@ class Meta:
'support_phone',
'bank_reg_number',
'bank_account',
'nordea_agreement_number',
'nordea_signer_id',
'bank_file_format',
'instagram_url',
'facebook_url',
Expand Down
Loading

0 comments on commit 88f0c42

Please sign in to comment.