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

View File

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