コード例 #1
0
ファイル: estimation.py プロジェクト: SophieWeb/autonomie
 def _get_task_line(cls, cost, description, tva):
     from autonomie.models.task.task import TaskLine
     from autonomie.models.tva import Product
     line = TaskLine(cost=cost,
                     description=description,
                     tva=tva,
                     quantity=1)
     line.product_id = Product.first_by_tva_value(tva)
     return line
コード例 #2
0
ファイル: test_task.py プロジェクト: Swannbm/autonomie
def test_task_line_from_sale_product(sale_product):
    from autonomie.models.task.task import TaskLine
    t = TaskLine.from_sale_product(sale_product)
    assert t.tva == sale_product.tva
    assert t.cost == 100000 * sale_product.value
    assert t.description == sale_product.description
    assert t.unity == sale_product.unity
コード例 #3
0
def test_task_line_from_sale_product(sale_product):
    from autonomie.models.task.task import TaskLine
    t = TaskLine.from_sale_product(sale_product)
    assert t.tva == sale_product.tva
    assert t.cost == 100000 * sale_product.value
    assert t.description == sale_product.description
    assert t.unity == sale_product.unity
    assert t.product_id == sale_product.product_id
コード例 #4
0
def task_line(dbsession, unity, tva, product, task_line_group):
    from autonomie.models.task.task import TaskLine
    line = TaskLine(
        cost=1250000,
        quantity=1,
        unity=unity.label,
        tva=2000,
        product_id=product.id,
        group=task_line_group,
    )
    dbsession.add(line)
    dbsession.flush()
    return line
コード例 #5
0
def task_line(dbsession, unity, tva, product, task_line_group):
    from autonomie.models.task.task import TaskLine
    # TTC = 120 €
    line = TaskLine(
        description=u"Task Line description",
        cost=10000000,
        quantity=1,
        unity=unity.label,
        tva=tva.value,
        product_id=product.id,
        group=task_line_group,
    )
    dbsession.add(line)
    dbsession.flush()
    return line
コード例 #6
0
 def submit_success(self, appstruct):
     for line in appstruct['lines']:
         line_id = line.get('id')
         product_id = line.get('product_id')
         if line_id is not None and product_id is not None:
             taskline = TaskLine.get(line_id)
             if taskline.task == self.context:
                 taskline.product_id = product_id
                 self.request.dbsession.merge(taskline)
             else:
                 logger.error(
                     u"Possible break in attempt: trying to set product id "
                     u"on the wrong task line (not belonging to this task)")
     return HTTPFound(
         self.request.route_path(
             '/%ss/{id}' % self.context.type_,
             id=self.context.id,
         ))
コード例 #7
0
ファイル: views.py プロジェクト: CroissanceCommune/autonomie
 def submit_success(self, appstruct):
     for line in appstruct['lines']:
         line_id = line.get('id')
         product_id = line.get('product_id')
         if line_id is not None and product_id is not None:
             taskline = TaskLine.get(line_id)
             if taskline.task == self.context:
                 taskline.product_id = product_id
                 self.request.dbsession.merge(taskline)
             else:
                 logger.error(
                     u"Possible break in attempt: trying to set product id "
                     u"on the wrong task line (not belonging to this task)"
                 )
     return HTTPFound(
         self.request.route_path(
             '/%ss/{id}' % self.context.type_,
             id=self.context.id,
         )
     )
コード例 #8
0
 def _get_task_line(cls, cost, description, tva):
     from autonomie.models.task.task import TaskLine
     from autonomie.models.tva import Product
     line = TaskLine(cost=cost, description=description, tva=tva, quantity=1)
     line.product_id = Product.first_by_tva_value(tva)
     return line