|
@@ -37,7 +37,7 @@ impl<'a> Sqlite<'a> {
|
|
|
"transaction_id" VARCHAR(66) NOT NULL,
|
|
|
"position_id" INTEGER NOT NULL,
|
|
|
"asset_id" TEXT NOT NULL,
|
|
|
- "cents" TEXT NOT NULL,
|
|
|
+ "cents" BIG INTEGER NOT NULL,
|
|
|
"status" INTEGER NOT NULL,
|
|
|
"to" VARCHAR(71) NOT NULL,
|
|
|
"spent_by" TEXT,
|
|
@@ -97,10 +97,9 @@ impl<'a> Sqlite<'a> {
|
|
|
};
|
|
|
|
|
|
let cents = row
|
|
|
- .try_get::<String, usize>(3)
|
|
|
+ .try_get::<i64, usize>(3)
|
|
|
.map_err(|_| Error::Storage("Invalid cents".to_string()))?
|
|
|
- .parse::<i128>()
|
|
|
- .map_err(|_| Error::Storage("Invalid cents".to_string()))?;
|
|
|
+ .into();
|
|
|
|
|
|
Ok(Payment {
|
|
|
id,
|
|
@@ -191,11 +190,12 @@ impl<'a> Storage<'a, Batch<'a>> for Sqlite<'a> {
|
|
|
r#"
|
|
|
SELECT
|
|
|
"asset_id",
|
|
|
- "cents"
|
|
|
+ SUM("cents") as "cents"
|
|
|
FROM
|
|
|
"payments"
|
|
|
WHERE
|
|
|
"to" = ? AND "spent_by" IS NULL AND status = ?
|
|
|
+ GROUP BY "asset_id"
|
|
|
"#,
|
|
|
)
|
|
|
.bind(account.to_string())
|
|
@@ -220,10 +220,9 @@ impl<'a> Storage<'a, Batch<'a>> for Sqlite<'a> {
|
|
|
.map_err(|e| Error::Storage(e.to_string()))?;
|
|
|
|
|
|
let cents = row
|
|
|
- .try_get::<String, usize>(1)
|
|
|
+ .try_get::<i64, usize>(1)
|
|
|
.map_err(|_| Error::Storage("Invalid cents".to_string()))?
|
|
|
- .parse::<i128>()
|
|
|
- .map_err(|_| Error::Storage("Invalid cents".to_string()))?;
|
|
|
+ .into();
|
|
|
|
|
|
let new_amount = asset.new_amount(cents);
|
|
|
|