Compare commits

..

No commits in common. "14a5952e144d384b1552ccb01919e33fba5d9c39" and "ae8887c72d6ab1b8243668ee8e29bd44185e0d4a" have entirely different histories.

3 changed files with 7 additions and 27 deletions

View File

@ -142,15 +142,10 @@ impl User {
let mut fee = Fee::new(); let mut fee = Fee::new();
if let Some(family) = Family::find_by_opt_id(db, self.family_id).await { if let Some(family) = Family::find_by_opt_id(db, self.family_id).await {
let mut names = String::new(); fee.name(format!("{} + Familie", self.name));
for member in family.members(db).await { for member in family.members(db).await {
if !names.is_empty() {
names.push_str(" + ");
}
names.push_str(&member.name);
fee.merge(member.fee_without_families(db).await); fee.merge(member.fee_without_families(db).await);
} }
fee.name(names);
if family.amount_family_members(db).await > 2 { if family.amount_family_members(db).await > 2 {
fee.add("Familie 3+ Personen".into(), FAMILY_THREE_OR_MORE); fee.add("Familie 3+ Personen".into(), FAMILY_THREE_OR_MORE);
} else { } else {
@ -362,26 +357,6 @@ ORDER BY last_access DESC
.unwrap() .unwrap()
} }
pub async fn all_payer_groups(db: &SqlitePool) -> Vec<Self> {
sqlx::query_as!(
Self,
"
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id FROM user
WHERE family_id IS NOT NULL
GROUP BY family_id
UNION
-- Select users with a null family_id, without grouping
SELECT id, name, pw, deleted, last_access, dob, weight, sex, member_since_date, birthdate, mail, nickname, notes, phone, address, family_id FROM user
WHERE family_id IS NULL;
"
)
.fetch_all(db)
.await
.unwrap()
}
pub async fn ergo(db: &SqlitePool) -> Vec<Self> { pub async fn ergo(db: &SqlitePool) -> Vec<Self> {
sqlx::query_as!( sqlx::query_as!(
Self, Self,

View File

@ -56,7 +56,7 @@ async fn fees(
) -> Template { ) -> Template {
let mut context = Context::new(); let mut context = Context::new();
let users = User::all_payer_groups(db).await; let users = User::all(db).await;
let mut fees = Vec::new(); let mut fees = Vec::new();
for user in users { for user in users {
if let Some(fee) = user.fee(db).await { if let Some(fee) = user.fee(db).await {

View File

@ -0,0 +1,5 @@
CREATE TABLE IF NOT EXISTS "family" (
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT
);
ALTER TABLE "user" ADD COLUMN "family_id" INTEGER REFERENCES family(id);