billecta 1.14.0

Generated Billecta API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
//! # Invoice
//!
//! The following endpoints describes the invoice api calls. It is a self-standing section/
//! feature but has tight integrations with debt collection if you have access to those
//! modules.
//!
use crate::{
    ActionPublicIds, CardRefundPayment, CommentAction, CommonActionEvents, Created,
    CreditCardPayment, CreditCardPaymentIntent, CreditCardPayments, Date, DeliveryMethodType,
    EmptyResponse, InterestType, InvoiceAction, InvoiceActionEntry, InvoiceActionSubs,
    RegisterPayment, ReminderInvoiceAction, ReminderInvoiceActionSubs, Request, RequestBuilder,
    SendReminderInvoice, SwishRefundPayment, UpdateAddressAction, Uuid,
    VerificationInvoiceActionEntry,
};

///Returns an invoice based on the ActionPublicId. All invoices have a
///unique ActionPublicId that is generated on creation.
pub fn get_an_invoice(id: &str) -> Request<InvoiceAction> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/action/")
        .path_param(id)
        .build()
}
///Note that only non-attested invoices can be updated. Once attested it
///is locked and update is not possible any more.
pub fn update_an_invoice(id: &str, body: &InvoiceActionEntry) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/action/")
        .path_param(id)
        .body(body)
        .build()
}
///All created invoices are saved and not attested. To make it permanent
///and bookkeep it, the invoice action must be attested.
pub fn create_an_invoice(body: &InvoiceActionEntry) -> Request<Created> {
    RequestBuilder::new(http::Method::POST, "/v1/invoice/action")
        .body(body)
        .build()
}
///Only non-attested invoices can be deleted. Once attested it is locked
///and deletion is not allowed any more.
pub fn delete_an_invoice(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/invoice/action/")
        .path_param(id)
        .build()
}
///Returns an invoice based on the invoice number.
pub fn get_an_invoice_by_invoice_number(id: Uuid, invoicenumber: &str) -> Request<InvoiceAction> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/actionbyinvoicenumber/")
        .path_param(id)
        .query_param("invoicenumber", invoicenumber)
        .build()
}
///Overrides the customer/debtor address and sets a temporary address for
///this invoice only
pub fn update_address_on_an_invoice(body: &UpdateAddressAction) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/address")
        .body(body)
        .build()
}
///Delete the overridden debtor address and uses the address from the
///debtor/customer card
pub fn delete_address_override_for_an_invoice(
    id: &str,
    body: &UpdateAddressAction,
) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/invoice/address/")
        .path_param(id)
        .body(body)
        .build()
}
///Attesting an invoice means that it will be book kept and locked for
///editing. Invoice is automatically sent if any distribution is set.
pub fn attest_an_invoice(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/attest/")
        .path_param(id)
        .build()
}
///Creates an autogiro withdrawal on the latest of todays date or the
///invoice due date
pub fn create_autogiro_withdrawal(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::POST, "/v1/invoice/autogiro/")
        .path_param(id)
        .build()
}
///The autogiro withdrawal can be cancelled using this endpoint. Note
///that this can't be done up to the day before the autogiro withdrawal
///date (day before due date)
pub fn cancel_autogiro_withdrawal(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/invoice/autogiro/")
        .path_param(id)
        .build()
}
///Removed the invoice dispute flag which reenables all automatic events
///on the invoice again
pub fn cancel_invoice_dispute(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/canceldispute/")
        .path_param(id)
        .build()
}
///Canceling the reminder invoice will also remove any added reminder
///fees to the invoice
pub fn cancel_reminder_invoice(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/cancelreminder/")
        .path_param(id)
        .build()
}
///Retrieves all invoices that have a closed/full payment date between
///the specified from and to dates.
pub fn get_all_closed_invoices(
    id: Uuid,
    from: Date,
    to: Date,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<InvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/closed/")
        .path_param(id)
        .query_param("from", from)
        .query_param("to", to)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
///Retrieves all invoices for a specific debtor that have a closed/full
///payment date between the specified from and to dates.
pub fn get_all_closed_invoices_by_debtor_public_id(
    id: Uuid,
    from: Date,
    to: Date,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<InvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/closedbydebtor/")
        .path_param(id)
        .query_param("from", from)
        .query_param("to", to)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
///Retrieves all closed invoices by invoice period.
pub fn get_all_closed_invoices_by_invoice_period(
    id: Uuid,
    from: Date,
    to: Date,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<InvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/closedbyperiod/")
        .path_param(id)
        .query_param("from", from)
        .query_param("to", to)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
///Writes a comment to the self invoice events log.
pub fn comment_an_invoice(body: &CommentAction) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::POST, "/v1/invoice/comment")
        .body(body)
        .build()
}
///A debit and credit invoice can be connected and balance each other out
///by this endpoint. If both have the same amount (the other one
///negative), then both will be closed. If one invoice has more amount
///than the other one, one of them will be closed and the other will have
///a current amount equal to the difference.
pub fn credit_an_invoice_with_existing_credit_invoice(
    id: &str,
    creditinvoiceactionpublicid: &str,
    paymentmeancode: Option<&str>,
) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/creditaction/")
        .path_param(id)
        .query_param("creditinvoiceactionpublicid", creditinvoiceactionpublicid)
        .query_param_opt("paymentmeancode", paymentmeancode)
        .build()
}
///Make an credit card payment intent with the amount on the invoice.
pub fn create_credit_card_payment_intent(
    body: &CreditCardPaymentIntent,
) -> Request<CreditCardPayment> {
    RequestBuilder::new(http::Method::POST, "/v1/invoice/creditcardpayment")
        .body(body)
        .build()
}
///The credit card payment can be cancelled if payment has not been
///completed yet.
pub fn cancel_credit_card_payment(id: Uuid) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/invoice/creditcardpayment/")
        .path_param(id)
        .build()
}
///Gets all credit card payment intents for a given invoice
pub fn get_all_credit_card_payment_intents(id: &str) -> Request<CreditCardPayments> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/creditcardpayments/")
        .path_param(id)
        .build()
}
///Creates a card withdrawal on the latest of specified date (optional)
///or todays date or the invoice due date
pub fn create_card_withdrawal(id: &str, paymentdate: Option<Date>) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::POST, "/v1/invoice/creditcardwithdrawal/")
        .path_param(id)
        .query_param_opt("paymentdate", paymentdate)
        .build()
}
///According to law a debtor/customer has the right to dispute an invoice
///(regardless reason). If such a knowledge is known to the customer no
///more automatic events are allowed to perform on the invoice (like
///sending it to debt collection)
pub fn dispute_an_invoice(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/dispute/")
        .path_param(id)
        .build()
}
pub fn get_all_events_for_all_invoices(
    id: Uuid,
    from: &str,
    to: &str,
) -> Request<CommonActionEvents> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/events/")
        .path_param(id)
        .query_param("from", from)
        .query_param("to", to)
        .build()
}
///Finance the invoice to a specified sales contract. If no contract is
///specified and only one exists that invoice sale contract will be used.
pub fn finance_the_invoice(
    id: &str,
    debtorcontractpublicid: Uuid,
    salescontractpublicid: Option<Uuid>,
) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/financeinvoice/")
        .path_param(id)
        .query_param("debtorcontractpublicid", debtorcontractpublicid)
        .query_param_opt("salescontractpublicid", salescontractpublicid)
        .build()
}
///According to law an invoice sender has the right to invoice the lost
///interest on a due invoice. By calling this endpoint an interest
///invoice will be sent with only the interest generated between the from
///and to date. Note that Billecta doesn't take consideration on the from
///and to date overlap with another reminder invoice with the same from
///and to date.
pub fn create_interest_invoice(
    id: &str,
    from: Date,
    to: Date,
    interesttype: &InterestType,
    interest: f64,
) -> Request<Created> {
    RequestBuilder::new(http::Method::POST, "/v1/invoice/interestinvoice/")
        .path_param(id)
        .query_param("from", from)
        .query_param("to", to)
        .query_param("interesttype", *interesttype)
        .query_param("interest", interest)
        .build()
}
///Invoice events gets archived after one year. This reloads archived
///events to enable the events to be retrieved again. Observe that these
///events will be archived again after one day.
pub fn load_archived_events(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/loadarchivedevents/")
        .path_param(id)
        .build()
}
///Retrieves all drafts/attested and unpaid invoices.
pub fn get_all_open_invoices(
    id: Uuid,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<InvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/open/")
        .path_param(id)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
///Retrieves all open invoices for a specific debtor.
pub fn get_all_open_invoices_by_debtor_public_id(
    id: Uuid,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<InvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/openbydebtor/")
        .path_param(id)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
///Retrieves all open invoices by invoice period.
pub fn get_all_open_invoices_by_invoice_period(
    id: Uuid,
    from: Date,
    to: Date,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<InvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/openbyperiod/")
        .path_param(id)
        .query_param("from", from)
        .query_param("to", to)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
///Get all open reminder invoices. Use this endpoint to see which
///invoices have an active reminder
pub fn get_all_open_reminder_invoices(
    id: Uuid,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<ReminderInvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/openreminders/")
        .path_param(id)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
///Pauses the invoice from any more automatic events.
pub fn pause_an_invoice(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/pause/")
        .path_param(id)
        .build()
}
///Postpones the next automatic event of an invoice. Note that it is only
///possible to postpone forward and not backwards
pub fn postpone_next_event(id: &str, days: i32) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/postpone/")
        .path_param(id)
        .query_param("days", days)
        .build()
}
///Postpones the next automatic event of an invoice. Note that it is only
///possible to postpone forward and not backwards
pub fn postpone_next_event_date(id: &str, date: Date) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/postpone/")
        .path_param(id)
        .query_param("date", date)
        .build()
}
///Preview an invoice to view how it will be generated. This endpoint
///previews data already stored in API/database. This endpoint returns a
///PDF data stream in the content
pub fn preview_an_invoice(id: &str) -> Request<Vec<u8>> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/preview/")
        .path_param(id)
        .build()
}
///Preview an invoice to view how it will be generated. This endpoint
///previews data sent in the request and ignores data stored in the API/
///database. This endpoint returns a PDF data stream in the content
pub fn preview_an_invoice_post(body: &InvoiceActionEntry) -> Request<Vec<u8>> {
    RequestBuilder::new(http::Method::POST, "/v1/invoice/preview")
        .body(body)
        .build()
}
///The credit card payment can be refunded if payment has been completed.
pub fn refund_credit_card_payment(body: &CardRefundPayment) -> Request<Created> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/refundcreditcardpayment")
        .body(body)
        .build()
}
///The swish payment can be refunded if payment has been completed.
pub fn refund_swish_payment(body: &SwishRefundPayment) -> Request<Created> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/refundswishpayment")
        .body(body)
        .build()
}
///Register an already received payment on the invoice that was not
///received through Billecta.
pub fn register_payment_on_an_invoice(body: &RegisterPayment) -> Request<Created> {
    RequestBuilder::new(http::Method::POST, "/v1/invoice/registerpayment")
        .body(body)
        .build()
}
///Invoice reminders can be sent using the Invoice/SendReminderInvoice
///endpoint. Call this endpoint to retrieve metadata about the reminder.
pub fn get_reminder_invoice(id: &str) -> Request<ReminderInvoiceAction> {
    RequestBuilder::new(http::Method::GET, "/v1/invoice/reminder/")
        .path_param(id)
        .build()
}
///Resumes the self invoice to automatically process events.
pub fn resume_a_paused_invoice(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/resume/")
        .path_param(id)
        .build()
}
///Invoices where XML has been generated can be marked as processed and
///filtered/hidden when exporting XML for other invoices
pub fn mark_invoices_are_processed_for_rot(body: &ActionPublicIds) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/rotprocessed")
        .body(body)
        .build()
}
pub fn unmark_invoices_are_processed_for_rot(body: &ActionPublicIds) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/invoice/rotprocessed")
        .body(body)
        .build()
}
///Invoices where XML has been generated can be marked as processed and
///filtered/hidden when exporting XML for other invoices
pub fn mark_invoices_are_processed_for_rut(body: &ActionPublicIds) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/rutprocessed")
        .body(body)
        .build()
}
pub fn unmark_invoices_are_processed_for_rut(body: &ActionPublicIds) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/invoice/rutprocessed")
        .body(body)
        .build()
}
///Sells the invoice to a purchaser according to specified sales
///contract. If no contract is specified and only one exists that invoice
///sale contract will be used.
pub fn sell_the_invoice(id: &str, salescontractpublicid: Option<Uuid>) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/sellinvoice/")
        .path_param(id)
        .query_param_opt("salescontractpublicid", salescontractpublicid)
        .build()
}
///If invoice has not been accepted by purchaser the invoice sales can be
///cancelled and reverted.
pub fn cancel_the_invoice_sales(id: &str, comment: Option<&str>) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/invoice/sellinvoice/")
        .path_param(id)
        .query_param_opt("comment", comment)
        .build()
}
///Sends the invoice with the preferred delivery method. Note that
///omitting optional parameters will use pre-stored values on the
///invoice.
pub fn send_the_invoice(id: &str, method: &DeliveryMethodType) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/sendinvoice/")
        .path_param(id)
        .query_param("method", *method)
        .build()
}
///Creates and sends a reminder invoice for the invoice. Reminder fees
///and PDF:s will be added to the invoice.
pub fn send_the_reminder_invoice(id: &str, method: &DeliveryMethodType) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/sendreminderinvoice/")
        .path_param(id)
        .query_param("method", *method)
        .build()
}
///Uses a already reminder PDF generated by you and sends it. Reminder
///fees and PDF:s will be added to the invoice.
pub fn send_the_reminder_invoice_with_pregenerated_pdf(
    body: &SendReminderInvoice,
) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/invoice/sendreminderinvoice")
        .body(body)
        .build()
}
///A verification invoice is a pure bookkeeping event. You create the
///verification to write to the bookkeeping and have a 'receipt' on the
///invoice for tracking. It is automatically closed after creation.
pub fn create_a_verification_invoice(body: &VerificationInvoiceActionEntry) -> Request<Created> {
    RequestBuilder::new(http::Method::POST, "/v1/invoice/verificationinvoice")
        .body(body)
        .build()
}