Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Hugo Hörnquist
Stupan
Commits
01a523df
Commit
01a523df
authored
Apr 13, 2018
by
Hugo Hörnquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Readded money transfer functionality
parent
f5b36244
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
32 deletions
+34
-32
admin/mainwindow.cpp
admin/mainwindow.cpp
+29
-32
admin/mainwindow.h
admin/mainwindow.h
+2
-0
admin/mainwindow.ui
admin/mainwindow.ui
+3
-0
No files found.
admin/mainwindow.cpp
View file @
01a523df
...
@@ -509,38 +509,6 @@ void MainWindow::on_buyRemoveButton_clicked()
...
@@ -509,38 +509,6 @@ void MainWindow::on_buyRemoveButton_clicked()
tempAcquisitionsModel
->
select
();
tempAcquisitionsModel
->
select
();
}
}
void
MainWindow
::
transferMoney
(
QString
from
,
QString
to
,
int
amount
,
QString
message
)
{
if
((
from
==
""
&&
to
==
""
)
||
amount
==
0
)
return
;
QSqlQuery
query
;
query
.
prepare
(
"INSERT INTO money_transfers (change, note, from_acc, to_acc) "
"VALUES (:amount, :message, "
"(SELECT CASE "
" WHEN count(1) != 0 THEN id "
" ELSE 0 END "
" FROM money WHERE name = :from), "
"(SELECT CASE "
" WHEN count(1) != 0 THEN id "
" ELSE 0 END "
" FROM money WHERE name = :to))"
);
query
.
bindValue
(
":amount"
,
amount
);
query
.
bindValue
(
":message"
,
message
);
query
.
bindValue
(
":from"
,
from
);
query
.
bindValue
(
":to"
,
to
);
if
(
!
query
.
exec
())
qDebug
()
<<
query
.
lastError
();
open_till
();
}
// invalid account names results in the outside world
void
MainWindow
::
transferMoney
(
QString
from
,
QString
to
,
int
amount
)
{
transferMoney
(
from
,
to
,
amount
,
NULL
);
}
void
MainWindow
::
on_addDrainageButton_clicked
()
void
MainWindow
::
on_addDrainageButton_clicked
()
{
{
// Products to go from crown to öre
// Products to go from crown to öre
...
@@ -864,3 +832,32 @@ void MainWindow::on_moneyDiffReload_clicked()
...
@@ -864,3 +832,32 @@ void MainWindow::on_moneyDiffReload_clicked()
ui
->
diffDrawer
->
setText
(
""
);
ui
->
diffDrawer
->
setText
(
""
);
setMoneyDiffLabels
();
setMoneyDiffLabels
();
}
}
void
MainWindow
::
on_accTransferSubmit_clicked
()
{
qlonglong
amount
=
ui
->
accTransferAmonut
->
value
()
*
100
;
qlonglong
from
=
ui
->
accTransferFrom
->
currentData
().
toLongLong
();
qlonglong
to
=
ui
->
accTransferTo
->
currentData
().
toLongLong
();
QString
text
=
ui
->
accTransferText
->
text
();
if
(
amount
==
0
||
from
==
to
)
return
;
qDebug
()
<<
amount
<<
from
<<
to
<<
text
;
QSqlQuery
query
;
query
.
prepare
(
"INSERT INTO money_transfers (change, from_acc, to_acc, note) "
"VALUES (:amount, :from, :to, :note)"
);
query
.
bindValue
(
":amount"
,
amount
);
query
.
bindValue
(
":from"
,
from
);
query
.
bindValue
(
":to"
,
to
);
query
.
bindValue
(
":note"
,
text
.
isEmpty
()
?
QVariant
::
String
:
QVariant
(
text
));
if
(
!
query
.
exec
())
qDebug
()
<<
query
.
lastError
();
ui
->
accTransferAmonut
->
setValue
(
0
);
ui
->
accTransferFrom
->
setCurrentIndex
(
0
);
ui
->
accTransferTo
->
setCurrentIndex
(
0
);
ui
->
accTransferText
->
setText
(
""
);
// TODO update money values
}
admin/mainwindow.h
View file @
01a523df
...
@@ -79,6 +79,8 @@ private slots:
...
@@ -79,6 +79,8 @@ private slots:
void
on_moneyDiffReload_clicked
();
void
on_moneyDiffReload_clicked
();
void
on_accTransferSubmit_clicked
();
private:
private:
Ui
::
MainWindow
*
ui
;
Ui
::
MainWindow
*
ui
;
QSqlTableModel
*
model
;
QSqlTableModel
*
model
;
...
...
admin/mainwindow.ui
View file @
01a523df
...
@@ -695,6 +695,9 @@
...
@@ -695,6 +695,9 @@
<layout
class=
"QGridLayout"
name=
"gridLayout_6"
>
<layout
class=
"QGridLayout"
name=
"gridLayout_6"
>
<item
row=
"1"
column=
"1"
>
<item
row=
"1"
column=
"1"
>
<widget
class=
"QDoubleSpinBox"
name=
"accTransferAmonut"
>
<widget
class=
"QDoubleSpinBox"
name=
"accTransferAmonut"
>
<property
name=
"suffix"
>
<string>
kr
</string>
</property>
<property
name=
"maximum"
>
<property
name=
"maximum"
>
<double>
99999999999999991433150857216.000000000000000
</double>
<double>
99999999999999991433150857216.000000000000000
</double>
</property>
</property>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment