first commit
This commit is contained in:
2
modules/project_revenue/tests/__init__.py
Normal file
2
modules/project_revenue/tests/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
133
modules/project_revenue/tests/scenario_project_revenue.rst
Normal file
133
modules/project_revenue/tests/scenario_project_revenue.rst
Normal file
@@ -0,0 +1,133 @@
|
||||
========================
|
||||
Project Revenue Scenario
|
||||
========================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('project_revenue', create_company)
|
||||
|
||||
Create customer::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.save()
|
||||
|
||||
Create employee::
|
||||
|
||||
>>> Employee = Model.get('company.employee')
|
||||
>>> employee = Employee()
|
||||
>>> party = Party(name='Employee')
|
||||
>>> party.save()
|
||||
>>> employee.party = party
|
||||
>>> _ = employee.cost_prices.new(cost_price=Decimal('10.00'))
|
||||
>>> employee.save()
|
||||
>>> employee.cost_price
|
||||
Decimal('10.00')
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> hour, = ProductUom.find([('name', '=', 'Hour')])
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Service'
|
||||
>>> template.default_uom = hour
|
||||
>>> template.type = 'service'
|
||||
>>> template.list_price = Decimal('20')
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Service'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'service'
|
||||
>>> template.list_price = Decimal('80')
|
||||
>>> template.save()
|
||||
>>> package, = template.products
|
||||
|
||||
Create a Project::
|
||||
|
||||
>>> Project = Model.get('project.work')
|
||||
>>> project = Project()
|
||||
>>> project.name = 'Test effort'
|
||||
>>> project.type = 'project'
|
||||
>>> project.party = customer
|
||||
>>> project.timesheet_available = True
|
||||
>>> project.product = product
|
||||
>>> project.list_price
|
||||
Decimal('20.0000')
|
||||
>>> project.effort_duration = datetime.timedelta(hours=1)
|
||||
>>> task = project.children.new()
|
||||
>>> task.name = 'Task 1'
|
||||
>>> task.type = 'task'
|
||||
>>> task.timesheet_available = True
|
||||
>>> task.product = product
|
||||
>>> task.list_price
|
||||
Decimal('20.0000')
|
||||
>>> task.effort_duration = datetime.timedelta(hours=5)
|
||||
>>> task_no_effort = project.children.new()
|
||||
>>> task_no_effort.name = "Task 2"
|
||||
>>> task_no_effort.type = 'task'
|
||||
>>> task_no_effort.effort_duration = None
|
||||
>>> task_no_effort.product = package
|
||||
>>> task_no_effort.list_price
|
||||
Decimal('80.0000')
|
||||
>>> project.save()
|
||||
>>> task, task_no_effort = project.children
|
||||
|
||||
Check project revenue and cost::
|
||||
|
||||
>>> project.revenue
|
||||
Decimal('200.00')
|
||||
>>> task.revenue
|
||||
Decimal('100.00')
|
||||
>>> task_no_effort.revenue
|
||||
Decimal('80.00')
|
||||
>>> project.cost
|
||||
Decimal('0.00')
|
||||
>>> task.cost
|
||||
Decimal('0.00')
|
||||
>>> task_no_effort.cost
|
||||
Decimal('0.00')
|
||||
|
||||
Create timesheets::
|
||||
|
||||
>>> TimesheetLine = Model.get('timesheet.line')
|
||||
>>> line = TimesheetLine()
|
||||
>>> line.employee = employee
|
||||
>>> line.duration = datetime.timedelta(hours=3)
|
||||
>>> line.work, = task.timesheet_works
|
||||
>>> line.save()
|
||||
>>> line = TimesheetLine()
|
||||
>>> line.employee = employee
|
||||
>>> line.duration = datetime.timedelta(hours=2)
|
||||
>>> line.work, = project.timesheet_works
|
||||
>>> line.save()
|
||||
|
||||
Cost should take in account timesheet lines::
|
||||
|
||||
>>> project.reload()
|
||||
>>> task, task_no_effort = project.children
|
||||
>>> project.revenue
|
||||
Decimal('200.00')
|
||||
>>> task.revenue
|
||||
Decimal('100.00')
|
||||
>>> task_no_effort.revenue
|
||||
Decimal('80.00')
|
||||
>>> project.cost
|
||||
Decimal('50.00')
|
||||
>>> task.cost
|
||||
Decimal('30.00')
|
||||
>>> task_no_effort.cost
|
||||
Decimal('0.00')
|
||||
14
modules/project_revenue/tests/test_module.py
Normal file
14
modules/project_revenue/tests/test_module.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.modules.company.tests import CompanyTestMixin
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class ProjectRevenueTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
'Test ProjectRevenue module'
|
||||
module = 'project_revenue'
|
||||
extras = ['purchase']
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/project_revenue/tests/test_scenario.py
Normal file
8
modules/project_revenue/tests/test_scenario.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.tests.test_tryton import load_doc_tests
|
||||
|
||||
|
||||
def load_tests(*args, **kwargs):
|
||||
return load_doc_tests(__name__, __file__, *args, **kwargs)
|
||||
Reference in New Issue
Block a user