Bug catching in form.

This commit is contained in:
James Cole
2019-05-24 05:47:26 +02:00
parent 8f1928c933
commit 47e0f6ed89
6 changed files with 143 additions and 16 deletions

View File

@@ -135,7 +135,9 @@ class TransactionFactory
$two->reconciled = $data['reconciled'] ?? false; $two->reconciled = $data['reconciled'] ?? false;
// add foreign currency info to $one and $two if necessary. // 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; $one->foreign_currency_id = $foreignCurrency->id;
$two->foreign_currency_id = $foreignCurrency->id; $two->foreign_currency_id = $foreignCurrency->id;
$one->foreign_amount = app('steam')->negative($foreignAmount); $one->foreign_amount = app('steam')->negative($foreignAmount);

View File

@@ -29,6 +29,7 @@ use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface; use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;
use FireflyIII\Transformers\TransactionGroupTransformer; use FireflyIII\Transformers\TransactionGroupTransformer;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\ParameterBag;
/** /**
@@ -64,7 +65,7 @@ class ShowController extends Controller
* *
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/ */
public function show(TransactionGroup $transactionGroup) public function show(Request $request, TransactionGroup $transactionGroup)
{ {
/** @var TransactionJournal $first */ /** @var TransactionJournal $first */
$first = $transactionGroup->transactionJournals->first(); $first = $transactionGroup->transactionJournals->first();
@@ -72,6 +73,7 @@ class ShowController extends Controller
$type = (string)trans(sprintf('firefly.%s', strtolower($first->transactionType->type))); $type = (string)trans(sprintf('firefly.%s', strtolower($first->transactionType->type)));
$title = 1 === $splits ? $first->description : $transactionGroup->title; $title = 1 === $splits ? $first->description : $transactionGroup->title;
$subTitle = sprintf('%s: "%s"', $type, $title); $subTitle = sprintf('%s: "%s"', $type, $title);
$message = $request->get('message');
/** @var TransactionGroupTransformer $transformer */ /** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class); $transformer = app(TransactionGroupTransformer::class);
@@ -111,7 +113,7 @@ class ShowController extends Controller
return view( return view(
'transactions.show', compact( 'transactions.show', compact(
'transactionGroup', 'amounts', 'first', 'type', 'subTitle', 'splits', 'groupArray', 'transactionGroup', 'amounts', 'first', 'type', 'subTitle', 'splits', 'groupArray',
'events', 'attachments', 'links' 'events', 'attachments', 'links','message'
) )
); );
} }

93
public/v1/js/app.js vendored
View File

@@ -54629,7 +54629,7 @@ exports = module.exports = __webpack_require__(0)(false);
// module // 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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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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\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 // 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; foreignAmount = this.transactions[key].foreign_amount.amount;
foreignCurrency = this.transactions[key].foreign_amount.currency_id; 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 = { currentArray = {
type: transactionType, type: transactionType,
@@ -54939,7 +54970,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
var data = this.convertData(); var data = this.convertData();
axios.post(uri, data).then(function (response) { 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) { }).catch(function (error) {
// give user errors things back. // give user errors things back.
// something something render errors. // something something render errors.
@@ -55577,17 +55608,31 @@ var render = function() {
on: { click: _vm.addTransaction } on: { click: _vm.addTransaction }
}, },
[_vm._v("Add another split")] [_vm._v("Add another split")]
),
_vm._v(" "),
_c(
"button",
{ staticClass: "btn btn-success", on: { click: _vm.submit } },
[_vm._v("Submit")]
) )
]) ])
]) ])
]), ]),
_vm._v(" "), _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))]) _c("pre", [_vm._v(_vm._s(_vm.$data))])
], ],
2 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 render._withStripped = true

View File

@@ -159,15 +159,40 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<p> <p>
<button class="btn btn-primary" @click="addTransaction">Add another split</button> <button class="btn btn-primary" @click="addTransaction">Add another split</button>
<button class="btn btn-success" @click="submit">Submit</button>
</p> </p>
</div> </div>
</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> <pre>{{ $data }}</pre>
</form> </form>
</template> </template>
@@ -237,6 +262,12 @@
foreignAmount = this.transactions[key].foreign_amount.amount; foreignAmount = this.transactions[key].foreign_amount.amount;
foreignCurrency = this.transactions[key].foreign_amount.currency_id; 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 = currentArray =
{ {
@@ -278,10 +309,10 @@
currentArray.foreign_currency_id = foreignCurrency; currentArray.foreign_currency_id = foreignCurrency;
} }
// set budget id and piggy ID. // 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); 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); currentArray.piggy_bank_id = parseInt(this.transactions[key].piggy_bank);
} }
@@ -298,7 +329,7 @@
axios.post(uri, data) axios.post(uri, data)
.then(response => { .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 => { }).catch(error => {
// give user errors things back. // give user errors things back.
// something something render errors. // something something render errors.

View File

@@ -851,6 +851,7 @@ return [
'deleted_deposit' => 'Successfully deleted deposit ":description"', 'deleted_deposit' => 'Successfully deleted deposit ":description"',
'deleted_transfer' => 'Successfully deleted transfer ":description"', 'deleted_transfer' => 'Successfully deleted transfer ":description"',
'stored_journal' => 'Successfully created new transaction ":description"', 'stored_journal' => 'Successfully created new transaction ":description"',
'stored_journal_no_descr' => 'Successfully created your new transaction',
'select_transactions' => 'Select transactions', 'select_transactions' => 'Select transactions',
'rule_group_select_transactions' => 'Apply ":title" to transactions', 'rule_group_select_transactions' => 'Apply ":title" to transactions',
'rule_select_transactions' => 'Apply ":title" to transactions', 'rule_select_transactions' => 'Apply ":title" to transactions',

View File

@@ -5,6 +5,20 @@
{% endblock %} {% endblock %}
{% block content %} {% 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="row">
<div class="col-lg-6"> <div class="col-lg-6">
<div class="box box-primary"> <div class="box box-primary">