mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-06 22:21:42 +00:00
Lots of new code and first submission thing.
This commit is contained in:
@@ -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: []
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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'));
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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' %}
|
||||
|
||||
Reference in New Issue
Block a user