From 438a4554682b49d019375b65066f01c419ba2fa5 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sat, 14 Mar 2020 11:31:20 +0100 Subject: [PATCH] :sparkles: (transaction) save location in transaction --- .env | 3 +- src/components/TagList.vue | 2 +- src/components/TransactionCreate.vue | 3 +- src/services/MapService.ts | 4 +- src/views/transactions/TransactionItem.vue | 198 ++++++++++++--------- 5 files changed, 116 insertions(+), 94 deletions(-) diff --git a/.env b/.env index ed064e5..bf7df5c 100644 --- a/.env +++ b/.env @@ -1 +1,2 @@ -VUE_APP_COUCHDB=https://couch.li212.fr \ No newline at end of file +VUE_APP_COUCHDB=https://couch.li212.fr +VUE_APP_MAP_KEY=AnLDo_m_IGvMsQPLuBak9igWj3gNYvqBodj0esZZ7VfI1OkqVWvg04eTZ4U9R0Y2 \ No newline at end of file diff --git a/src/components/TagList.vue b/src/components/TagList.vue index 96fc9ab..ca8bd2f 100644 --- a/src/components/TagList.vue +++ b/src/components/TagList.vue @@ -46,7 +46,7 @@
-
+
@@ -290,6 +290,7 @@ export default class TransactionCreate extends Vue { mainCurrency: this.currency, currencies: this.account.currencies, transactionType: TransactionType.normal, + location: this.transaction.location, exchange: await exchangeService.get(this.currency.code, date, currencies) } const response: PouchDB.Core.Response = hasId diff --git a/src/services/MapService.ts b/src/services/MapService.ts index 7d4698e..6eeb9c6 100644 --- a/src/services/MapService.ts +++ b/src/services/MapService.ts @@ -23,9 +23,7 @@ class MapService { } private url(latitude: number, longitude: number) { - return `https://dev.virtualearth.net/REST/v1/Locations/${latitude},${longitude}?key=${ - this.key - }` + return `https://dev.virtualearth.net/REST/v1/Locations/${latitude},${longitude}?key=${this.key}` } } diff --git a/src/views/transactions/TransactionItem.vue b/src/views/transactions/TransactionItem.vue index a1cb3b9..7197eaa 100644 --- a/src/views/transactions/TransactionItem.vue +++ b/src/views/transactions/TransactionItem.vue @@ -25,92 +25,96 @@ -

{{ transaction.date | fulldate }}

-
- Dépense payée par - {{ transaction.payBy }} - pour - {{ payForLabel.join(', ') }} - d'une somme de - {{ - transaction.amount | money(transaction.mainCurrency) - }}. -
-
-
-
-

- Taux d'échange le {{ transaction.date | fulldate }} -

-
-
- - - - - - - -
- {{ - transaction.amount | money(transaction.mainCurrency) - }} -
- {{ - (transaction.amount * - transaction.exchange.rates[currency.code]) - | moneypad(currency) - }} -
-
-
- - - - - - - -
- {{ - 1 | money(transaction.mainCurrency) - }} -
- {{ - transaction.exchange.rates[currency.code] - | moneypad(currency) - }} -
-
-
- - - - - - - - -
- {{ - $tc('transaction.money', currencies.length) - }} -
{{ 1 | money(currency) }} - {{ - (1 / transaction.exchange.rates[currency.code]) - | moneypad(transaction.mainCurrency) - }} -
+
+
+

{{ transaction.date | fulldate }}

+
+ Dépense payée par + {{ transaction.payBy }} + + pour + {{ payForLabel.join(', ') }} + + + à {{ transaction.location.place }} + + d'une somme de + {{ + transaction.amount | money(transaction.mainCurrency) + }} + . +
+
+
+
+

+ Taux d'échange +

+
+
+ + + + + + + +
+ {{ + transaction.amount | money(transaction.mainCurrency) + }} +
+ {{ + (transaction && transaction.amount) || + (1 * getRate(currency.code)) | moneypad(currency) + }} +
+
+
+ + + + + + + +
+ {{ + 1 | money(transaction.mainCurrency) + }} +
+ {{ getRate(currency.code) | moneypad(currency) }} +
+
+
+ + + + + + + + +
+ {{ + $tc('transaction.money', currencies.length) + }} +
{{ 1 | money(currency) }} + {{ + (1 / getRate(currency.code)) + | moneypad(transaction && transaction.mainCurrency) + }} +
+
-
-
- Le taux d'échange n'a pas pu - être récupéré. +
+ + Le taux d'échange n'a pas pu être récupéré. +
modifier - supprimer + modifier + + + supprimer +
@@ -227,6 +232,22 @@ export default class TransactionItem extends Vue { } } + public getRate(code: string) { + return ( + (this.transaction && + this.transaction.exchange && + this.transaction.exchange.rates[code]) || + 1 + ) + } + + public uniqueUser() { + if (!this.transaction) { + return false + } + return this.transaction.payBy === this.payForLabel.join(',') + } + public get accountId(): string { return (this.transaction && this.transaction.accountId) || '' } @@ -303,7 +324,8 @@ table.table { .buttons { margin-top: 15px; } -.pay-by { +.pay-by, +.pay-for { font-weight: bold; } .numeric {