aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Guyonvarch2026-04-18 11:29:15 +0200
committerJoris Guyonvarch2026-04-18 11:29:15 +0200
commit94520e13a7f1bf45e94b4f28ea37f3703763baf7 (patch)
tree4d16f440b266dddec449b9a072031c3f8e5ce9f7
parentf3c8651faaea7d1c2900442cdba9e8aec49e8f45 (diff)
Show date for balancings
-rw-r--r--src/db/balancing.rs19
-rw-r--r--src/model/balancing.rs1
-rw-r--r--templates/balancing/table.html2
3 files changed, 12 insertions, 10 deletions
diff --git a/src/db/balancing.rs b/src/db/balancing.rs
index 1641b97..8914eef 100644
--- a/src/db/balancing.rs
+++ b/src/db/balancing.rs
@@ -12,15 +12,6 @@ fn row_to_balancing(row: &Row) -> Result<Balancing, rusqlite::Error> {
})
}
-fn row_to_table_row(row: &Row) -> Result<TableRow, rusqlite::Error> {
- Ok(TableRow {
- id: row.get(0)?,
- source: row.get(1)?,
- destination: row.get(2)?,
- amount: row.get(3)?,
- })
-}
-
pub async fn count(conn: &Connection) -> i64 {
let query = r#"
SELECT COUNT(*)
@@ -49,6 +40,7 @@ pub async fn list_for_table(conn: &Connection, page: i64, per_page: i64) -> Vec<
let query = r#"
SELECT
balancing.id,
+ strftime('%d/%m/%Y', balancing.created_at),
users_src.name,
users_dest.name,
balancing.amount
@@ -67,7 +59,14 @@ pub async fn list_for_table(conn: &Connection, page: i64, per_page: i64) -> Vec<
stmt.query_map(
named_params![":limit": per_page, ":offset": (page - 1) * per_page],
- row_to_table_row
+ |row: &Row|
+ Ok(TableRow {
+ id: row.get(0)?,
+ date: row.get(1)?,
+ source: row.get(2)?,
+ destination: row.get(3)?,
+ amount: row.get(4)?,
+ })
)?
.collect::<Result<Vec<TableRow>, _>>()
})
diff --git a/src/model/balancing.rs b/src/model/balancing.rs
index fe480f2..6da7646 100644
--- a/src/model/balancing.rs
+++ b/src/model/balancing.rs
@@ -1,6 +1,7 @@
#[derive(Debug, serde::Serialize)]
pub struct TableRow {
pub id: i64,
+ pub date: String,
pub source: String,
pub destination: String,
pub amount: i64,
diff --git a/templates/balancing/table.html b/templates/balancing/table.html
index 72f3b37..07687fb 100644
--- a/templates/balancing/table.html
+++ b/templates/balancing/table.html
@@ -29,6 +29,7 @@
<span class="g-Table__Cell">Montant</span>
<span class="g-Table__Cell">De</span>
<span class="g-Table__Cell">Vers</span>
+ <span class="g-Table__Cell">Date</span>
</div>
{% for balancing in balancings %}
<a
@@ -40,6 +41,7 @@
</span>
<span class="g-Table__Cell">{{ balancing.source }}</span>
<span class="g-Table__Cell">{{ balancing.destination }}</span>
+ <span class="g-Table__Cell">{{ balancing.date }}</span>
</a>
{% endfor %}
</div>