Compare commits

..

No commits in common. "6913defcd9b8214e39c58e73ab24040383793f90" and "f8a5aac75faf662f54a4243c2c9416641d206892" have entirely different histories.

3 changed files with 10 additions and 15 deletions

View file

@ -95,7 +95,7 @@ struct SimpleTransaction {
amount: f64,
credit_account_code: String,
debit_account_code: String,
reference: Option<String>,
reference: String,
linked_users: Vec<Id>,
linked_subscriptions: Vec<Id>,
accounting_year: Id
@ -321,7 +321,7 @@ impl AuthentifiedClient {
#[allow(dead_code)]
id: u64,
label: String,
reference: Option<String>,
reference: String,
#[serde(deserialize_with = "deserialize_json_list")]
accounts_codes: Vec<String>,
year_id: u64,
@ -545,11 +545,9 @@ 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));
}

View file

@ -30,7 +30,7 @@ async fn get_auth_client_from_cache(
Ok(auth_client)
}
eprintln!("Initializing HA client");
eprintln!("Init HA client");
match &user_cache.helloasso_session {
Some(cached_session) => {
@ -97,6 +97,8 @@ 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"),

View file

@ -112,22 +112,17 @@ pub async fn sync_paheko(
let existing_matching_transactions: Vec<&SimpleTransaction> = existing_transactions
.iter()
.filter(|t| t.reference == Some(answer.reference.clone()))
.filter(|t| t.reference == answer.reference)
.collect();
// check for existing user in paheko by email
// TODO: check user with fuzzing first name and last name
let existing_user_opt = existing_users
.iter()
.find(|user|
user.first_name.clone().map(|x| x.to_lowercase()) == answer.first_name.clone().map(|x| x.to_lowercase()) &&
user.last_name.to_lowercase() == answer.last_name.to_lowercase()
)
.iter().find(|user| user.first_name == answer.first_name && user.last_name == answer.last_name)
.cloned();
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 => {
@ -238,7 +233,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: Some(answer.reference.clone()),
reference: 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,
@ -269,7 +264,7 @@ pub async fn sync_paheko(
}.id.clone(),
label: format!("Don lié à une adhésion via {}", via_name),
amount: answer.donation_amount,
reference: Some(answer.reference.clone()),
reference: 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,