diff --git a/src/paheko.rs b/src/paheko.rs index b8ee3dc..904fe2d 100644 --- a/src/paheko.rs +++ b/src/paheko.rs @@ -95,7 +95,7 @@ struct SimpleTransaction { amount: f64, credit_account_code: String, debit_account_code: String, - reference: String, + reference: Option, linked_users: Vec, linked_subscriptions: Vec, accounting_year: Id @@ -321,7 +321,7 @@ impl AuthentifiedClient { #[allow(dead_code)] id: u64, label: String, - reference: String, + reference: Option, #[serde(deserialize_with = "deserialize_json_list")] accounts_codes: Vec, year_id: u64, @@ -545,9 +545,11 @@ impl AuthentifiedClient { .text("debit", transaction.debit_account_code) .text("credit", transaction.credit_account_code) // "Numéro pièce comptable" enregistré au niveau de la transaction - .text("reference", transaction.reference) ; + if let Some(reference) = transaction.reference { + form = form.text("reference", reference); + } for linked_id in transaction.linked_users { form = form.text("linked_users[]", format!("{}", linked_id.0)); } diff --git a/src/sync_helloasso.rs b/src/sync_helloasso.rs index 615e008..b87d14f 100644 --- a/src/sync_helloasso.rs +++ b/src/sync_helloasso.rs @@ -30,7 +30,7 @@ async fn get_auth_client_from_cache( Ok(auth_client) } - eprintln!("Init HA client"); + eprintln!("Initializing HA client…"); match &user_cache.helloasso_session { Some(cached_session) => { @@ -97,8 +97,6 @@ pub async fn sync_helloasso( user_cache: &mut UserCache, dry_run: bool ) -> Result<()> { - - eprintln!("wow"); let mut ha_client: helloasso::Client = helloasso::Client::new(helloasso::ClientConfig { base_url: Url::parse("https://api.helloasso.com/v5/") .expect("Expected valid helloasso API base URL"), diff --git a/src/sync_paheko.rs b/src/sync_paheko.rs index be8e002..0f8b292 100644 --- a/src/sync_paheko.rs +++ b/src/sync_paheko.rs @@ -112,7 +112,7 @@ pub async fn sync_paheko( let existing_matching_transactions: Vec<&SimpleTransaction> = existing_transactions .iter() - .filter(|t| t.reference == answer.reference) + .filter(|t| t.reference == Some(answer.reference.clone())) .collect(); // check for existing user in paheko by email @@ -123,6 +123,7 @@ pub async fn sync_paheko( let pk_user_summary = match existing_user_opt.clone() { Some(user) => { eprintln!(" Found existing paheko user by matching name."); + // TODO: if existing user is different, update the details of user user }, None => { @@ -233,7 +234,7 @@ pub async fn sync_paheko( // TODO: make the label template configurable label: format!("{} {:?} via {}", pk_membership.service_name, pk_membership.mode_name, via_name), amount: pk_membership.payed_amount, - reference: answer.reference.clone(), + reference: Some(answer.reference.clone()), credit_account_code: "756".to_string(), // cotisations account debit_account_code: debit_account_code.to_string(), // helloasso account inception_time: answer.inception_time, @@ -264,7 +265,7 @@ pub async fn sync_paheko( }.id.clone(), label: format!("Don lié à une adhésion via {}", via_name), amount: answer.donation_amount, - reference: answer.reference.clone(), + reference: Some(answer.reference.clone()), credit_account_code: DONATION_ACCOUNT_CODE.to_string(), // account 754 - Ressources liées à la générosité du public debit_account_code: debit_account_code.to_string(), // compte d'encaissement inception_time: answer.inception_time,