billecta 1.14.0

Generated Billecta API
Documentation
//! # Contract invoice
//!
//! Contract invoices are recurring invoices to the same customer with the same invoice
//! records and amounts. Using contract invoice you create an invoice definition and intervals
//! of when it should be triggered. The create invoice trigger is executed a new invoice from
//! the contract invoice is made and put among invoices (either as a draft/unattested or also
//! auto attested by the system depending on the configuration on the contract invoice. The
//! trigger is automatically managed by Billecta and made right after midnight. If a contract
//! invoice is created after midnight it will not be triggered until the day after as long as
//! next trigger/run date is today or earlier. Contract invoices also support invoice rows
//! that are in the future also rows that should automatically be phased out after a certain
//! date.
//!
use crate::{
    CommentAction, ContractInvoiceAction, ContractInvoiceActionSubs, Created, Date, EmptyResponse,
    HalfYearlyAutogiroContractInvoice, InvoiceActionSubs, MonthlyAutogiroContractInvoice, Request,
    RequestBuilder, Uuid, YearlyAutogiroContractInvoice,
};

///Get a contract invoice based on the public id number that contract
///invoice was assigned when created.
pub fn get_a_contract_invoice(id: &str) -> Request<ContractInvoiceAction> {
    RequestBuilder::new(http::Method::GET, "/v1/contractinvoice/action/")
        .path_param(id)
        .build()
}
pub fn update_a_contract_invoice(id: &str, body: &ContractInvoiceAction) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/contractinvoice/action/")
        .path_param(id)
        .body(body)
        .build()
}
///Create a new contract invoice. Response is the public id you will use
///when retrieving it again or performing actions on the contract invoice
///in the API.
pub fn create_a_contract_invoice(body: &ContractInvoiceAction) -> Request<Created> {
    RequestBuilder::new(http::Method::POST, "/v1/contractinvoice/action")
        .body(body)
        .build()
}
///Deletes a contract invoice. Please note that a contract invoice can't
///be deleted if at least on invoice is generated from it. Pause it
///(equal to disabling it) if it shall not be used anymore. You will get
///a 400 Bad Request it you try to delete a contract invoice that has
///been triggered at least once.
pub fn delete_a_contract_invoice(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::DELETE, "/v1/contractinvoice/action/")
        .path_param(id)
        .build()
}
///Get all contract invoices for all debtors/customers
pub fn get_all_contract_invoices(
    id: Uuid,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<ContractInvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/contractinvoice/actions/")
        .path_param(id)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
///Get all contract invoices that to the specified debtor/customer
pub fn get_all_contract_invoices_to_a_debtor(
    id: Uuid,
    debtorpublicid: Uuid,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<ContractInvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/contractinvoice/actionsbydebtor/")
        .path_param(id)
        .query_param("debtorpublicid", debtorpublicid)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
pub fn comment_a_contract_invoice(body: &CommentAction) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::POST, "/v1/contractinvoice/comment")
        .body(body)
        .build()
}
///Creates a new invoice with the contract invoice as template. The
///response is the public id of the newly created invoice and the new
///invoice is retrieved using the Invoice endpoints.
pub fn generate_a_new_invoice_from_a_contract_invoice(id: &str) -> Request<Created> {
    RequestBuilder::new(http::Method::PUT, "/v1/contractinvoice/createinvoice/")
        .path_param(id)
        .build()
}
///Gets all generated invoices by this contract invoice.
pub fn get_invoices_generated_from_contract_invoice(
    id: &str,
    offset: Option<i32>,
    limit: Option<i32>,
    sortingfield: Option<&str>,
    asc: Option<bool>,
) -> Request<InvoiceActionSubs> {
    RequestBuilder::new(http::Method::GET, "/v1/contractinvoice/generatedinvoices/")
        .path_param(id)
        .query_param_opt("offset", offset)
        .query_param_opt("limit", limit)
        .query_param_opt("sortingfield", sortingfield)
        .query_param_opt("asc", asc)
        .build()
}
///Create a new contract invoice set to half year recurring. Create
///debtor with autogiro enabled. Response is the public id you will use
///when retrieving it again or performing actions on the contract invoice
///in the API.
pub fn create_half_year_recurring_autogiro_contract_invoice(
    body: &HalfYearlyAutogiroContractInvoice,
) -> Request<Created> {
    RequestBuilder::new(
        http::Method::POST,
        "/v1/contractinvoice/halfyearlyrecurringautogiro",
    )
    .body(body)
    .build()
}
///Create a new contract invoice set to monthly recurring. Create debtor
///with autogiro enabled. Response is the public id you will use when
///retrieving it again or performing actions on the contract invoice in
///the API.
pub fn create_monthly_recurring_autogiro_contract_invoice(
    body: &MonthlyAutogiroContractInvoice,
) -> Request<Created> {
    RequestBuilder::new(
        http::Method::POST,
        "/v1/contractinvoice/monthlyrecurringautogiro",
    )
    .body(body)
    .build()
}
///Skips or reverts a contract invoice so that it is 'not
///triggered'/'retriggered' on the next run depending on recurring period
///setup. Please note that if you revert multiple steps to a date that is
///multiple periods earlier than current date, then the contract invoice
///will execute that many numbers of times until next step is after
///current date.
pub fn move_next_run(id: &str, steps: i32) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/contractinvoice/movenextrun/")
        .path_param(id)
        .query_param("steps", steps)
        .build()
}
///Pauses/Disables a contract invoice from automatically creating new
///invoices each triggered period
pub fn pause_disables_a_contract_invoice(id: &str) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/contractinvoice/pause/")
        .path_param(id)
        .build()
}
///Preview a contract invoice to view how it will be generated when the
///next period is triggered. This endpoint previews data already stored
///in API/database
pub fn preview_a_contract_invoice(id: &str) -> Request<Vec<u8>> {
    RequestBuilder::new(http::Method::GET, "/v1/contractinvoice/preview/")
        .path_param(id)
        .build()
}
///Preview a contract invoice to view how it will be generated when the
///next period is triggered. This endpoint previews data sent in the
///request and ignores data stored in the API/database.
pub fn preview_a_contract_invoice_post(body: &ContractInvoiceAction) -> Request<Vec<u8>> {
    RequestBuilder::new(http::Method::POST, "/v1/contractinvoice/preview")
        .body(body)
        .build()
}
///Resumes/Enables a contract invoice to automatically create new
///invoices when each period is triggered.
pub fn resume_a_contract_invoice(id: &str, nextdate: Date) -> Request<EmptyResponse> {
    RequestBuilder::new(http::Method::PUT, "/v1/contractinvoice/resume/")
        .path_param(id)
        .query_param("nextdate", nextdate)
        .build()
}
///Create a new contract invoice set to yearly recurring. Create debtor
///with autogiro enabled. Response is the public id you will use when
///retrieving it again or performing actions on the contract invoice in
///the API.
pub fn create_yearly_recurring_autogiro_contract_invoice(
    body: &YearlyAutogiroContractInvoice,
) -> Request<Created> {
    RequestBuilder::new(
        http::Method::POST,
        "/v1/contractinvoice/yearlyrecurringautogiro",
    )
    .body(body)
    .build()
}