membership-pdf-new #284
@ -182,4 +182,117 @@ Der Vorstand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn fees_final(db: &SqlitePool, smtp_pw: String) {
|
||||||
|
let users = User::all_payer_groups(db).await;
|
||||||
|
for user in users {
|
||||||
|
if let Some(fee) = user.fee(db).await {
|
||||||
|
if !fee.paid {
|
||||||
|
let mut is_family = false;
|
||||||
|
let mut send_to = String::new();
|
||||||
|
match Family::find_by_opt_id(db, user.family_id).await {
|
||||||
|
Some(family) => {
|
||||||
|
is_family = true;
|
||||||
|
for member in family.members(db).await {
|
||||||
|
if let Some(mail) = member.mail {
|
||||||
|
send_to.push_str(&format!("{mail},"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
if let Some(mail) = &user.mail {
|
||||||
|
send_to.push_str(mail)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let fees = user.fee(db).await;
|
||||||
|
if let Some(fees) = fees {
|
||||||
|
let mut content = format!(
|
||||||
|
"Liebes Vereinsmitglied, \n\n\
|
||||||
|
wir möchten darauf hinweisen, dass wir deinen Mitgliedsbeitrag für das laufende Jahr bislang nicht verbuchen konnten. Es besteht die Möglichkeit, dass es sich hierbei um ein Versehen unsererseits handelt. Solltest du den Betrag bereits überwiesen haben, bitte kurz auf diese E-Mail antworten, damit wir es richtigstellen können.
|
||||||
|
|
||||||
|
Falls die Zahlung noch nicht erfolgt ist, bitten wir um umgehende Überweisung des ausstehenden Betrags, spätestens jedoch bis zum 31. März, auf unser Bankkonto.\n\n\
|
||||||
|
Dein Vereintsbeitrag für das aktuelle Jahr beträgt {}€",
|
||||||
|
fees.sum_in_cents / 100,
|
||||||
|
);
|
||||||
|
|
||||||
|
if fees.parts.len() == 1 {
|
||||||
|
content.push_str(&format!(" ({}).\n", fees.parts[0].0))
|
||||||
|
} else {
|
||||||
|
content
|
||||||
|
.push_str(". Dieser setzt sich aus folgenden Teilen zusammen: \n");
|
||||||
|
for (desc, fee_in_cents) in fees.parts {
|
||||||
|
content.push_str(&format!("- {}: {}€\n", desc, fee_in_cents / 100))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if is_family {
|
||||||
|
content.push_str(&format!(
|
||||||
|
"Dieser gilt für die gesamte Familie ({}).\n",
|
||||||
|
fees.name
|
||||||
|
))
|
||||||
|
}
|
||||||
|
content.push_str("\n\
|
||||||
|
Gemäß § 7 Abs. 3 lit. c unseres Status behalten wir uns vor, bei ausbleibender Zahlung die Mitgliedschaft zu beenden. Dies möchten wir vermeiden und hoffen auf deine Unterstützung.\n\n\
|
||||||
|
|
||||||
|
Bei Fragen oder Problemen stehen wir gerne zur Verfügung.
|
||||||
|
|
||||||
|
Bankverbindung: IBAN: AT13 1200 0804 1300 1200 (Unter https://app.rudernlinz.at/planned findest du einen QR Code, den du mit deiner Bankapp scannen kannst um alle Eingaben bereits ausgefüllt zu haben.)
|
||||||
|
|
||||||
|
Mit freundlichen Grüßen,\n\
|
||||||
|
Der Vorstand");
|
||||||
|
let mut email = Message::builder()
|
||||||
|
.from(
|
||||||
|
"ASKÖ Ruderverein Donau Linz <no-reply@rudernlinz.at>"
|
||||||
|
.parse()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.reply_to(
|
||||||
|
"ASKÖ Ruderverein Donau Linz <it@rudernlinz.at>"
|
||||||
|
.parse()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.to("ASKÖ Ruderverein Donau Linz <no-reply@rudernlinz.at>"
|
||||||
|
.parse()
|
||||||
|
.unwrap());
|
||||||
|
let splitted = send_to.split(',');
|
||||||
|
let mut send_mail = false;
|
||||||
|
for single_rec in splitted {
|
||||||
|
let single_rec = single_rec.trim();
|
||||||
|
match single_rec.parse() {
|
||||||
|
Ok(val) => {
|
||||||
|
email = email.bcc(val);
|
||||||
|
send_mail = true;
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
println!("Error in mail: {single_rec}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if send_mail {
|
||||||
|
let email = email
|
||||||
|
.subject("Mahnung Vereinsgebühren | ASKÖ Ruderverein Donau Linz")
|
||||||
|
.header(ContentType::TEXT_PLAIN)
|
||||||
|
.body(content)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let creds = Credentials::new(
|
||||||
|
"no-reply@rudernlinz.at".to_owned(),
|
||||||
|
smtp_pw.clone(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let mailer = SmtpTransport::relay("mail.your-server.de")
|
||||||
|
.unwrap()
|
||||||
|
.credentials(creds)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Send the email
|
||||||
|
mailer.send(&email).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ const REGULAR: i32 = 22000;
|
|||||||
const UNTERSTUETZEND: i32 = 2500;
|
const UNTERSTUETZEND: i32 = 2500;
|
||||||
const FOERDERND: i32 = 8500;
|
const FOERDERND: i32 = 8500;
|
||||||
|
|
||||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
#[derive(FromRow, Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
@ -106,6 +106,7 @@ pub struct Fee {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
pub user_ids: String,
|
pub user_ids: String,
|
||||||
pub paid: bool,
|
pub paid: bool,
|
||||||
|
pub users: Vec<User>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Fee {
|
impl Default for Fee {
|
||||||
@ -121,6 +122,7 @@ impl Fee {
|
|||||||
name: "".into(),
|
name: "".into(),
|
||||||
parts: Vec::new(),
|
parts: Vec::new(),
|
||||||
user_ids: "".into(),
|
user_ids: "".into(),
|
||||||
|
users: Vec::new(),
|
||||||
paid: false,
|
paid: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,6 +141,7 @@ impl Fee {
|
|||||||
self.name.push_str(&user.name);
|
self.name.push_str(&user.name);
|
||||||
|
|
||||||
self.user_ids.push_str(&format!("user_ids[]={}", user.id));
|
self.user_ids.push_str(&format!("user_ids[]={}", user.id));
|
||||||
|
self.users.push(user.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn paid(&mut self) {
|
pub fn paid(&mut self) {
|
||||||
|
@ -39,6 +39,16 @@ async fn fee(db: &State<SqlitePool>, _admin: AdminUser, config: &State<Config>)
|
|||||||
"SUCC"
|
"SUCC"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/mail/fee-final")]
|
||||||
|
async fn fee_final(
|
||||||
|
db: &State<SqlitePool>,
|
||||||
|
_admin: AdminUser,
|
||||||
|
config: &State<Config>,
|
||||||
|
) -> &'static str {
|
||||||
|
Mail::fees_final(db, config.smtp_pw.clone()).await;
|
||||||
|
"SUCC"
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(FromForm, Debug)]
|
#[derive(FromForm, Debug)]
|
||||||
pub struct MailToSend<'a> {
|
pub struct MailToSend<'a> {
|
||||||
pub(crate) role_id: i32,
|
pub(crate) role_id: i32,
|
||||||
@ -63,7 +73,7 @@ async fn update(
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn routes() -> Vec<Route> {
|
pub fn routes() -> Vec<Route> {
|
||||||
routes![index, update, fee]
|
routes![index, update, fee, fee_final]
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user