Skip to content

Firefly III: a personal finances manager

Bug catching in form.

James Cole47e0f6ed89a2
diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.php
index 90af8a1448..92f0811347 100644
--- a/app/Factory/TransactionFactory.php
+++ b/app/Factory/TransactionFactory.php
@@ -135,7 +135,9 @@ class TransactionFactory
$two->reconciled = $data['reconciled'] ?? false;
// add foreign currency info to $one and $two if necessary.
- if (null !== $foreignCurrency && null !== $foreignAmount) {
+ if (null !== $foreignCurrency && null !== $foreignAmount
+ && $foreignCurrency->id !== $currency->id
+ ) {
$one->foreign_currency_id = $foreignCurrency->id;
$two->foreign_currency_id = $foreignCurrency->id;
$one->foreign_amount = app('steam')->negative($foreignAmount);
diff --git a/app/Http/Controllers/Transaction/ShowController.php b/app/Http/Controllers/Transaction/ShowController.php
index 64842c008b..d9f0165922 100644
--- a/app/Http/Controllers/Transaction/ShowController.php
+++ b/app/Http/Controllers/Transaction/ShowController.php
@@ -29,6 +29,7 @@ use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\Transformers\TransactionGroupTransformer;
+use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
@@ -64,7 +65,7 @@ class ShowController extends Controller
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
- public function show(TransactionGroup $transactionGroup)
+ public function show(Request $request, TransactionGroup $transactionGroup)
{
/** @var TransactionJournal $first */
$first = $transactionGroup->transactionJournals->first();
@@ -72,6 +73,7 @@ class ShowController extends Controller
$type = (string)trans(sprintf('firefly.%s', strtolower($first->transactionType->type)));
$title = 1 === $splits ? $first->description : $transactionGroup->title;
$subTitle = sprintf('%s: "%s"', $type, $title);
+ $message = $request->get('message');
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
@@ -111,7 +113,7 @@ class ShowController extends Controller
return view(
'transactions.show', compact(
'transactionGroup', 'amounts', 'first', 'type', 'subTitle', 'splits', 'groupArray',
- 'events', 'attachments', 'links'
+ 'events', 'attachments', 'links','message'
)
);
}
diff --git a/public/v1/js/app.js b/public/v1/js/app.js
index 9e6b62d8a9..f6131a5019 100644
--- a/public/v1/js/app.js
+++ b/public/v1/js/app.js
@@ -54629,7 +54629,7 @@ exports = module.exports = __webpack_require__(0)(false);
// module
-exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
// exports
@@ -54816,6 +54816,31 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
//
//
//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
@@ -54879,6 +54904,12 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
foreignAmount = this.transactions[key].foreign_amount.amount;
foreignCurrency = this.transactions[key].foreign_amount.currency_id;
}
+ console.log(foreignCurrency);
+ console.log(this.transactions[key].currency_id);
+ if (foreignCurrency === this.transactions[key].currency_id) {
+ foreignAmount = null;
+ foreignCurrency = null;
+ }
currentArray = {
type: transactionType,
@@ -54939,7 +54970,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
var data = this.convertData();
axios.post(uri, data).then(function (response) {
- window.location.href = 'transactions/show/' + response.data.data.id + '?message=OK';
+ window.location.href = 'transactions/show/' + response.data.data.id + '?message=created';
}).catch(function (error) {
// give user errors things back.
// something something render errors.
@@ -55577,17 +55608,31 @@ var render = function() {
on: { click: _vm.addTransaction }
},
[_vm._v("Add another split")]
- ),
- _vm._v(" "),
- _c(
- "button",
- { staticClass: "btn btn-success", on: { click: _vm.submit } },
- [_vm._v("Submit")]
)
])
])
]),
_vm._v(" "),
+ _c("div", { staticClass: "row" }, [
+ _c("div", { staticClass: "col-lg-3 col-md-4 col-sm-6 col-xs-12" }, [
+ _c("div", { staticClass: "box" }, [
+ _vm._m(2),
+ _vm._v(" "),
+ _vm._m(3),
+ _vm._v(" "),
+ _c("div", { staticClass: "box-footer" }, [
+ _c("div", { staticClass: "btn-group" }, [
+ _c(
+ "button",
+ { staticClass: "btn btn-success", on: { click: _vm.submit } },
+ [_vm._v("Submit")]
+ )
+ ])
+ ])
+ ])
+ ])
+ ]),
+ _vm._v(" "),
_c("pre", [_vm._v(_vm._s(_vm.$data))])
],
2
@@ -55622,6 +55667,38 @@ var staticRenderFns = [
)
])
])
+ },
+ function() {
+ var _vm = this
+ var _h = _vm.$createElement
+ var _c = _vm._self._c || _h
+ return _c("div", { staticClass: "box-header with-border" }, [
+ _c("h3", { staticClass: "box-title splitTitle" }, [
+ _vm._v("\n Submission\n ")
+ ])
+ ])
+ },
+ function() {
+ var _vm = this
+ var _h = _vm.$createElement
+ var _c = _vm._self._c || _h
+ return _c("div", { staticClass: "box-body" }, [
+ _c("div", { staticClass: "checkbox" }, [
+ _c("label", [
+ _c("input", {
+ attrs: {
+ id: "transaction_return_to_form",
+ name: "create_another",
+ type: "checkbox",
+ value: "1"
+ }
+ }),
+ _vm._v(
+ "\n After storing, return here to create another one.\n "
+ )
+ ])
+ ])
+ ])
}
]
render._withStripped = true
diff --git a/resources/assets/js/components/transactions/CreateTransaction.vue b/resources/assets/js/components/transactions/CreateTransaction.vue
index a50b01fa7d..6749c2f9a7 100644
--- a/resources/assets/js/components/transactions/CreateTransaction.vue
+++ b/resources/assets/js/components/transactions/CreateTransaction.vue
@@ -159,15 +159,40 @@
</div>
</div>
</div>
-
<div class="row">
<div class="col-lg-12">
<p>
<button class="btn btn-primary" @click="addTransaction">Add another split</button>
- <button class="btn btn-success" @click="submit">Submit</button>
</p>
</div>
</div>
+
+ <div class="row">
+ <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title splitTitle">
+ Submission
+ </h3>
+ </div>
+ <div class="box-body">
+ <div class="checkbox">
+ <label>
+ <input id="transaction_return_to_form" name="create_another" type="checkbox" value="1">
+ After storing, return here to create another one.
+ </label>
+ </div>
+ </div>
+ <div class="box-footer">
+ <div class="btn-group">
+
+ <button class="btn btn-success" @click="submit">Submit</button>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
<pre>{{ $data }}</pre>
</form>
</template>
@@ -237,6 +262,12 @@
foreignAmount = this.transactions[key].foreign_amount.amount;
foreignCurrency = this.transactions[key].foreign_amount.currency_id;
}
+ console.log(foreignCurrency);
+ console.log(this.transactions[key].currency_id);
+ if (foreignCurrency === this.transactions[key].currency_id) {
+ foreignAmount = null;
+ foreignCurrency = null;
+ }
currentArray =
{
@@ -278,10 +309,10 @@
currentArray.foreign_currency_id = foreignCurrency;
}
// set budget id and piggy ID.
- if(parseInt(this.transactions[key].budget) > 0) {
+ if (parseInt(this.transactions[key].budget) > 0) {
currentArray.budget_id = parseInt(this.transactions[key].budget);
}
- if(parseInt(this.transactions[key].piggy_bank) > 0) {
+ if (parseInt(this.transactions[key].piggy_bank) > 0) {
currentArray.piggy_bank_id = parseInt(this.transactions[key].piggy_bank);
}
@@ -298,7 +329,7 @@
axios.post(uri, data)
.then(response => {
- window.location.href = 'transactions/show/'+ response.data.data.id + '?message=OK';
+ window.location.href = 'transactions/show/' + response.data.data.id + '?message=created';
}).catch(error => {
// give user errors things back.
// something something render errors.
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index 2e8d60cbfc..3dbcd87920 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -851,6 +851,7 @@ return [
'deleted_deposit' => 'Successfully deleted deposit ":description"',
'deleted_transfer' => 'Successfully deleted transfer ":description"',
'stored_journal' => 'Successfully created new transaction ":description"',
+ 'stored_journal_no_descr' => 'Successfully created your new transaction',
'select_transactions' => 'Select transactions',
'rule_group_select_transactions' => 'Apply ":title" to transactions',
'rule_select_transactions' => 'Apply ":title" to transactions',
diff --git a/resources/views/v1/transactions/show.twig b/resources/views/v1/transactions/show.twig
index 82ada19cfb..4668632afc 100644
--- a/resources/views/v1/transactions/show.twig
+++ b/resources/views/v1/transactions/show.twig
@@ -5,6 +5,20 @@
{% endblock %}
{% block content %}
+ {% if message == 'created' %}
+ <div class="row">
+ <div class="col-lg-12">
+ <div class="alert alert-success alert-dismissible" role="alert">
+ <button type="button" class="close" data-dismiss="alert">
+ <span>&times;</span><span class="sr-only">{{ 'close'|_ }}</span>
+ </button>
+ <strong>{{ 'flash_success'|_ }}</strong>
+ {{ trans('firefly.stored_journal_no_descr') }}
+
+ </div>
+ </div>
+ </div>
+ {% endif %}
<div class="row">
<div class="col-lg-6">
<div class="box box-primary">