BexioApiClient.Purchase (bexio_api_client v2.0.0)

Copy Markdown

Purchase Part of the API

Summary

Functions

Endpoint for creating a Bill

Endpoint for creating an Expense

Endpoint for creating an Outgoing Payment

This action creates a new purchase order

Endpoint for deleting a Bill by id. Bill can be removed when it is in status :draft only.

Endpoint for deleting an Expense by id. Expense cannot be removed when it is :done.

Endpoint for deleting an Outgoing Payment by id. Payment cannot be removed when it is reconciled (:transaction_id is not nil) or its Business Year is Closed or Locked.

This action permanently deletes a purchase order. It cannot be undone.

Endpoint for updating a Bill

Endpoint for updating an Expense

Endpoint for editing an Outgoing Payment. The id of the payment is taken from outgoing_payment.id and sent as payment_id (bulk edit endpoint).

This action updates a purchase order.

Endpoint for executing actions for a Bill, e.g. DUPLICATE.

Endpoint for executing actions for an Expense, e.g. DUPLICATE.

Endpoint for retrieving a single Bill by id

Endpoint for validating whether a Bill document number is available or not.

Endpoint for retrieving a single Expense by id

Endpoint for validating whether an Expense document number is available or not.

Endpoint for retrieving Expenses

Endpoint for retrieving a single Outgoing Payment by id

Endpoint for retrieving Outgoing Payments for a Bill

This action fetches a single purchase order

Fetch a list of purchase orders.

Endpoint for updating the status of a Bill (changing status to :booked or back to :draft).

Endpoint for updating the status of an Expense (changing status to :done or back to :draft).

Types

api_error_type()

@type api_error_type() :: BexioApiClient.Helpers.api_error_type()

bill_booking_status()

@type bill_booking_status() :: :draft | :booked

bill_search_args()

@type bill_search_args() :: [
  bill_date_start: Date.t(),
  bill_date_end: Date.t(),
  due_date_start: Date.t(),
  due_date_end: Date.t(),
  vendor_ref: String.t(),
  title: String.t(),
  currency_code: String.t(),
  pending_amount_min: float(),
  pending_amount_max: float(),
  vendor: String.t(),
  gross_min: float(),
  gross_max: float(),
  net_min: float(),
  net_max: float(),
  document_no: String.t(),
  supplier_id: integer(),
  status: :drafts | :todo | :paid | :overdue
]

expense_booking_status()

@type expense_booking_status() :: :draft | :done

expense_search_args()

@type expense_search_args() :: [
  vendor: String.t(),
  gross_min: float(),
  gross_max: float(),
  net_min: float(),
  net_max: float(),
  paid_on_start: Date.t(),
  paid_on_end: Date.t(),
  created_at_start: DateTime.t(),
  created_at_end: DateTime.t(),
  title: String.t(),
  currency_code: String.t(),
  document_no: String.t(),
  supplier_id: integer(),
  project_id: String.t()
]

Functions

create_bill(req, bill)

@spec create_bill(req :: Req.Request.t(), bill :: BexioApiClient.Purchase.Bill.t()) ::
  {:ok, BexioApiClient.Purchase.Bill.t()} | api_error_type()

Endpoint for creating a Bill

create_expense(req, expense)

@spec create_expense(
  req :: Req.Request.t(),
  expense :: BexioApiClient.Purchase.Expense.t()
) ::
  {:ok, BexioApiClient.Purchase.Expense.t()} | api_error_type()

Endpoint for creating an Expense

create_outgoing_payment(req, outgoing_payment)

@spec create_outgoing_payment(
  req :: Req.Request.t(),
  outgoing_payment :: BexioApiClient.Purchase.OutgoingPayment.t()
) :: {:ok, BexioApiClient.Purchase.OutgoingPayment.t()} | api_error_type()

Endpoint for creating an Outgoing Payment

create_purchase_order(req, purchase_order)

@spec create_purchase_order(
  req :: Req.Request.t(),
  purchase_order :: BexioApiClient.Purchase.PurchaseOrder.t()
) :: {:ok, BexioApiClient.Purchase.PurchaseOrder.t()} | api_error_type()

This action creates a new purchase order

delete_bill(req, id)

@spec delete_bill(req :: Req.Request.t(), id :: String.t()) ::
  {:ok, boolean()} | api_error_type()

Endpoint for deleting a Bill by id. Bill can be removed when it is in status :draft only.

delete_expense(req, id)

@spec delete_expense(req :: Req.Request.t(), id :: String.t()) ::
  {:ok, boolean()} | api_error_type()

Endpoint for deleting an Expense by id. Expense cannot be removed when it is :done.

delete_outgoing_payment(req, id)

@spec delete_outgoing_payment(req :: Req.Request.t(), id :: String.t()) ::
  {:ok, boolean()} | api_error_type()

