aboutsummaryrefslogtreecommitdiff
path: root/src/index.html
blob: ef868354bf24aabac729ae64faad019ebfcdc4fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!doctype html>
<html lang="en">

<head>
    <title>Budget</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="shortcut icon" href="/favicon.ico">
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue"></script> -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="main.js"></script>
    <link rel="stylesheet" type="text/css" href="styles.css">
</head>

<body>
    <div id="data">
        <h1 v-if="summary.username">{{summary.username}}'s budget</h1>
        <div>
            <button v-bind:class="{ bold: activeTab == 0 }" v-on:click="setTab(0)">Ledger</button>
            <button v-bind:class="{ bold: activeTab == 1 }" v-on:click="setTab(1)">Summary</button>
        </div>

        <!-- Ledger -->
        <div v-if="activeTab == 0">
            <div class="newItem">
                <input v-model="m.when" placeholder="Date" type="date">
                <input v-model="m.where" placeholder="Where">
                <input v-model="m.amount" placeholder="Amount" type="number" step="0.01">
                <input v-model="m.category" placeholder="Category">
                <input v-model="m.subcategory" placeholder="Subcategory">
                <button v-on:click="post(m, '/transaction')">Add</button>
            </div>
            <table class="table">
                <tr class="table-header">
                    <th class="table-index"></th>
                    <th>Date</th>
                    <th>Where</th>
                    <th>Amount</th>
                    <th>Category</th>
                    <th>Subcategory</th>
                    <th></th>
                </tr>
                <tr v-for="(transaction, i) in transactions">
                    <td class="table-index">{{i+1}}</td>
                    <td>{{transaction.when.substring(0,10)}}</td>
                    <td>{{transaction.where}}</td>
                    <td>{{transaction.amount}}</td>
                    <td>{{transaction.category}}</td>
                    <td>{{transaction.subcategory}}</td>
                    <td>
                        <button v-on:click="prepareEntryEdit(transaction)">&#9881;</button>
                        <button v-on:click="remove(transaction)">X</button>
                    </td>
                </tr>

            </table>
        </div>

        <table v-if="activeTab == 10">
            <tr>
                <th></th>
                <th>Date</th>
                <th>Where</th>
                <th>Amount</th>
                <th>Category</th>
                <th>Subcategory</th>

            </tr>
            <tr>
                <td></td>
                <td>
                    <input v-model="em.when" placeholder="Date" type="date">
                </td>
                <td>
                    <input v-model="em.where" placeholder="Where">
                </td>
                <td>
                    <input v-model="em.amount" placeholder="Amount" type="number" step="0.01">
                </td>
                <td>
                    <input v-model="em.category" placeholder="Category">
                </td>
                <td>
                    <input v-model="em.subcategory" placeholder="Subcategory">
                </td>
                <td><button v-on:click="updateMany(em);activeTab=0;">Update</button></td>
            </tr>
        </table>

        <!-- Summary -->
        <div v-if="activeTab == 1">
            <div class="summary-panel">
                <h2>Weekly</h2>
                <table class="table">
                    <tr>
                        <th>Year</th>
                        <th>Week</th>
                        <th>In</th>
                        <th>Out</th>
                        <th>Net</th>
                    </tr>
                    <tr v-for="(data, i) in summary.week">
                        <td>{{data.y}}</td>
                        <td>{{data.w}}</td>
                        <td>{{data.in}}</td>
                        <td>{{data.out}}</td>
                        <td v-bind:class="{'net-negative': data.negative, 'net-positive':data.positive}">{{data.net}}
                        </td>
                    </tr>
                </table>
            </div>
            <div class="summary-panel">
                <h2>Monthly</h2>
                <table class="table">
                    <tr>
                        <th>Year</th>
                        <th>Month</th>
                        <th>In</th>
                        <th>Out</th>
                        <th>Net</th>
                    </tr>
                    <tr v-for="(data, i) in summary.month">
                        <td>{{data.y}}</td>
                        <td>{{data.m}}</td>
                        <td>{{data.in}}</td>
                        <td>{{data.out}}</td>
                        <td v-bind:class="{'net-negative': data.negative, 'net-positive':data.positive}">{{data.net}}
                        </td v-bind:class="{'net-negative': data.negative, 'net-positive':data.positive}">
                    </tr>
                </table>
            </div>
            <div class="summary-panel">
                <h2>Yearly</h2>
                <table class="table">
                    <tr>
                        <th>Year</th>
                        <th>In</th>
                        <th>Out</th>
                        <th>Net</th>
                    </tr>
                    <tr v-for="(data, i) in summary.year">
                        <td>{{data.y}}</td>
                        <td>{{data.in}}</td>
                        <td>{{data.out}}</td>
                        <td v-bind:class="{'net-negative': data.negative, 'net-positive':data.positive}">{{data.net}}
                        </td v-bind:class="{'net-negative': data.negative, 'net-positive':data.positive}">
                    </tr>
                </table>
            </div>
        </div>
    </div>
</body>

</html>