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, service_period_from: datetime.date = None, service_period_to: datetime.date = None, custom_properties: dict = None, file: moco_wrapper.util.io.file.File = 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) – Description of the expense (default
None
) - billable (bool) – If this expense billable (default
True
) - budget_relevant (bool) – If this expense is budget relevant (default
False
) - service_period_from (datetime.date, str) – Service period start date (default
None
) - service_period_to (datetime.date, str) – Service period end date (default
None
) - custom_properties (dict) – Additional fields as dictionary (default
None
) - file (
moco_wrapper.util.io.File
) – File attached to the expense (defaultNone
)
Returns: The created expense object
Return type:
-
create_bulk
(project_id: int, items: list)¶ Create 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
Return type:
-
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
Return type:
-
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: List of disregarded expense ids
Return type: Example usage:
from moco_wrapper import Moco m = Moco() m.ProjectExpense.disregard( project_id=22, expense_ids=[444, 522, 893], reason="Expenses already billed" )
-
static
endpoints
() → List[moco_wrapper.util.endpoint.endpoint.Endpoint]¶ Returns all endpoints associated with the model
Returns: List of Endpoint objects Return type: moco_wrapper.util.endpoint.Endpoint
-
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
Return type:
-
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 (default
None
) - to_date (datetime.date, str) – End date (default
None
) - sort_by (str) – Sort results by field (default
None
) - sort_order (str) – asc or desc (default
"asc"
) - page (int) – Page number (default
1
)
Returns: List of expense objects
Return type: - from_date (datetime.date, str) – Start date (default
-
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 (default
None
) - sort_order (str) – asc or desc (default
"asc"
) - page (int) – Page number (default
1
)
Returns: List of expense objects
Return type:
-
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, service_period_from: datetime.date = None, service_period_to: datetime.date = 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 (default
None
) - title (str) – Expense title (default
None
) - quantity (float) – Quantity (how much of
unit
was bought?) (defaultNone
) - unit (str) – Name of the unit (What was bought for the customer/project?) (default
None
) - unit_price (float) – Price of the unit that will be billed to the customer/project (default
None
) - unit_cost (float) – Cost that we had to pay (default
None
) - description (str) – Description of the expense (default
None
) - billable (bool) – If this expense billable (default
None
) - budget_relevant (bool) – If this expense is budget relevant (default
None
) - service_period_from (datetime.date, str) – Service period start date (default
None
) - service_period_to (datetime.date, str) – Service period end date (default
None
) - custom_properties (dict) – Additional fields as dictionary (default
None
)
Returns: The updated expense object
Return type:
-