Endpoint for deleting an Outgoing Payment by id. Payment cannot be removed when it is reconciled (:transaction_id is not nil) or its Business Year is Closed or Locked.

delete_purchase_order(req, purchase_order_id)

@spec delete_purchase_order(
  req :: Req.Request.t(),
  purchase_order_id :: pos_integer()
) ::
  {:ok, boolean()} | api_error_type()

This action permanently deletes a purchase order. It cannot be undone.

edit_bill(req, id, bill)

@spec edit_bill(
  req :: Req.Request.t(),
  id :: String.t(),
  bill :: BexioApiClient.Purchase.Bill.t()
) ::
  {:ok, BexioApiClient.Purchase.Bill.t()} | api_error_type()

Endpoint for updating a Bill

edit_expense(req, id, expense)

@spec edit_expense(
  req :: Req.Request.t(),
  id :: String.t(),
  expense :: BexioApiClient.Purchase.Expense.t()
) :: {:ok, BexioApiClient.Purchase.Expense.t()} | api_error_type()

Endpoint for updating an Expense

edit_outgoing_payment(req, outgoing_payment)

@spec edit_outgoing_payment(
  req :: Req.Request.t(),
  outgoing_payment :: BexioApiClient.Purchase.OutgoingPayment.t()
) :: {:ok, BexioApiClient.Purchase.OutgoingPayment.t()} | api_error_type()

Endpoint for editing an Outgoing Payment. The id of the payment is taken from outgoing_payment.id and sent as payment_id (bulk edit endpoint).

edit_purchase_order(req, purchase_order_id, purchase_order)

@spec edit_purchase_order(
  req :: Req.Request.t(),
  purchase_order_id :: pos_integer(),
  purchase_order :: BexioApiClient.Purchase.PurchaseOrder.t()
) :: {:ok, BexioApiClient.Purchase.PurchaseOrder.t()} | api_error_type()

This action updates a purchase order.

execute_bill_action(req, id, action)

@spec execute_bill_action(
  req :: Req.Request.t(),
  id :: String.t(),
  action :: String.t()
) ::
  {:ok, BexioApiClient.Purchase.Bill.t()} | api_error_type()

Endpoint for executing actions for a Bill, e.g. DUPLICATE.

execute_expense_action(req, id, action)

@spec execute_expense_action(
  req :: Req.Request.t(),
  id :: String.t(),
  action :: String.t()
) ::
  {:ok, BexioApiClient.Purchase.Expense.t()} | api_error_type()

Endpoint for executing actions for an Expense, e.g. DUPLICATE.

fetch_bill(req, id)

@spec fetch_bill(req :: Req.Request.t(), id :: String.t()) ::
  {:ok, BexioApiClient.Purchase.Bill.t()} | api_error_type()

Endpoint for retrieving a single Bill by id

fetch_bill_document_number(req, document_no)

@spec fetch_bill_document_number(req :: Req.Request.t(), document_no :: String.t()) ::
  {:ok, BexioApiClient.Purchase.DocumentNumber.t()} | api_error_type()

Endpoint for validating whether a Bill document number is available or not.

fetch_bills(req, search_term \\ nil, fields \\ nil, search_args \\ [], opts \\ [])

@spec fetch_bills(
  req :: Req.Request.t(),
  search_term :: String.t() | nil,
  fields :: [String.t()] | nil,
  search_args :: bill_search_args(),
  opts :: [BexioApiClient.GlobalArguments.paging_arg()]
) ::
  {:ok, {[BexioApiClient.Purchase.Bill.t()], BexioApiClient.Global.Paging.t()}}
  | api_error_type()

Endpoint for retrieving Bills

Arguments:

  • :client - client to execute the HTTP request with
  • :limit - limit the number of results (default: 500, max: 2000)
  • :page - current page
  • :order - sorting order, example order=asc&order=desc
  • :sort - field to sort by, example sort=document_no
  • :search_term - term for which application will look for (minimum 3 signs, maximum 255 signs), example search_term=term
  • :fields - Items enum, fields for which search will be run (if no fields specified then searching will be done for all allowed fields)
  • :status - filter for Bill 'status' (DRAFTS: [DRAFT], TODO: [BOOKED, PARTIALLY_CREATED, CREATED, PARTIALLY_SENT, SENT, PARTIALLY_DOWNLOADED, DOWNLOADED, PARTIALLY_PAID, PARTIALLY_FAILED, FAILED], PAID: [PAID], OVERDUE: [BOOKED, PARTIALLY_CREATED, CREATED, PARTIALLY_SENT, SENT, PARTIALLY_DOWNLOADED, DOWNLOADED, PARTIALLY_PAID, PARTIALLY_FAILED, FAILED]) and for 'onlyOverdue' (DRAFTS: [FALSE], TODOS: [FALSE], PAID: [FALSE], OVERDUE: [TRUE]). Choosing OVERDUE means that only Bills with 'due_date' before now will be shown

