fix(paheko): transaction reference can be NULL
This commit is contained in:
parent
f8a5aac75f
commit
6ae274e810
3 changed files with 10 additions and 9 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: String,
|
reference: Option<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: String,
|
reference: Option<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,9 +545,11 @@ 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!("Init HA client");
|
eprintln!("Initializing HA client…");
|
||||||
|
|
||||||
match &user_cache.helloasso_session {
|
match &user_cache.helloasso_session {
|
||||||
Some(cached_session) => {
|
Some(cached_session) => {
|
||||||
|
@ -97,8 +97,6 @@ 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,7 +112,7 @@ 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 == answer.reference)
|
.filter(|t| t.reference == Some(answer.reference.clone()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// check for existing user in paheko by email
|
// 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() {
|
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 => {
|
||||||
|
@ -233,7 +234,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: answer.reference.clone(),
|
reference: Some(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,
|
||||||
|
@ -264,7 +265,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: 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
|
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