Compare commits
No commits in common. "6913defcd9b8214e39c58e73ab24040383793f90" and "f8a5aac75faf662f54a4243c2c9416641d206892" have entirely different histories.
6913defcd9
...
f8a5aac75f
3 changed files with 10 additions and 15 deletions
|
@ -95,7 +95,7 @@ struct SimpleTransaction {
|
||||||
amount: f64,
|
amount: f64,
|
||||||
credit_account_code: String,
|
credit_account_code: String,
|
||||||
debit_account_code: String,
|
debit_account_code: String,
|
||||||
reference: Option<String>,
|
reference: String,
|
||||||
linked_users: Vec<Id>,
|
linked_users: Vec<Id>,
|
||||||
linked_subscriptions: Vec<Id>,
|
linked_subscriptions: Vec<Id>,
|
||||||
accounting_year: Id
|
accounting_year: Id
|
||||||
|
@ -321,7 +321,7 @@ impl AuthentifiedClient {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
id: u64,
|
id: u64,
|
||||||
label: String,
|
label: String,
|
||||||
reference: Option<String>,
|
reference: String,
|
||||||
#[serde(deserialize_with = "deserialize_json_list")]
|
#[serde(deserialize_with = "deserialize_json_list")]
|
||||||
accounts_codes: Vec<String>,
|
accounts_codes: Vec<String>,
|
||||||
year_id: u64,
|
year_id: u64,
|
||||||
|
@ -545,11 +545,9 @@ impl AuthentifiedClient {
|
||||||
.text("debit", transaction.debit_account_code)
|
.text("debit", transaction.debit_account_code)
|
||||||
.text("credit", transaction.credit_account_code)
|
.text("credit", transaction.credit_account_code)
|
||||||
// "Numéro pièce comptable" enregistré au niveau de la transaction
|
// "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 {
|
for linked_id in transaction.linked_users {
|
||||||
form = form.text("linked_users[]", format!("{}", linked_id.0));
|
form = form.text("linked_users[]", format!("{}", linked_id.0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ async fn get_auth_client_from_cache(
|
||||||
Ok(auth_client)
|
Ok(auth_client)
|
||||||
}
|
}
|
||||||
|
|
||||||
eprintln!("Initializing HA client…");
|
eprintln!("Init HA client");
|
||||||
|
|
||||||
match &user_cache.helloasso_session {
|
match &user_cache.helloasso_session {
|
||||||
Some(cached_session) => {
|
Some(cached_session) => {
|
||||||
|
@ -97,6 +97,8 @@ pub async fn sync_helloasso(
|
||||||
user_cache: &mut UserCache,
|
user_cache: &mut UserCache,
|
||||||
dry_run: bool
|
dry_run: bool
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
|
||||||
|
eprintln!("wow");
|
||||||
let mut ha_client: helloasso::Client = helloasso::Client::new(helloasso::ClientConfig {
|
let mut ha_client: helloasso::Client = helloasso::Client::new(helloasso::ClientConfig {
|
||||||
base_url: Url::parse("https://api.helloasso.com/v5/")
|
base_url: Url::parse("https://api.helloasso.com/v5/")
|
||||||
.expect("Expected valid helloasso API base URL"),
|
.expect("Expected valid helloasso API base URL"),
|
||||||
|
|
|
@ -112,22 +112,17 @@ pub async fn sync_paheko(
|
||||||
|
|
||||||
let existing_matching_transactions: Vec<&SimpleTransaction> = existing_transactions
|
let existing_matching_transactions: Vec<&SimpleTransaction> = existing_transactions
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|t| t.reference == Some(answer.reference.clone()))
|
.filter(|t| t.reference == answer.reference)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// check for existing user in paheko by email
|
// check for existing user in paheko by email
|
||||||
// TODO: check user with fuzzing first name and last name
|
// TODO: check user with fuzzing first name and last name
|
||||||
let existing_user_opt = existing_users
|
let existing_user_opt = existing_users
|
||||||
.iter()
|
.iter().find(|user| user.first_name == answer.first_name && user.last_name == answer.last_name)
|
||||||
.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()
|
|
||||||
)
|
|
||||||
.cloned();
|
.cloned();
|
||||||
let pk_user_summary = match existing_user_opt.clone() {
|
let pk_user_summary = match existing_user_opt.clone() {
|
||||||
Some(user) => {
|
Some(user) => {
|
||||||
eprintln!(" Found existing paheko user by matching name.");
|
eprintln!(" Found existing paheko user by matching name.");
|
||||||
// TODO: if existing user is different, update the details of user
|
|
||||||
user
|
user
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
|
@ -238,7 +233,7 @@ pub async fn sync_paheko(
|
||||||
// TODO: make the label template configurable
|
// TODO: make the label template configurable
|
||||||
label: format!("{} {:?} via {}", pk_membership.service_name, pk_membership.mode_name, via_name),
|
label: format!("{} {:?} via {}", pk_membership.service_name, pk_membership.mode_name, via_name),
|
||||||
amount: pk_membership.payed_amount,
|
amount: pk_membership.payed_amount,
|
||||||
reference: Some(answer.reference.clone()),
|
reference: answer.reference.clone(),
|
||||||
credit_account_code: "756".to_string(), // cotisations account
|
credit_account_code: "756".to_string(), // cotisations account
|
||||||
debit_account_code: debit_account_code.to_string(), // helloasso account
|
debit_account_code: debit_account_code.to_string(), // helloasso account
|
||||||
inception_time: answer.inception_time,
|
inception_time: answer.inception_time,
|
||||||
|
@ -269,7 +264,7 @@ pub async fn sync_paheko(
|
||||||
}.id.clone(),
|
}.id.clone(),
|
||||||
label: format!("Don lié à une adhésion via {}", via_name),
|
label: format!("Don lié à une adhésion via {}", via_name),
|
||||||
amount: answer.donation_amount,
|
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
|
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
|
debit_account_code: debit_account_code.to_string(), // compte d'encaissement
|
||||||
inception_time: answer.inception_time,
|
inception_time: answer.inception_time,
|
||||||
|
|
Loading…
Reference in a new issue