def add_lines_to_estimation(task, appstruct):
    """
        Add the lines to the current estimation
    """
    task.default_line_group.lines = []
    task.line_groups = [task.default_line_group]
    task.discounts = []
    task.payment_lines = []

    for line in appstruct['payment_lines']:
        task.payment_lines.append(PaymentLine(**line))

    for group in appstruct['groups']:
        lines = group.pop('lines', [])
        group = TaskLineGroup(**group)
        for line in lines:
            group.lines.append(TaskLine(**line))
        task.line_groups.append(group)

    for line in appstruct['lines']:
        task.default_line_group.lines.append(TaskLine(**line))

    for line in appstruct.get('discounts', []):
        task.discounts.append(DiscountLine(**line))

    return task
Exemple #2
0
def discount_line(dbsession, tva):
    from autonomie.models.task.task import DiscountLine
    discount = DiscountLine(description="Discount",
                            amount=1000000,
                            tva=tva.value)
    dbsession.add(discount)
    dbsession.flush()
    return discount
Exemple #3
0
def add_lines_to_invoice(task, appstruct):
    """
        Add the lines to the current invoice
    """
    # Needed for edition only
    task.lines = []
    task.discounts = []
    for line in appstruct['lines']:
        task.lines.append(InvoiceLine(**line))
    for line in appstruct.get('discounts', []):
        task.discounts.append(DiscountLine(**line))
    return task
Exemple #4
0
def add_lines_to_estimation(task, appstruct):
    """
        Add the lines to the current estimation
    """
    task.lines = []
    task.discounts = []
    task.payment_lines = []
    for line in appstruct['payment_lines']:
        task.payment_lines.append(PaymentLine(**line))
    for line in appstruct['lines']:
        task.lines.append(EstimationLine(**line))
    for line in appstruct.get('discounts', []):
        task.discounts.append(DiscountLine(**line))
    return task