This commit is contained in:
Bernat 2019-11-19 13:40:50 +01:00
commit 20088c6712
3 changed files with 21 additions and 14 deletions

View File

@ -0,0 +1,7 @@
USE `vn`;
ALTER TABLE `vn`.`payMethod`
ADD COLUMN `code` VARCHAR(50) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci' NULL AFTER `id`;
UPDATE `vn`.`payMethod` SET `code` = 'bankDraft' WHERE (`id` = '4');
UPDATE `vn`.`payMethod` SET `code` = 'card' WHERE (`id` = '5');

View File

@ -33,16 +33,18 @@
<p>
<section>
<span>{{ $t('sections.pay.method') }}:</span>
<strong>{{client.payMethodName}}</strong>
<strong>{{payMethod.name}}</strong>
</section>
<section v-if="client.payMethodId != 5">
<section v-if="payMethod.code != 'card'">
<span>{{ $t('sections.pay.day') }}:</span>
<strong>{{ $t('sections.pay.dueDay', [client.dueDay]) }}</strong>
<strong>{{ $t('sections.pay.dueDay', [payMethod.dueDay]) }}</strong>
</section>
</p>
<p v-if="client.payMethodId == 4" v-html="$t('sections.pay.accountImplicates', [client.accountAddress])"></p>
<p v-else-if="client.payMethodId == 5">
<p v-if="payMethod.code == 'bankDraft'"
v-html="$t('sections.pay.accountImplicates', [accountAddress])">
</p>
<p v-else-if="payMethod.code == 'card'">
{{ $t('sections.pay.cardImplicates') }}
</p>

View File

@ -6,29 +6,27 @@ const emailFooter = new Component('email-footer');
module.exports = {
name: 'payment-update',
async serverPrefetch() {
this.client = await this.fetchClient(this.clientId);
this.payMethod = await this.fetchPayMethod(this.clientId);
if (!this.client)
if (!this.payMethod)
throw new Error('Something went wrong');
},
computed: {
accountAddress: function() {
return this.iban.slice(-4);
return this.payMethod.iban.slice(-4);
},
},
methods: {
// Redmine #1854 Replace payMethodId by code
fetchClient(id) {
fetchPayMethod(clientId) {
return db.findOne(
`SELECT
c.dueDay,
c.iban,
pm.id payMethodId,
pm.name payMethodName
pm.name,
pm.code
FROM client c
JOIN payMethod pm ON pm.id = c.payMethodFk
JOIN account.user u ON u.id = c.id
WHERE c.id = :clientId`, {clientId: id});
WHERE c.id = :clientId`, {clientId: clientId});
}
},
components: {