Skip to content

Firefly III: a personal finances manager

Lots of new code and first submission thing.

James Cole43a17d867606
diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.php
index e0b3c39871..10871b7cf2 100644
--- a/app/Http/Controllers/Transaction/CreateController.php
+++ b/app/Http/Controllers/Transaction/CreateController.php
@@ -58,19 +58,17 @@ class CreateController extends Controller
/**
* Create a new transaction group.
*
- * @param Request $request
* @param string|null objectType
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
- public function create(Request $request, string $objectType = null)
+ public function create()
{
- $objectType = strtolower($objectType ?? TransactionType::WITHDRAWAL);
+ $objectType = TransactionType::WITHDRAWAL;
$preFilled = session()->has('preFilled') ? session('preFilled') : [];
$subTitle = (string)trans('breadcrumbs.create_new_transaction');
$subTitleIcon = 'fa-plus';
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
- $source = (int)$request->get('source');
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
$accountToTypes = config('firefly.account_to_transaction');
$defaultCurrency = app('amount')->getDefaultCurrency();
@@ -88,4 +86,11 @@ class CreateController extends Controller
);
}
+ public function store(Request $request)
+ {
+ echo '<pre>';
+ print_r($request->all());
+ exit;
+ }
+
}
\ No newline at end of file
diff --git a/public/v1/js/app.js b/public/v1/js/app.js
index 26bd957d26..2a6241b953 100644
--- a/public/v1/js/app.js
+++ b/public/v1/js/app.js
@@ -50047,7 +50047,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", ""]);
+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", ""]);
// exports
@@ -50095,7 +50095,8 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
var url = document.getElementsByTagName('base')[0].href + 'api/v1/preferences/transaction_journal_optional_fields';
axios.get(url).then(function (response) {
- console.log(response.data.data.attributes);
+ // TODO here we are.
+ //console.log(response.data.data.attributes);
}).catch(function () {
return console.warn('Oh. Something went wrong');
});
@@ -54104,7 +54105,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", ""]);
+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", ""]);
// exports
@@ -54264,100 +54265,155 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
//
//
//
+//
+//
+//
+//
/* harmony default export */ __webpack_exports__["default"] = ({
name: "CreateTransaction",
components: {},
mounted: function mounted() {
- // not sure if something needs to happen here.
+ this.addTransaction();
},
ready: function ready() {},
methods: {
addTransaction: function addTransaction(e) {
- var latest = this.transactions.transactions[this.transactions.transactions.length - 1];
- this.transactions.transactions.push(latest);
- e.preventDefault();
+ this.transactions.push({
+ description: "",
+ date: "",
+ amount: "",
+ foreign_amount: "",
+ source_account: {
+ id: 0,
+ name: "",
+ type: "",
+ //currency_id: window.defaultCurrency.id,
+ //currency_name: window.defaultCurrency.name,
+ //currency_code: window.defaultCurrency.code,
+ //currency_decimal_places: window.defaultCurrency.decimal_places,
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: []
+ },
+ destination_account: {
+ id: 0,
+ name: "",
+ type: "",
+ //currency_id: window.defaultCurrency.id,
+ //currency_name: window.defaultCurrency.name,
+ //currency_code: window.defaultCurrency.code,
+ //currency_decimal_places: window.defaultCurrency.decimal_places,
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: []
+ }
+ });
+ if (e) {
+ e.preventDefault();
+ }
},
setTransactionType: function setTransactionType(type) {
this.transactionType = type;
},
+ deleteTransaction: function deleteTransaction(index, event) {
+ event.preventDefault();
+ for (var key in this.transactions) {
+ if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
+ console.log('Transactions[' + key + '] exists: ' + this.transactions[key].description);
+ }
+ }
+
+ this.transactions.splice(index, 1);
+ console.log('Going to remove index ' + index);
+
+ for (var _key in this.transactions) {
+ if (this.transactions.hasOwnProperty(_key) && /^0$|^[1-9]\d*$/.test(_key) && _key <= 4294967294) {
+ console.log('New: Transactions[' + _key + '] exists: ' + this.transactions[_key].description);
+ }
+ }
+ },
limitSourceType: function limitSourceType(type) {
var i = void 0;
- for (i = 0; i < this.transactions.transactions.length; i++) {
- this.transactions.transactions[i].source_account.allowed_types = [type];
+ for (i = 0; i < this.transactions.length; i++) {
+ this.transactions[i].source_account.allowed_types = [type];
}
},
limitDestinationType: function limitDestinationType(type) {
var i = void 0;
- for (i = 0; i < this.transactions.transactions.length; i++) {
- this.transactions.transactions[i].destination_account.allowed_types = [type];
+ for (i = 0; i < this.transactions.length; i++) {
+ this.transactions[i].destination_account.allowed_types = [type];
}
},
selectedSourceAccount: function selectedSourceAccount(index, model) {
if (typeof model === 'string') {
// cant change types, only name.
- this.transactions.transactions[index].source_account.name = model;
+ this.transactions[index].source_account.name = model;
} else {
// todo maybe replace the entire model?
- this.transactions.transactions[index].source_account.id = model.id;
- this.transactions.transactions[index].source_account.name = model.name;
- this.transactions.transactions[index].source_account.type = model.type;
-
- this.transactions.transactions[index].source_account.currency_id = model.currency_id;
- this.transactions.transactions[index].source_account.currency_name = model.currency_name;
- this.transactions.transactions[index].source_account.currency_code = model.currency_code;
- this.transactions.transactions[index].source_account.currency_decimal_places = model.currency_decimal_places;
+ this.transactions[index].source_account.id = model.id;
+ this.transactions[index].source_account.name = model.name;
+ this.transactions[index].source_account.type = model.type;
+
+ this.transactions[index].source_account.currency_id = model.currency_id;
+ this.transactions[index].source_account.currency_name = model.currency_name;
+ this.transactions[index].source_account.currency_code = model.currency_code;
+ this.transactions[index].source_account.currency_decimal_places = model.currency_decimal_places;
// force types on destination selector.
- this.transactions.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type];
+ this.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type];
}
},
selectedDestinationAccount: function selectedDestinationAccount(index, model) {
if (typeof model === 'string') {
// cant change types, only name.
- this.transactions.transactions[index].destination_account.name = model;
+ this.transactions[index].destination_account.name = model;
} else {
// todo maybe replace the entire model?
- this.transactions.transactions[index].destination_account.id = model.id;
- this.transactions.transactions[index].destination_account.name = model.name;
- this.transactions.transactions[index].destination_account.type = model.type;
+ this.transactions[index].destination_account.id = model.id;
+ this.transactions[index].destination_account.name = model.name;
+ this.transactions[index].destination_account.type = model.type;
- this.transactions.transactions[index].destination_account.currency_id = model.currency_id;
- this.transactions.transactions[index].destination_account.currency_name = model.currency_name;
- this.transactions.transactions[index].destination_account.currency_code = model.currency_code;
- this.transactions.transactions[index].destination_account.currency_decimal_places = model.currency_decimal_places;
+ this.transactions[index].destination_account.currency_id = model.currency_id;
+ this.transactions[index].destination_account.currency_name = model.currency_name;
+ this.transactions[index].destination_account.currency_code = model.currency_code;
+ this.transactions[index].destination_account.currency_decimal_places = model.currency_decimal_places;
// force types on destination selector.
- this.transactions.transactions[index].source_account.allowed_types = window.allowedOpposingTypes.destination[model.type];
+ this.transactions[index].source_account.allowed_types = window.allowedOpposingTypes.destination[model.type];
}
},
clearSource: function clearSource(index) {
- this.transactions.transactions[index].source_account.id = 0;
- this.transactions.transactions[index].source_account.name = "";
- this.transactions.transactions[index].source_account.type = "";
- this.transactions.transactions[index].destination_account.allowed_types = [];
+ this.transactions[index].source_account.id = 0;
+ this.transactions[index].source_account.name = "";
+ this.transactions[index].source_account.type = "";
+ this.transactions[index].destination_account.allowed_types = [];
// if there is a destination model, reset the types of the source
// by pretending we selected it again.
- if (this.transactions.transactions[index].destination_account) {
+ if (this.transactions[index].destination_account) {
console.log('There is a destination account.');
- this.selectedDestinationAccount(index, this.transactions.transactions[index].destination_account);
+ this.selectedDestinationAccount(index, this.transactions[index].destination_account);
}
},
clearDestination: function clearDestination(index) {
- this.transactions.transactions[index].destination_account.id = 0;
- this.transactions.transactions[index].destination_account.name = "";
- this.transactions.transactions[index].destination_account.type = "";
- this.transactions.transactions[index].source_account.allowed_types = [];
+ this.transactions[index].destination_account.id = 0;
+ this.transactions[index].destination_account.name = "";
+ this.transactions[index].destination_account.type = "";
+ this.transactions[index].source_account.allowed_types = [];
// if there is a source model, reset the types of the destination
// by pretending we selected it again.
- if (this.transactions.transactions[index].source_account) {
+ if (this.transactions[index].source_account) {
console.log('There is a source account.');
- this.selectedSourceAccount(index, this.transactions.transactions[index].source_account);
+ this.selectedSourceAccount(index, this.transactions[index].source_account);
}
}
},
@@ -54368,43 +54424,8 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
data: function data() {
return {
transactionType: null,
- transactions: {
- group_title: "",
- transactions: [{
- description: "",
- date: "",
- amount: "",
- foreign_amount: "",
- source_account: {
- id: 0,
- name: "",
- type: "",
- //currency_id: window.defaultCurrency.id,
- //currency_name: window.defaultCurrency.name,
- //currency_code: window.defaultCurrency.code,
- //currency_decimal_places: window.defaultCurrency.decimal_places,
- currency_id: 0,
- currency_name: '',
- currency_code: '',
- currency_decimal_places: 2,
- allowed_types: []
- },
- destination_account: {
- id: 0,
- name: "",
- type: "",
- //currency_id: window.defaultCurrency.id,
- //currency_name: window.defaultCurrency.name,
- //currency_code: window.defaultCurrency.code,
- //currency_decimal_places: window.defaultCurrency.decimal_places,
- currency_id: 0,
- currency_name: '',
- currency_code: '',
- currency_decimal_places: 2,
- allowed_types: []
- }
- }]
- }
+ group_title: "",
+ transactions: []
};
}
});
@@ -54423,7 +54444,7 @@ var render = function() {
staticClass: "form-horizontal",
attrs: {
method: "POST",
- action: "xxxx",
+ action: "transactions/store",
"accept-charset": "UTF-8",
id: "store",
enctype: "multipart/form-data"
@@ -54432,7 +54453,7 @@ var render = function() {
[
_c("input", { attrs: { name: "_token", type: "hidden", value: "xxx" } }),
_vm._v(" "),
- _vm.transactions.transactions.length > 1
+ _vm.transactions.length > 1
? _c("div", { staticClass: "row" }, [
_c("div", { staticClass: "col-lg-6" }, [
_c("div", { staticClass: "box" }, [
@@ -54446,8 +54467,8 @@ var render = function() {
{
name: "model",
rawName: "v-model",
- value: _vm.transactions.group_title,
- expression: "transactions.group_title"
+ value: _vm.group_title,
+ expression: "group_title"
}
],
staticClass: "form-control",
@@ -54458,17 +54479,13 @@ var render = function() {
autocomplete: "off",
placeholder: "Description of the split transaction"
},
- domProps: { value: _vm.transactions.group_title },
+ domProps: { value: _vm.group_title },
on: {
input: function($event) {
if ($event.target.composing) {
return
}
- _vm.$set(
- _vm.transactions,
- "group_title",
- $event.target.value
- )
+ _vm.group_title = $event.target.value
}
}
}),
@@ -54486,28 +54503,52 @@ var render = function() {
])
: _vm._e(),
_vm._v(" "),
- _vm._l(_vm.transactions.transactions, function(transaction, index) {
+ _vm._l(_vm.transactions, function(transaction, index) {
return _c("div", [
_c("div", { staticClass: "row" }, [
_c("div", { staticClass: "col-lg-12" }, [
_c("div", { staticClass: "box" }, [
_c("div", { staticClass: "box-header with-border" }, [
_c("h3", { staticClass: "box-title splitTitle" }, [
- _vm.transactions.transactions.length > 1
+ _vm.transactions.length > 1
? _c("span", [
_vm._v(
"Split " +
_vm._s(index + 1) +
" / " +
- _vm._s(_vm.transactions.transactions.length)
+ _vm._s(_vm.transactions.length)
)
])
: _vm._e(),
_vm._v(" "),
- _vm.transactions.transactions.length === 1
+ _vm.transactions.length === 1
? _c("span", [_vm._v("Transaction information")])
: _vm._e()
- ])
+ ]),
+ _vm._v(" "),
+ _vm.transactions.length > 1
+ ? _c(
+ "div",
+ {
+ staticClass: "box-tools pull-right",
+ attrs: { x: "" }
+ },
+ [
+ _c(
+ "button",
+ {
+ staticClass: "btn btn-xs btn-danger",
+ on: {
+ click: function($event) {
+ return _vm.deleteTransaction(index, $event)
+ }
+ }
+ },
+ [_c("i", { staticClass: "fa fa-trash" })]
+ )
+ ]
+ )
+ : _vm._e()
]),
_vm._v(" "),
_c("div", { staticClass: "box-body" }, [
@@ -54562,6 +54603,14 @@ var render = function() {
_c("div", { staticClass: "form-group" }, [
_c("div", { staticClass: "col-sm-12" }, [
_c("input", {
+ directives: [
+ {
+ name: "model",
+ rawName: "v-model",
+ value: transaction.description,
+ expression: "transaction.description"
+ }
+ ],
staticClass: "form-control",
attrs: {
type: "text",
@@ -54570,7 +54619,19 @@ var render = function() {
autocomplete: "off",
placeholder: "Description"
},
- domProps: { value: transaction.description }
+ domProps: { value: transaction.description },
+ on: {
+ input: function($event) {
+ if ($event.target.composing) {
+ return
+ }
+ _vm.$set(
+ transaction,
+ "description",
+ $event.target.value
+ )
+ }
+ }
})
])
]),
@@ -54578,6 +54639,14 @@ var render = function() {
_c("div", { staticClass: "form-group" }, [
_c("div", { staticClass: "col-sm-12" }, [
_c("input", {
+ directives: [
+ {
+ name: "model",
+ rawName: "v-model",
+ value: transaction.date,
+ expression: "transaction.date"
+ }
+ ],
staticClass: "form-control",
attrs: {
type: "date",
@@ -54588,7 +54657,19 @@ var render = function() {
disabled: index > 0,
placeholder: "Date"
},
- domProps: { value: transaction.date }
+ domProps: { value: transaction.date },
+ on: {
+ input: function($event) {
+ if ($event.target.composing) {
+ return
+ }
+ _vm.$set(
+ transaction,
+ "date",
+ $event.target.value
+ )
+ }
+ }
})
])
]),
@@ -54688,7 +54769,9 @@ var render = function() {
on: { click: _vm.addTransaction }
},
[_vm._v("Add another split")]
- )
+ ),
+ _vm._v(" "),
+ _c("button", { staticClass: "btn btn-success" }, [_vm._v("Submit")])
])
])
])
diff --git a/readme.md b/readme.md
index c27c33778e..49714ef23d 100644
--- a/readme.md
+++ b/readme.md
@@ -136,12 +136,12 @@ This work [is licensed](https://github.com/firefly-iii/firefly-iii/blob/master/L
### Donate
If you like Firefly III and if it helps you save lots of money, why not send me a dime for every dollar saved!
-OK that was a joke. You could donate using [PayPal](https://docs.firefly-iii.org/en/latest/contact/note-donations.html). Please find the button on the page.
+OK that was a joke. You can donate using [PayPal](https://docs.firefly-iii.org/en/latest/contact/note-donations.html) or [Patreon](https://www.patreon.com/jc5).
Thank you for considering donating to Firefly III!
### Alternatives
-If you are looking for alternatives, check out [Kickball's Awesome-Selfhosted list](https://github.com/Kickball/awesome-selfhosted) which features not only Firefly III but also noteworthy alternatives such as [Silverstrike](https://github.com/agstrike/silverstrike).
+If you are looking for alternatives, check out [Kickball's Awesome-Selfhosted list](https://github.com/Kickball/awesome-selfhosted) which features not only Firefly III but also many other noteworthy alternatives.
### Badges
I like badges!
diff --git a/resources/assets/js/components/transactions/CreateTransaction.vue b/resources/assets/js/components/transactions/CreateTransaction.vue
index add716c090..ea65abcee5 100644
--- a/resources/assets/js/components/transactions/CreateTransaction.vue
+++ b/resources/assets/js/components/transactions/CreateTransaction.vue
@@ -19,10 +19,10 @@
-->
<template>
- <form method="POST" action="xxxx" accept-charset="UTF-8" class="form-horizontal" id="store" enctype="multipart/form-data">
+ <form method="POST" action="transactions/store" accept-charset="UTF-8" class="form-horizontal" id="store" enctype="multipart/form-data">
<input name="_token" type="hidden" value="xxx">
- <div class="row" v-if="transactions.transactions.length > 1">
+ <div class="row" v-if="transactions.length > 1">
<div class="col-lg-6">
<div class="box">
<div class="box-header with-border">
@@ -34,7 +34,7 @@
<div class="form-group">
<div class="col-sm-12">
<input type="text" class="form-control" name="group_title"
- v-model="transactions.group_title"
+ v-model="group_title"
title="Description of the split transaction" autocomplete="off" placeholder="Description of the split transaction">
@@ -48,15 +48,18 @@
</div>
</div>
- <div v-for="(transaction, index) in transactions.transactions">
+ <div v-for="(transaction, index) in transactions">
<div class="row">
<div class="col-lg-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title splitTitle">
- <span v-if="transactions.transactions.length > 1">Split {{ index+1 }} / {{ transactions.transactions.length }}</span>
- <span v-if="transactions.transactions.length === 1">Transaction information</span>
+ <span v-if="transactions.length > 1">Split {{ index+1 }} / {{ transactions.length }}</span>
+ <span v-if="transactions.length === 1">Transaction information</span>
</h3>
+ <div class="box-tools pull-right" v-if="transactions.length > 1" x>
+ <button v-on:click="deleteTransaction(index, $event)" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></button>
+ </div>
</div>
<div class="box-body">
<div class="row">
@@ -84,7 +87,7 @@
<div class="form-group">
<div class="col-sm-12">
<input type="text" class="form-control" name="description[]"
- :value="transaction.description"
+ v-model="transaction.description"
title="Description" autocomplete="off" placeholder="Description">
</div>
</div>
@@ -92,7 +95,7 @@
<div class="col-sm-12">
<input type="date" class="form-control" name="date[]"
title="Date" value="" autocomplete="off"
- :value="transaction.date"
+ v-model="transaction.date"
:disabled="index > 0"
placeholder="Date">
</div>
@@ -141,6 +144,7 @@
<div class="col-lg-12">
<p>
<button class="btn btn-primary" v-on:click="addTransaction">Add another split</button>
+ <button class="btn btn-success">Submit</button>
</p>
</div>
</div>
@@ -150,99 +154,151 @@
<script>
export default {
name: "CreateTransaction",
- components: {
-
- },
+ components: {},
mounted() {
- // not sure if something needs to happen here.
+ this.addTransaction();
},
ready() {
+
},
methods: {
addTransaction: function (e) {
- let latest = this.transactions.transactions[this.transactions.transactions.length - 1];
- this.transactions.transactions.push(latest);
- e.preventDefault();
+ this.transactions.push({
+ description: "",
+ date: "",
+ amount: "",
+ foreign_amount: "",
+ source_account: {
+ id: 0,
+ name: "",
+ type: "",
+ //currency_id: window.defaultCurrency.id,
+ //currency_name: window.defaultCurrency.name,
+ //currency_code: window.defaultCurrency.code,
+ //currency_decimal_places: window.defaultCurrency.decimal_places,
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: []
+ },
+ destination_account: {
+ id: 0,
+ name: "",
+ type: "",
+ //currency_id: window.defaultCurrency.id,
+ //currency_name: window.defaultCurrency.name,
+ //currency_code: window.defaultCurrency.code,
+ //currency_decimal_places: window.defaultCurrency.decimal_places,
+ currency_id: 0,
+ currency_name: '',
+ currency_code: '',
+ currency_decimal_places: 2,
+ allowed_types: []
+ }
+ });
+ if (e) {
+ e.preventDefault();
+ }
},
setTransactionType: function (type) {
this.transactionType = type;
},
+ deleteTransaction: function (index, event) {
+ event.preventDefault();
+ for (const key in this.transactions) {
+ if (
+ this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
+ console.log('Transactions[' + key + '] exists: ' + this.transactions[key].description);
+ }
+ }
+
+ this.transactions.splice(index, 1);
+ console.log('Going to remove index ' + index);
+
+ for (const key in this.transactions) {
+ if (
+ this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
+ console.log('New: Transactions[' + key + '] exists: ' + this.transactions[key].description);
+ }
+ }
+ },
limitSourceType: function (type) {
let i;
- for (i = 0; i < this.transactions.transactions.length; i++) {
- this.transactions.transactions[i].source_account.allowed_types = [type];
+ for (i = 0; i < this.transactions.length; i++) {
+ this.transactions[i].source_account.allowed_types = [type];
}
},
limitDestinationType: function (type) {
let i;
- for (i = 0; i < this.transactions.transactions.length; i++) {
- this.transactions.transactions[i].destination_account.allowed_types = [type];
+ for (i = 0; i < this.transactions.length; i++) {
+ this.transactions[i].destination_account.allowed_types = [type];
}
},
selectedSourceAccount: function (index, model) {
if (typeof model === 'string') {
// cant change types, only name.
- this.transactions.transactions[index].source_account.name = model;
+ this.transactions[index].source_account.name = model;
} else {
// todo maybe replace the entire model?
- this.transactions.transactions[index].source_account.id = model.id;
- this.transactions.transactions[index].source_account.name = model.name;
- this.transactions.transactions[index].source_account.type = model.type;
+ this.transactions[index].source_account.id = model.id;
+ this.transactions[index].source_account.name = model.name;
+ this.transactions[index].source_account.type = model.type;
- this.transactions.transactions[index].source_account.currency_id = model.currency_id;
- this.transactions.transactions[index].source_account.currency_name = model.currency_name;
- this.transactions.transactions[index].source_account.currency_code = model.currency_code;
- this.transactions.transactions[index].source_account.currency_decimal_places = model.currency_decimal_places;
+ this.transactions[index].source_account.currency_id = model.currency_id;
+ this.transactions[index].source_account.currency_name = model.currency_name;
+ this.transactions[index].source_account.currency_code = model.currency_code;
+ this.transactions[index].source_account.currency_decimal_places = model.currency_decimal_places;
// force types on destination selector.
- this.transactions.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type];
+ this.transactions[index].destination_account.allowed_types = window.allowedOpposingTypes.source[model.type];
}
},
selectedDestinationAccount: function (index, model) {
if (typeof model === 'string') {
// cant change types, only name.
- this.transactions.transactions[index].destination_account.name = model;
+ this.transactions[index].destination_account.name = model;
} else {
// todo maybe replace the entire model?
- this.transactions.transactions[index].destination_account.id = model.id;
- this.transactions.transactions[index].destination_account.name = model.name;
- this.transactions.transactions[index].destination_account.type = model.type;
+ this.transactions[index].destination_account.id = model.id;
+ this.transactions[index].destination_account.name = model.name;
+ this.transactions[index].destination_account.type = model.type;
- this.transactions.transactions[index].destination_account.currency_id = model.currency_id;
- this.transactions.transactions[index].destination_account.currency_name = model.currency_name;
- this.transactions.transactions[index].destination_account.currency_code = model.currency_code;
- this.transactions.transactions[index].destination_account.currency_decimal_places = model.currency_decimal_places;
+ this.transactions[index].destination_account.currency_id = model.currency_id;
+ this.transactions[index].destination_account.currency_name = model.currency_name;
+ this.transactions[index].destination_account.currency_code = model.currency_code;
+ this.transactions[index].destination_account.currency_decimal_places = model.currency_decimal_places;
// force types on destination selector.
- this.transactions.transactions[index].source_account.allowed_types = window.allowedOpposingTypes.destination[model.type];
+ this.transactions[index].source_account.allowed_types = window.allowedOpposingTypes.destination[model.type];
}
},
clearSource: function (index) {
- this.transactions.transactions[index].source_account.id = 0;
- this.transactions.transactions[index].source_account.name = "";
- this.transactions.transactions[index].source_account.type = "";
- this.transactions.transactions[index].destination_account.allowed_types = [];
+ this.transactions[index].source_account.id = 0;
+ this.transactions[index].source_account.name = "";
+ this.transactions[index].source_account.type = "";
+ this.transactions[index].destination_account.allowed_types = [];
// if there is a destination model, reset the types of the source
// by pretending we selected it again.
- if (this.transactions.transactions[index].destination_account) {
+ if (this.transactions[index].destination_account) {
console.log('There is a destination account.');
- this.selectedDestinationAccount(index, this.transactions.transactions[index].destination_account);
+ this.selectedDestinationAccount(index, this.transactions[index].destination_account);
}
},
clearDestination: function (index) {
- this.transactions.transactions[index].destination_account.id = 0;
- this.transactions.transactions[index].destination_account.name = "";
- this.transactions.transactions[index].destination_account.type = "";
- this.transactions.transactions[index].source_account.allowed_types = [];
+ this.transactions[index].destination_account.id = 0;
+ this.transactions[index].destination_account.name = "";
+ this.transactions[index].destination_account.type = "";
+ this.transactions[index].source_account.allowed_types = [];
// if there is a source model, reset the types of the destination
// by pretending we selected it again.
- if (this.transactions.transactions[index].source_account) {
+ if (this.transactions[index].source_account) {
console.log('There is a source account.');
- this.selectedSourceAccount(index, this.transactions.transactions[index].source_account);
+ this.selectedSourceAccount(index, this.transactions[index].source_account);
}
}
},
@@ -253,45 +309,8 @@
data() {
return {
transactionType: null,
- transactions: {
- group_title: "",
- transactions: [
- {
- description: "",
- date: "",
- amount: "",
- foreign_amount: "",
- source_account: {
- id: 0,
- name: "",
- type: "",
- //currency_id: window.defaultCurrency.id,
- //currency_name: window.defaultCurrency.name,
- //currency_code: window.defaultCurrency.code,
- //currency_decimal_places: window.defaultCurrency.decimal_places,
- currency_id: 0,
- currency_name: '',
- currency_code: '',
- currency_decimal_places: 2,
- allowed_types: []
- },
- destination_account: {
- id: 0,
- name: "",
- type: "",
- //currency_id: window.defaultCurrency.id,
- //currency_name: window.defaultCurrency.name,
- //currency_code: window.defaultCurrency.code,
- //currency_decimal_places: window.defaultCurrency.decimal_places,
- currency_id: 0,
- currency_name: '',
- currency_code: '',
- currency_decimal_places: 2,
- allowed_types: []
- }
- }
- ]
- }
+ group_title: "",
+ transactions: []
};
},
}
diff --git a/resources/assets/js/components/transactions/CustomTransactionFields.vue b/resources/assets/js/components/transactions/CustomTransactionFields.vue
index 63c7c63190..1328e7b13d 100644
--- a/resources/assets/js/components/transactions/CustomTransactionFields.vue
+++ b/resources/assets/js/components/transactions/CustomTransactionFields.vue
@@ -34,7 +34,8 @@
const url = document.getElementsByTagName('base')[0].href + 'api/v1/preferences/transaction_journal_optional_fields';
axios.get(url).then(response => {
- console.log(response.data.data.attributes);
+ // TODO here we are.
+ //console.log(response.data.data.attributes);
}).catch(() => console.warn('Oh. Something went wrong'));
},
}
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index 5af414b621..2e8d60cbfc 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -54,6 +54,7 @@ return [
'create_new_stuff' => 'Create new stuff',
'new_withdrawal' => 'New withdrawal',
'create_new_transaction' => 'Create new transaction',
+ 'new_transaction' => 'New transaction',
'go_to_asset_accounts' => 'View your asset accounts',
'go_to_budgets' => 'Go to your budgets',
'go_to_categories' => 'Go to your categories',
diff --git a/resources/views/v1/index.twig b/resources/views/v1/index.twig
index 171535298e..59183fb423 100644
--- a/resources/views/v1/index.twig
+++ b/resources/views/v1/index.twig
@@ -56,20 +56,6 @@
<div class="box">
<div class="box-header with-border">
<h3 class="box-title"><a href="{{ route('accounts.show', data[1].id) }}">{{ data[1].name }}</a></h3>
-
- <div class="box-tools pull-right">
- <div class="btn-group">
- <button class="btn btn-box-tool dropdown-toggle" data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i></button>
- <ul class="dropdown-menu" role="menu">
- <li><a href="{{ route('transactions.create','withdrawal') }}?source={{ data[1].id }}"><i
- class="fa fa-long-arrow-left fa-fw"></i> {{ 'newWithdrawal'|_ }}</a></li>
- <li><a href="{{ route('transactions.create','deposit') }}?source={{ data[1].id }}"><i
- class="fa fa-long-arrow-right fa-fw"></i> {{ 'newDeposit'|_ }}</a></li>
- <li><a href="{{ route('transactions.create','transfer') }}?source={{ data[1].id }}"><i
- class="fa fa-fw fa-exchange"></i> {{ 'newTransfer'|_ }}</a></li>
- </ul>
- </div>
- </div>
</div>
{% if data[0].count > 0 %}
@@ -95,22 +81,8 @@
<div class="btn-group" role="group" aria-label="...">
<div class="btn-group" role="group">
- <a href="{{ route('transactions.create','withdrawal') }}?source={{ data[1].id }}" class="btn btn-success"><i
+ <a href="{{ route('transactions.create') }}" class="btn btn-success"><i
class="fa fa-plus fa-fw"></i> {{ 'create_new_transaction'|_ }}</a>
- <button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
- aria-expanded="false">
- <span class="caret"></span>
- <span class="sr-only">Toggle Dropdown</span>
- </button>
- <ul class="dropdown-menu">
- <li><a href="{{ route('transactions.create','withdrawal') }}?source={{ data[1].id }}"><i
- class="fa fa-long-arrow-left fa-fw"></i> {{ 'newWithdrawal'|_ }}</a></li>
- <li><a href="{{ route('transactions.create','deposit') }}?source={{ data[1].id }}"><i
- class="fa fa-long-arrow-right fa-fw"></i> {{ 'newDeposit'|_ }}</a></li>
- <li><a href="{{ route('transactions.create','transfer') }}?source={{ data[1].id }}"><i
- class="fa fa-fw fa-exchange"></i> {{ 'newTransfer'|_ }}
- </a></li>
- </ul>
</div>
<a class="btn btn-default"
href="{{ route('accounts.show',data[1].id) }}">{{ formatAmountByAccount(data[1], data[1]|balance, false) }}</a>
diff --git a/resources/views/v1/partials/control-bar.twig b/resources/views/v1/partials/control-bar.twig
index 40d25cbbe4..da883cb39e 100644
--- a/resources/views/v1/partials/control-bar.twig
+++ b/resources/views/v1/partials/control-bar.twig
@@ -4,29 +4,11 @@
<h3 class="control-sidebar-heading">{{ 'create_new_stuff'|_ }}</h3>
<ul class='control-sidebar-menu'>
<li>
- <a href="{{ route('transactions.create', 'withdrawal') }}">
+ <a href="{{ route('transactions.create') }}">
<i class="menu-icon fa fa-long-arrow-left bg-red"></i>
<div class="menu-info">
- <h4 class="control-sidebar-subheading">{{ 'new_withdrawal'|_ }}</h4>
- </div>
- </a>
- </li>
- <li>
- <a href="{{ route('transactions.create', 'deposit') }}">
- <i class="menu-icon fa fa-long-arrow-right bg-green"></i>
-
- <div class="menu-info">
- <h4 class="control-sidebar-subheading">{{ 'new_deposit'|_ }}</h4>
- </div>
- </a>
- </li>
- <li>
- <a href="{{ route('transactions.create', 'transfer') }}">
- <i class="menu-icon fa fa-exchange bg-blue"></i>
-
- <div class="menu-info">
- <h4 class="control-sidebar-subheading">{{ 'new_transfer'|_ }}</h4>
+ <h4 class="control-sidebar-subheading">{{ 'new_transaction'|_ }}</h4>
</div>
</a>
</li>
diff --git a/resources/views/v1/transactions/index.twig b/resources/views/v1/transactions/index.twig
index dcfe5fcf69..0171415ff9 100644
--- a/resources/views/v1/transactions/index.twig
+++ b/resources/views/v1/transactions/index.twig
@@ -24,11 +24,7 @@
</div>
<div class="box-body no-padding">
<div style="padding:8px;">
- {% if transactionType == 'transfers' %}
- <a href="{{ route('transactions.create', 'transfer') }}" class="btn btn-success"><i class="fa fa-plus fa-fw"></i> {{ ('new_' ~ transactionType)|_ }}</a>
- {% else %}
- <a href="{{ route('transactions.create', transactionType) }}" class="btn btn-success"><i class="fa fa-plus fa-fw"></i> {{ ('new_' ~ transactionType)|_ }}</a>
- {% endif %}
+ <a href="{{ route('transactions.create') }}" class="btn btn-success"><i class="fa fa-plus fa-fw"></i> {{ 'create_new_transaction'|_ }}</a>
</div>
{# actual list #}
{% include 'list.groups' %}
diff --git a/routes/web.php b/routes/web.php
index d85d07f74d..5995a3977b 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -885,13 +885,15 @@ Route::group(
);
// create group:
- Route::get('create/{objectType}', ['uses' => 'Transaction\CreateController@create', 'as' => 'create'])->where(['objectType' => 'withdrawal|deposit|transfer']);
+ Route::get('create', ['uses' => 'Transaction\CreateController@create', 'as' => 'create']);
+ Route::post('store', ['uses' => 'Transaction\CreateController@store', 'as' => 'store']);
+
+
// TODO improve these routes
Route::get('{what}/all', ['uses' => 'TransactionController@indexAll', 'as' => 'index.all'])->where(['what' => 'withdrawal|deposit|transfers|transfer']);
-
Route::get('debug/{tj}', ['uses' => 'Transaction\SingleController@debugShow', 'as' => 'debug']);
Route::get('debug/{tj}', ['uses' => 'Transaction\SingleController@debugShow', 'as' => 'debug']);
@@ -914,7 +916,7 @@ Route::group(
Route::get('edit/{tj}', ['uses' => 'SingleController@edit', 'as' => 'edit']);
Route::get('delete/{tj}', ['uses' => 'SingleController@delete', 'as' => 'delete']);
- Route::post('store', ['uses' => 'SingleController@store', 'as' => 'store'])->where(['what' => 'withdrawal|deposit|transfer']);
+ //Route::post('store', ['uses' => 'SingleController@store', 'as' => 'store'])->where(['what' => 'withdrawal|deposit|transfer']);
Route::post('update/{tj}', ['uses' => 'SingleController@update', 'as' => 'update']);
Route::post('destroy/{tj}', ['uses' => 'SingleController@destroy', 'as' => 'destroy']);
Route::get('clone/{tj}', ['uses' => 'SingleController@cloneTransaction', 'as' => 'clone']);