This commit is contained in:
James Cole 2019-11-10 07:26:49 +01:00
parent d2a8f969d9
commit f82d0dda0a
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
24 changed files with 96 additions and 45 deletions

View File

@ -26,6 +26,7 @@ use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\PiggyBank;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
@ -291,7 +292,26 @@ class AutoCompleteController extends Controller
/** @var PiggyBankRepositoryInterface $repository */
$repository = app(PiggyBankRepositoryInterface::class);
return response()->json($repository->getPiggyBanks()->toArray());
/** @var AccountRepositoryInterface $accountRepos */
$accountRepos = app(AccountRepositoryInterface::class);
$piggies = $repository->getPiggyBanks();
$defaultCurrency = \Amount::getDefaultCurrency();
$response = [];
/** @var PiggyBank $piggy */
foreach ($piggies as $piggy) {
$currency = $accountRepos->getAccountCurrency($piggy->account) ?? $defaultCurrency;
$currentAmount = $repository->getRepetition($piggy)->currentamount ?? '0';
$piggy->name_with_amount = sprintf(
'%s (%s / %s)',
$piggy->name,
app('amount')->formatAnything($currency, $currentAmount, false),
app('amount')->formatAnything($currency, $piggy->targetamount, false),
);
$response[] = $piggy->toArray();
}
return response()->json($response);
}
/**

View File

@ -557,8 +557,13 @@ class AccountRepository implements AccountRepositoryInterface
->orderBy('accounts.name', 'ASC')
->with(['accountType']);
if ('' !== $query) {
$search = sprintf('%%%s%%', $query);
$dbQuery->where('name', 'LIKE', $search);
// split query on spaces just in case:
$parts = explode(' ', $query);
foreach($parts as $part) {
$search = sprintf('%%%s%%', $part);
$dbQuery->where('name', 'LIKE', $search);
}
}
if (count($types) > 0) {
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');

View File

@ -418,9 +418,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*/
public function getPiggyBanks(): Collection
{
return $this->user->piggyBanks()->orderBy('order', 'ASC')->get();
return $this->user->piggyBanks()->with(['account'])->orderBy('order', 'ASC')->get();
}
/**
* Also add amount in name.
*

File diff suppressed because one or more lines are too long

View File

@ -45,7 +45,7 @@
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
{{ $t('firefly.split_title_help')}}
{{ $t('firefly.split_transaction_title')}}
</h3>
</div>
<div class="box-body">
@ -385,7 +385,7 @@
// this method will ultimately send the user on (or not).
if (0 === this.collectAttachmentData(response)) {
// console.log('Will now go to redirectUser()');
this.redirectUser(response.data.data.id, button);
this.redirectUser(response.data.data.id, button, response.data.data);
}
}).catch(error => {
// give user errors things back.
@ -401,14 +401,20 @@
e.preventDefault();
}
},
redirectUser(groupId, button) {
escapeHTML(unsafeText) {
let div = document.createElement('div');
div.innerText = unsafeText;
return div.innerHTML;
},
redirectUser(groupId, button, transactionData) {
// console.log('In redirectUser()');
// console.log(transactionData);
let title = null === transactionData.attributes.group_title ? transactionData.attributes.transactions[0].description : transactionData.attributes.group_title;
// console.log('Title is "' + title + '"');
// if count is 0, send user onwards.
if (this.createAnother) {
// console.log('Will create another.');
// do message:
this.success_message = '<a href="transactions/show/' + groupId + '">Transaction #' + groupId + '</a> has been stored.';
this.success_message = '<a href="transactions/show/' + groupId + '">Transaction #' + groupId + ' ("' + this.escapeHTML(title) + '")</a> has been stored.';
this.error_message = '';
if (this.resetFormAfter) {
// also clear form.
@ -478,7 +484,7 @@
}
);
if (fileData.length === count) {
theParent.uploadFiles(fileData, groupId);
theParent.uploadFiles(fileData, groupId, response.data.data);
}
}
};
@ -489,7 +495,7 @@
return count;
},
uploadFiles(fileData, groupId) {
uploadFiles(fileData, groupId, transactionData) {
let count = fileData.length;
let uploads = 0;
for (const key in fileData) {
@ -508,13 +514,13 @@
// console.log('Uploading attachment #' + key);
const uploadUri = './api/v1/attachments/' + response.data.data.id + '/upload';
axios.post(uploadUri, fileData[key].content)
.then(response => {
.then(attachmentResponse => {
// console.log('Uploaded attachment #' + key);
uploads++;
if (uploads === count) {
// finally we can redirect the user onwards.
// console.log('FINAL UPLOAD');
this.redirectUser(groupId);
this.redirectUser(groupId, null, transactionData);
}
// console.log('Upload complete!');
return true;
@ -526,7 +532,7 @@
if (uploads === count) {
// finally we can redirect the user onwards.
// console.log('FINAL UPLOAD');
this.redirectUser(groupId);
this.redirectUser(groupId, null, transactionData);
}
// console.log('Upload complete!');
return false;

View File

@ -24,7 +24,7 @@
v-if="typeof this.transactionType !== 'undefined' && this.transactionType === 'Transfer'">
<div class="col-sm-12">
<select name="piggy_bank[]" ref="piggy" @input="handleInput" class="form-control" v-if="this.piggies.length > 0">
<option v-for="piggy in this.piggies" :label="piggy.name" :value="piggy.id">{{piggy.name}}</option>
<option v-for="piggy in this.piggies" :label="piggy.name_with_amount" :value="piggy.id">{{piggy.name_with_amount}}</option>
</select>
<ul class="list-unstyled" v-for="error in this.error">
<li class="text-danger">{{ error }}</li>
@ -57,7 +57,7 @@
axios.get(URI, {}).then((res) => {
this.piggies = [
{
name: this.no_piggy_bank,
name_with_amount: this.no_piggy_bank,
id: 0,
}
];

View File

@ -28,7 +28,8 @@
"split_title_help": "Pokud vytvo\u0159\u00edte roz\u00fa\u010dtov\u00e1n\u00ed, je t\u0159eba, aby zde byl celkov\u00fd popis pro v\u0161echna roz\u00fa\u010dtov\u00e1n\u00ed dan\u00e9 transakce.",
"none_in_select_list": "(\u017e\u00e1dn\u00e9)",
"no_piggy_bank": "(no piggy bank)",
"description": "Popis"
"description": "Popis",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "\u00darokov\u00e9 datum",

View File

@ -28,7 +28,8 @@
"split_title_help": "Wenn Sie eine Splittbuchung anlegen, muss es eine eindeutige Beschreibung f\u00fcr alle Aufteilungen der Buchhaltung geben.",
"none_in_select_list": "(Keine)",
"no_piggy_bank": "(kein Sparschwein)",
"description": "Beschreibung"
"description": "Beschreibung",
"split_transaction_title_help": "Wenn Sie eine Splittbuchung anlegen, muss es eine eindeutige Beschreibung f\u00fcr alle Aufteilungen der Buchung geben."
},
"form": {
"interest_date": "Zinstermin",

View File

@ -28,7 +28,8 @@
"split_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction.",
"none_in_select_list": "(\u03c4\u03af\u03c0\u03bf\u03c4\u03b1)",
"no_piggy_bank": "(no piggy bank)",
"description": "Description"
"description": "Description",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "\u0397\u03bc\u03b5\u03c1\u03bf\u03bc\u03b7\u03bd\u03af\u03b1 \u03c4\u03bf\u03ba\u03b9\u03c3\u03bc\u03bf\u03cd",

View File

@ -28,7 +28,8 @@
"split_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction.",
"none_in_select_list": "(none)",
"no_piggy_bank": "(no piggy bank)",
"description": "Description"
"description": "Description",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "Interest date",

View File

@ -28,7 +28,8 @@
"split_title_help": "Si crea una transacci\u00f3n dividida, debe haber una descripci\u00f3n global para todos los fragmentos de la transacci\u00f3n.",
"none_in_select_list": "(ninguno)",
"no_piggy_bank": "(sin alcanc\u00eda)",
"description": "Descripci\u00f3n"
"description": "Descripci\u00f3n",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "Fecha de inter\u00e9s",

View File

@ -5,15 +5,15 @@
"flash_success": "Termin\u00e9 avec succ\u00e8s !",
"close": "Fermer",
"split_transaction_title": "Description de l'op\u00e9ration ventil\u00e9e",
"errors_submission": "There was something wrong with your submission. Please check out the errors below.",
"errors_submission": "Certaines informations ne sont pas correctes dans votre formulaire. Veuillez v\u00e9rifier les erreurs ci-dessous.",
"split": "Ventiler",
"transaction_journal_information": "Informations sur les transactions",
"source_account": "Compte d'origine",
"destination_account": "Compte de destination",
"add_another_split": "Ajouter une autre fraction",
"submission": "Submission",
"create_another": "After storing, return here to create another one.",
"reset_after": "Reset form after submission",
"submission": "Soumission",
"create_another": "Apr\u00e8s enregistrement, revenir ici pour en cr\u00e9er un nouveau.",
"reset_after": "R\u00e9initialiser le formulaire apr\u00e8s soumission",
"submit": "Soumettre",
"amount": "Montant",
"date": "Date",
@ -22,13 +22,14 @@
"category": "Cat\u00e9gorie",
"attachments": "Pi\u00e8ces jointes",
"notes": "Notes",
"update_transaction": "Update transaction",
"after_update_create_another": "After updating, return here to continue editing.",
"store_as_new": "Store as a new transaction instead of updating.",
"update_transaction": "Mettre \u00e0 jour la transaction",
"after_update_create_another": "Apr\u00e8s la mise \u00e0 jour, revenir ici pour continuer l'\u00e9dition.",
"store_as_new": "Enregistrer comme une nouvelle transaction au lieu de mettre \u00e0 jour.",
"split_title_help": "Si vous cr\u00e9ez une op\u00e9ration ventil\u00e9e, il doit y avoir une description globale pour chaque fractions de l'op\u00e9ration.",
"none_in_select_list": "(aucun)",
"no_piggy_bank": "(no piggy bank)",
"description": "Description"
"no_piggy_bank": "(aucune tirelire)",
"description": "Description",
"split_transaction_title_help": "Si vous cr\u00e9ez une op\u00e9ration ventil\u00e9e, il doit y avoir une description globale pour chaque fraction de l'op\u00e9ration."
},
"form": {
"interest_date": "Date de l\u2019int\u00e9r\u00eat",

View File

@ -28,7 +28,8 @@
"split_title_help": "Felosztott tranzakci\u00f3 l\u00e9trehoz\u00e1sakor meg kell adni egy glob\u00e1lis le\u00edr\u00e1st a tranzakci\u00f3 \u00f6sszes feloszt\u00e1sa r\u00e9sz\u00e9re.",
"none_in_select_list": "(nincs)",
"no_piggy_bank": "(no piggy bank)",
"description": "Le\u00edr\u00e1s"
"description": "Le\u00edr\u00e1s",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "Kamatfizet\u00e9si id\u0151pont",

View File

@ -28,7 +28,8 @@
"split_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction.",
"none_in_select_list": "(none)",
"no_piggy_bank": "(no piggy bank)",
"description": "Deskripsi"
"description": "Deskripsi",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "Tanggal bunga",

View File

@ -28,7 +28,8 @@
"split_title_help": "Se crei una transazione suddivisa \u00e8 necessario che ci sia una descrizione globale per tutte le suddivisioni della transazione.",
"none_in_select_list": "(nessuna)",
"no_piggy_bank": "(nessun salvadanaio)",
"description": "Descrizione"
"description": "Descrizione",
"split_transaction_title_help": "Se crei una transazione suddivisa, \u00e8 necessario che ci sia una descrizione globale per tutte le suddivisioni della transazione."
},
"form": {
"interest_date": "Data interesse",

View File

@ -28,7 +28,8 @@
"split_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction.",
"none_in_select_list": "(ingen)",
"no_piggy_bank": "(no piggy bank)",
"description": "Beskrivelse"
"description": "Beskrivelse",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "Rentedato",

View File

@ -28,7 +28,8 @@
"split_title_help": "Als je een gesplitste transactie maakt, moet er een algemene beschrijving zijn voor alle splitsingen van de transactie.",
"none_in_select_list": "(geen)",
"no_piggy_bank": "(geen spaarpotje)",
"description": "Omschrijving"
"description": "Omschrijving",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "Rentedatum",

View File

@ -27,8 +27,9 @@
"store_as_new": "Zapisz jako now\u0105 zamiast aktualizowa\u0107.",
"split_title_help": "Podzielone transakcje musz\u0105 posiada\u0107 globalny opis.",
"none_in_select_list": "(\u017cadne)",
"no_piggy_bank": "(brak skarbonek)",
"description": "Opis"
"no_piggy_bank": "(brak skarbonki)",
"description": "Opis",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "Data odsetek",

View File

@ -28,7 +28,8 @@
"split_title_help": "Se voc\u00ea criar uma transa\u00e7\u00e3o dividida, \u00e9 necess\u00e1rio haver uma descri\u00e7\u00e3o global para todas as partes da transa\u00e7\u00e3o.",
"none_in_select_list": "(nenhum)",
"no_piggy_bank": "(nenhum cofrinho)",
"description": "Descri\u00e7\u00e3o"
"description": "Descri\u00e7\u00e3o",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "Data de interesse",

View File

@ -28,7 +28,8 @@
"split_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction.",
"none_in_select_list": "(nici unul)",
"no_piggy_bank": "(no piggy bank)",
"description": "Descriere"
"description": "Descriere",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "Data de interes",

View File

@ -28,7 +28,8 @@
"split_title_help": "\u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u0443\u044e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e, \u0442\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043b\u0435 \u0432\u0441\u0435\u0445 \u0435\u0451 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445.",
"none_in_select_list": "(\u043d\u0435\u0442)",
"no_piggy_bank": "(\u043d\u0435\u0442 \u043a\u043e\u043f\u0438\u043b\u043a\u0438)",
"description": "\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435"
"description": "\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435",
"split_transaction_title_help": "\u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u0443\u044e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e, \u0442\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0435\u0451 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445."
},
"form": {
"interest_date": "\u0414\u0430\u0442\u0430 \u0432\u044b\u043f\u043b\u0430\u0442\u044b",

View File

@ -28,7 +28,8 @@
"split_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction.",
"none_in_select_list": "(Yok)",
"no_piggy_bank": "(no piggy bank)",
"description": "A\u00e7\u0131klama"
"description": "A\u00e7\u0131klama",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "Faiz tarihi",

View File

@ -28,7 +28,8 @@
"split_title_help": "\u5982\u679c\u60a8\u521b\u5efa\u4e00\u4e2a\u62c6\u5206\u4ea4\u6613\uff0c\u5fc5\u987b\u6709\u4e00\u4e2a\u5168\u5c40\u7684\u4ea4\u6613\u63cf\u8ff0\u3002",
"none_in_select_list": "\uff08\u7a7a\uff09",
"no_piggy_bank": "(no piggy bank)",
"description": "\u63cf\u8ff0"
"description": "\u63cf\u8ff0",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "\u5229\u7387\u65e5\u671f",

View File

@ -28,7 +28,8 @@
"split_title_help": "\u82e5\u60a8\u5efa\u7acb\u4e00\u7b46\u62c6\u5206\u4ea4\u6613\uff0c\u9808\u6709\u4e00\u500b\u6709\u95dc\u4ea4\u6613\u6240\u6709\u62c6\u5206\u7684\u6574\u9ad4\u63cf\u8ff0\u3002",
"none_in_select_list": "(\u7a7a)",
"no_piggy_bank": "(no piggy bank)",
"description": "\u63cf\u8ff0"
"description": "\u63cf\u8ff0",
"split_transaction_title_help": "If you create a split transaction, there must be a global description for all splits of the transaction."
},
"form": {
"interest_date": "\u5229\u7387\u65e5\u671f",