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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
<template lang="pug">
div
h1 Payments Received
div(style='margin-bottom: 15px')
input#user(type='hidden', value='')
|
input#from_date(type='text', style='position: relative; top: 25px; height: 0px; width:0px; border: 0px;')
|
button#from.btn.btn-primary
| to
input#to_date(type='text', style='position: relative; top: 25px; height: 0px; width:0px; border: 0px;')
|
button#to.btn.btn-primary(name='to')
p.alert.alert-warning(style='display: none') No transactions were found for the specified time period
table.table.table-striped.table-hover.report(style='cursor: pointer; display: none')
thead
tr
th Time
th Rate
th BTC
th {{currency}}
tbody
tfoot
tr
td.total(colspan='2') Subtotal:
td#btc
td#fiat
tr
td.total(colspan='2') Tips:
td#btc_tips
td#fiat_tips
tr
td.total(colspan='2') Total:
td#btc_total
td#fiat_total
#modal.modal.fade(tabindex='-1', role='dialog')
.modal-dialog
.modal-content
.modal-header
button.close(type='button', data-dismiss='modal')
span(aria-hidden='true') ×
span.sr-only Close
h4.modal-title Transaction
.modal-body
textarea(style='width: 100%; height: 100px;', placeholder='Notes')
p#yousure You sure?
.modal-footer
#buttons
button.btn.btn-danger(type='button', tabindex='-1') Delete Transaction
|
button.btn.btn-primary(type='button') View Blockchain
|
button.btn.btn-default(type='button', data-dismiss='modal') Done
#confirm
button.btn.btn-default(type='button', data-dismiss='modal') No
|
button.btn.btn-danger(type='button') Yes
</template>
<script>
export default {
name: 'Sales'
}
/*
(function() {
var display, filterDates, g;
g = typeof exports !== "undefined" && exports !== null ? exports : this;
$(function() {
var from, to;
from = moment().subtract(7, 'days');
to = moment();
$('#from').html(from.format("MMMM Do, YYYY"));
$('#to').html(to.format("MMMM Do, YYYY"));
$('#from_date').val(from.format("MM/DD/YYYY"));
$('#to_date').val(to.format("MM/DD/YYYY"));
$('#from_date').datepicker({
onClose: filterDates
});
$('#to_date').datepicker({
onClose: filterDates
});
$('#from').click(function() {
return $('#from_date').datepicker('show').blur();
});
$('#to').click(function() {
return $('#to_date').datepicker('show').blur();
});
return $.getJSON('transactions.json', function(data) {
g.transactions = data.transactions.filter(function(t) {
return t.user === $('#user').val();
});
display(g.transactions);
return filterDates();
});
});
filterDates = function() {
var transactions;
$('#from').html(moment($('#from_date').datepicker('getDate')).format("MMMM Do, YYYY"));
$('#to').html(moment($('#to_date').datepicker('getDate')).format("MMMM Do, YYYY"));
transactions = $.grep(g.transactions, function(e, i) {
var amount, d, from, to;
if (!e) {
return false;
}
from = moment($('#from_date').val(), "MM/DD/YYYY");
to = moment($('#to_date').val(), "MM/DD/YYYY");
d = moment(e.date);
amount = parseFloat(e.exchange) * parseFloat(e.received);
return !isNaN(parseFloat(amount)) && isFinite(amount) && ((from == null) || d.diff(from, 'days') >= 0) && ((to == null) || d.diff(to, 'days') <= 0);
});
return display(transactions);
};
display = function(transactions) {
var btc_tips_total, btc_total, fiat_tips_total, fiat_total;
$('.report tbody tr').remove();
if (transactions.length === 0) {
$('.report').hide();
return $('.alert').fadeIn();
} else {
$('.alert').hide();
btc_total = btc_tips_total = 0;
fiat_total = fiat_tips_total = 0;
$.each(transactions, function() {
var btc, btc_tip, btc_tip_str, date, exchange, fiat, fiat_tip, fiat_tip_str, notes, row, tip, txid;
btc_tip_str = "";
fiat_tip_str = "";
exchange = parseFloat(this.exchange);
tip = this.tip;
btc = parseFloat(this.received);
fiat = btc * exchange;
btc_total += parseFloat(btc.toFixed(8));
fiat_total += parseFloat(fiat.toFixed(2));
if (tip > 1) {
btc = btc / tip;
btc_tip = (btc * tip - btc).toFixed(8);
fiat_tip = (btc_tip * exchange).toFixed(2);
btc_tips_total += parseFloat(btc_tip);
fiat_tips_total += parseFloat(fiat_tip);
btc_tip_str = "<br /><small>+ " + btc_tip + "</small>";
fiat_tip_str = "<br /><small>+ " + fiat_tip + "</small>";
}
fiat = btc * exchange;
notes = this.notes;
txid = this.txid;
date = moment(this.date, 'YYYY-MM-DD h:mm:ss').format('MMM D h:mma');
row = $("<tr id='" + this.txid + "'>\n <td>" + date + " <span class='glyphicon glyphicon-tag hidden'></span></td>\n <td>" + (exchange.toFixed(2)) + "</td>\n <td>" + (btc.toFixed(8)) + btc_tip_str + "</td>\n <td>" + (fiat.toFixed(2)) + fiat_tip_str + "</td>\n</tr>");
if (notes) {
row.attr('data-notes', notes);
row.find('span').removeClass('hidden');
}
$('.report tbody').append(row);
return row.click(function() {
$('#confirm, #yousure').hide();
$('#buttons, #modal textarea').show();
notes = $(this).attr('data-notes');
$('#modal').modal();
$('#modal textarea').val('');
$('#modal .btn-primary').toggle((txid != null) && txid.length > 5);
$('#modal .btn-danger').off().click(function() {
$('#yousure, #confirm').show();
return $('#buttons, #modal textarea').hide();
});
$('#confirm .btn-danger').click(function() {
$.ajax({
type: 'delete',
url: "/" + ($('#user').val()) + "/transactions/" + txid
});
$('#modal').modal('hide');
return row.fadeOut('slow');
});
$('#modal .btn-primary').off().click(function() {
window.open("https://blockchain.info/tx/" + txid, '_blank');
return $('#modal').modal('hide');
});
$('#modal textarea').off().change(function() {
notes = $(this).val();
if (txid) {
$.post("/transactions/" + txid, {
notes: $(this).val()
});
}
row.find('span').addClass('hidden');
if (notes) {
row.find('span').removeClass('hidden');
}
return row.attr('data-notes', $(this).val());
});
if (notes) {
return $('#modal textarea').val(notes);
}
});
});
$('#btc_total').html("" + (parseFloat(btc_total).toFixed(8)));
$('#fiat_total').html("" + (parseFloat(fiat_total).toFixed(2)));
$('#btc_tips').html("" + (parseFloat(btc_tips_total).toFixed(8)));
$('#fiat_tips').html("" + (parseFloat(fiat_tips_total).toFixed(2)));
$('#btc').html("" + (parseFloat(btc_total - btc_tips_total).toFixed(8)));
$('#fiat').html("" + (parseFloat(fiat_total - fiat_tips_total).toFixed(2)));
return $('.report').fadeIn();
}
};
}).call(this);
*/
</script>
|