Project Expense¶
-
class
moco_wrapper.models.
ProjectExpense
(moco)¶ Class for handling additional project expenses.
An example for this would be when a third part product (one time cost) is bought for a specific customer project and then get billed to the project to regain the cost.
See also
moco_wrapper.models.ProjectRecurringExpense
for repeating expenses.-
create
(project_id: int, expense_date: datetime.date, title: str, quantity: float, unit: str, unit_price: float, unit_cost: float, description: str = None, billable: bool = True, budget_relevant: bool = False, custom_properties: dict = None)¶ Create a project expense.
Parameters: - project_id (int) – Id of the project to create the expense for
- expense_date (datetime.date, str) – Date of the expense
- title (str) – Expense title
- quantity (float) – Quantity (how much of
unit
was bought?) - unit (str) – Name of the unit (What was bought for the customer/project?)
- unit_price (float) – Price of the unit that will be billed to the customer/project
- unit_cost (float) – Cost that we had to pay
- description (str) – Descripion of the expense
- billable (bool) – If this expense billable (default True)
- budget_relevant (bool) – If this expense is budget relevant (default False)
- custom_properties (dict) – Additional fields as dictionary
Returns: The created expense object
-
create_bulk
(project_id: int, items: list)¶ Create an multiple expenses for a project.
Parameters: - project_id (int) – Id of the project to created the expenses for
- items (list) – Items to create bulk
Returns: The created entries
-
delete
(project_id: int, expense_id: int)¶ Deletes an expense.
Parameters: - project_id (int) – Id of the project the expense belongs to
- expense_id (int) – Id of the expense to delete
Returns: Empty response on success
-
disregard
(project_id: int, expense_ids: list, reason: str)¶ Disregard expenses
Parameters: - project_id (int) – Id of the project
- expense_ids (list) – Array of expense ids to disregard
- reason (str) – Reason for disregarding the expenses
Returns: Empty response on success
Example usage:
from moco_wrapper import Moco m = Moco() project_id = 22 expense_ids_to_disregard = [444, 522, 893] m.ProjectExpense.disregard( project_id, expense_ids_to_disregard, "Expenses already billed" )
-
get
(project_id: int, expense_id: int)¶ Retrieve a single expense object.
Parameters: - project_id (int) – Id of the project
- expense_id (int) – If of the expense to retrieve
Returns: Single expense object
-
getall
(from_date: datetime.date = None, to_date: datetime.date = None, sort_by: str = None, sort_order: str = 'asc', page: int = 1)¶ Get a list of all expenses.
Parameters: - from_date (datetime.date, str) – Start date
- to_date (datetime.date, str) – End date
- sort_by (str) – Sort results by field
- sort_order (str) – asc or desc (default asc)
- page (int) – Page number (default 1)
Returns: List of expense objects
-
getlist
(project_id: int, sort_by: str = None, sort_order: str = 'asc', page: int = 1)¶ Retrieve all expenses of a project.
Parameters: - project_id (int) – Id of the project
- sort_by (str) – Sort results by field
- sort_order (str) – asc or desc (default asc)
- page (int) – Page number (default 1)
Returns: List of expense objects
-
update
(project_id: int, expense_id: int, expense_date: datetime.date = None, title: str = None, quantity: float = None, unit: str = None, unit_price: float = None, unit_cost: float = None, description: str = None, billable: bool = None, budget_relevant: bool = None, custom_properties: dict = None)¶ Update an existing project expense.
Parameters: - project_id (int) – Id of the project
- expense_id (int) – id of the expense we want to update
- expense_date (datetime.date, str) – Date of the expense
- title (str) – Expense title
- quantity (float) – Quantity (how much of
unit
was bought?) - unit (str) – Name of the unit (What was bought for the customer/project?)
- unit_price (float) – Price of the unit that will be billed to the customer/project
- unit_cost (float) – Cost that we had to pay
- description (str) – Descripion of the expense
- billable (bool) – If this expense billable (default True)
- budget_relevant (bool) – If this expense is budget relevant (default False)
- custom_properties (dict) – Additional fields as dictionary
Returns: The updated expense object
-