fix(paheko): use linked_subscriptions on transaction import

This commit is contained in:
Matthieu Bessat 2024-01-19 21:43:28 +01:00
parent 64f115d0d5
commit 52c7da4836
2 changed files with 4 additions and 5 deletions

View file

@ -97,7 +97,7 @@ struct SimpleTransaction {
debit_account_code: String,
reference: String,
linked_users: Vec<Id>,
linked_services: Vec<Id>,
linked_subscriptions: Vec<Id>,
accounting_year: Id
}
@ -520,9 +520,8 @@ impl AuthentifiedClient {
for linked_id in transaction.linked_users {
form = form.text("linked_users[]", format!("{}", linked_id.0));
}
// only possible with paheko fork
for linked_id in transaction.linked_services {
form = form.text("linked_services[]", format!("{}", linked_id.0));
for linked_id in transaction.linked_subscriptions {
form = form.text("linked_subscriptions[]", format!("{}", linked_id.0));
}
let res = self.client

View file

@ -245,7 +245,7 @@ pub async fn sync_paheko(
kind: paheko::TransactionKind::Revenue,
linked_users: pk_users_summaries.iter().map(|x| x.id.clone()).collect(),
// the linked_services, depend on a patch to paheko API code to work (see https://forge.lefuturiste.fr/mbess/paheko-fork/commit/a4fdd816112f51db23a2b02ac160b0513a5b09c5)
linked_services: pk_user_service_registrations.iter().map(|x| x.id.clone()).collect()
linked_subscriptions: pk_user_service_registrations.iter().map(|x| x.id.clone()).collect()
};
let _ = paheko_client.register_transaction(transaction)
.await.context("Expected to create new paheko transaction")?;