fetch_expense(req, id)

@spec fetch_expense(req :: Req.Request.t(), id :: String.t()) ::
  {:ok, BexioApiClient.Purchase.Expense.t()} | api_error_type()

Endpoint for retrieving a single Expense by id

fetch_expense_document_number(req, document_no)

@spec fetch_expense_document_number(req :: Req.Request.t(), document_no :: String.t()) ::
  {:ok, BexioApiClient.Purchase.DocumentNumber.t()} | api_error_type()

Endpoint for validating whether an Expense document number is available or not.

fetch_expenses(req, search_args \\ [], opts \\ [])

Endpoint for retrieving Expenses

Arguments:

  • :client - client to execute the HTTP request with
  • :limit - limit the number of results (default: 100)
  • :page - current page
  • :order - sorting order, example order=asc&order=desc
  • :sort - field to sort by, example sort=document_no
  • :vendor - filter for Expense 'vendor', text containing in fields lastname_company and firstname_suffix
  • :gross_min/:gross_max - filter for Expense 'gross', the lowest/greatest accepted value
  • :net_min/:net_max - filter for Expense 'net', the lowest/greatest accepted value
  • :paid_on_start/:paid_on_end - filter for Expense 'paid_on', the earliest/latest accepted date
  • :created_at_start/:created_at_end - filter for Expense 'created_at', the earliest/latest accepted date
  • :title - filter for Expense 'title', text containing in field
  • :currency_code - filter for Expense 'currency_code', text containing in field
  • :document_no - filter for Expense 'document_no', text containing in field
  • :supplier_id - filter for Expense 'supplier_id'
  • :project_id - filter for Expense 'project_id'

fetch_outgoing_payment(req, id)

@spec fetch_outgoing_payment(req :: Req.Request.t(), id :: String.t()) ::
  {:ok, BexioApiClient.Purchase.OutgoingPayment.t()} | api_error_type()

Endpoint for retrieving a single Outgoing Payment by id

fetch_outgoing_payments(req, bill_id, opts \\ [])

@spec fetch_outgoing_payments(
  req :: Req.Request.t(),
  bill_id :: String.t(),
  opts :: [BexioApiClient.GlobalArguments.paging_arg()]
) ::
  {:ok,
   {[BexioApiClient.Purchase.OutgoingPayment.t()],
    BexioApiClient.Global.Paging.t()}}
  | api_error_type()

Endpoint for retrieving Outgoing Payments for a Bill

Arguments:

  • :bill_id - id of Bill for which Outgoing Payments were created
  • :limit - limit the number of results (default: 100)
  • :page - current page
  • :order - sorting order (:asc or :desc)
  • :sort - field to sort by

fetch_purchase_order(req, purchase_order_id)

@spec fetch_purchase_order(req :: Req.Request.t(), purchase_order_id :: pos_integer()) ::
  {:ok, BexioApiClient.Purchase.PurchaseOrder.t()} | api_error_type()

This action fetches a single purchase order

fetch_purchase_orders(req, opts \\ [])

@spec fetch_purchase_orders(
  req :: Req.Request.t(),
  opts :: [BexioApiClient.GlobalArguments.offset_arg()]
) :: {:ok, [BexioApiClient.Purchase.PurchaseOrder.t()]} | api_error_type()

Fetch a list of purchase orders.

Arguments:

  • :limit - limit the number of results (default: 500, max: 2000)
  • :offset - skip over a number of elements by specifying an offset value for the query
  • :order_by - defines the order of the results (:id, :total, :total_net, :total_gross, :updated_at), _asc/_desc can be appended to sort ascending (default) or descending

update_bill_status(req, id, status)

@spec update_bill_status(
  req :: Req.Request.t(),
  id :: String.t(),
  status :: bill_booking_status()
) ::
  {:ok, BexioApiClient.Purchase.Bill.t()} | api_error_type()

Endpoint for updating the status of a Bill (changing status to :booked or back to :draft).

Changing status to :booked triggers specific validations on the Bill (see the Bexio API documentation for PUT /4.0/purchase/bills/{id}/bookings/{status}).

update_expense_status(req, id, status)

@spec update_expense_status(
  req :: Req.Request.t(),
  id :: String.t(),
  status :: expense_booking_status()
) :: {:ok, BexioApiClient.Purchase.Expense.t()} | api_error_type()

Endpoint for updating the status of an Expense (changing status to :done or back to :draft).

Changing status triggers specific validations on the Expense (see the Bexio API documentation for PUT /4.0/expenses/{id}/bookings/{status}).