Exemplo n.º 1
0
 def test_interfaces(self):
     self.assertTrue(verifyObject(ITask, Task()))
     self.assertTrue(verifyObject(IValidatedTask, Estimation()))
     self.assertTrue(verifyObject(IPaidTask, Invoice()))
     self.assertTrue(verifyObject(IPaidTask, CancelInvoice()))
     self.assertTrue(verifyObject(IInvoice, Invoice()))
     self.assertTrue(verifyObject(IInvoice, CancelInvoice()))
Exemplo n.º 2
0
def test_get_number():
    cinv = CancelInvoice()
    cinv.project = MagicMock(code="PRO1")
    cinv.customer = MagicMock(code="CLI1")
    cinv.taskDate = datetime.date(1969, 07, 31)
    cinv.set_sequence_number(15)
    cinv.set_number()
    assert cinv.number == u"PRO1_CLI1_A15_0769"
Exemplo n.º 3
0
def cancelinvoice(project, user, customer, company, phase):
    cancelinvoice = CancelInvoice(
        company,
        customer,
        project,
        phase,
        user,
    )
    cancelinvoice.address = customer.address
    cancelinvoice.date = datetime.date(2012, 12, 10)

    return cancelinvoice
Exemplo n.º 4
0
 def test_get_number(self):
     cinv = CancelInvoice()
     cinv.project = MagicMock(code="PRO1")
     cinv.customer = MagicMock(code="CLI1")
     cinv.taskDate = datetime.date(1969, 07, 31)
     cinv.set_sequenceNumber(15)
     cinv.set_number()
     self.assertEqual(cinv.number, u"PRO1_CLI1_A15_0769")
Exemplo n.º 5
0
    def submit_success(self, appstruct):
        log.debug("Submitting cancelinvoice add")
        appstruct = get_cancel_invoice_dbdatas(appstruct)

        customer_id = appstruct["task"]['customer_id']
        customer = Customer.get(customer_id)

        cinvoice = CancelInvoice(
            self.context.company,
            customer,
            self.context,
            self.context.phases[0],
            self.request.user,
        )
        cinvoice = merge_session_with_post(cinvoice, appstruct["task"])
        try:
            cinvoice = self.set_task_status(cinvoice)
            cinvoice.invoice.check_resulted(user_id=self.request.user.id)
            self.dbsession.merge(cinvoice.invoice)
            # Line handling
            cinvoice = add_lines_to_cancelinvoice(cinvoice, appstruct)
            self.dbsession.add(cinvoice)
            self.dbsession.flush()
            self.session.flash(u"L'avoir a bien été ajoutée.")
        except Forbidden, err:
            self.request.session.flash(err.message, queue='error')
def upgrade():
    logger = logging.getLogger("alembic.add_compte_cg")
    op.add_column("tva", sa.Column("compte_cg", sa.String(125), default=""))
    op.add_column("tva", sa.Column("code", sa.String(125), default=""))
    op.add_column("company", sa.Column("contribution", sa.Integer))
    op.add_column("customer",
            sa.Column("compte_cg", sa.String(125), default=""))
    op.add_column("customer",
            sa.Column("compte_tiers", sa.String(125), default=""))

    # Ajout du code produit au ligne des factures et avoirs
    for table in ("invoice_line", "cancelinvoice_line"):
        op.add_column(table,
            sa.Column("product_id", sa.Integer, default=""))

    # Ajout d'un tag "exporte" aux factures et avoirs
    for table in ("invoice", "cancelinvoice"):
        op.add_column(table,
            sa.Column("exported",
                sa.Boolean()))
    # Les factures et avoirs deja validees sont considerees comme exportees
    logger.warn(u"On tag des factures comme exportees")
    for invoice in Invoice.query():
        if invoice.CAEStatus in Invoice.valid_states:
            invoice.exported = True
            DBSESSION().merge(invoice)
            logger.warn(u"officialNumber : {0.officialNumber} \
{0.financial_year}".format(invoice))

    for cinv in CancelInvoice.query():
        if cinv.CAEStatus in CancelInvoice.valid_states:
            cinv.exported = True
            DBSESSION().merge(cinv)
            logger.warn(u"officialNumber : {0.officialNumber} \
{0.financial_year}".format(cinv))
def upgrade():
    logger = logging.getLogger("alembic.add_compte_cg")
    op.add_column("tva", sa.Column("compte_cg", sa.String(125), default=""))
    op.add_column("tva", sa.Column("code", sa.String(125), default=""))
    op.add_column("company", sa.Column("contribution", sa.Integer))
    op.add_column("customer", sa.Column("compte_cg",
                                        sa.String(125),
                                        default=""))
    op.add_column("customer",
                  sa.Column("compte_tiers", sa.String(125), default=""))

    # Ajout du code produit au ligne des factures et avoirs
    for table in ("invoice_line", "cancelinvoice_line"):
        op.add_column(table, sa.Column("product_id", sa.Integer, default=""))

    # Ajout d'un tag "exporte" aux factures et avoirs
    for table in ("invoice", "cancelinvoice"):
        op.add_column(table, sa.Column("exported", sa.Boolean()))
    # Les factures et avoirs deja validees sont considerees comme exportees
    logger.warn(u"On tag des factures comme exportees")
    for invoice in Invoice.query():
        if invoice.CAEStatus in Invoice.valid_states:
            invoice.exported = True
            DBSESSION().merge(invoice)
            logger.warn(u"officialNumber : {0.officialNumber} \
{0.financial_year}".format(invoice))

    for cinv in CancelInvoice.query():
        if cinv.CAEStatus in CancelInvoice.valid_states:
            cinv.exported = True
            DBSESSION().merge(cinv)
            logger.warn(u"officialNumber : {0.officialNumber} \
{0.financial_year}".format(cinv))
Exemplo n.º 8
0
    def turnovers(self):
        """
            Return the realised turnovers
        """
        result = dict(year_total=0)
        for month in range(1, 13):

            invoices = Invoice.query().join(Task.project)
            invoices = invoices.filter(
                Project.company_id == self.request.context.id)
            date_condition = and_(
                extract('year', Invoice.taskDate) == self.year,
                extract('month', Invoice.taskDate) == month,
                Invoice.financial_year == self.year,
            )
            if month != 12:
                invoices = invoices.filter(date_condition)
            else:
                # for december, we also like to have invoices edited in january
                # and reported to the previous comptability year
                reported_condition = and_(
                    Invoice.financial_year == self.year,
                    extract('year', Invoice.taskDate) != self.year,
                )
                invoices = invoices.filter(
                    or_(date_condition, reported_condition))

            invoices = invoices.filter(
                Invoice.CAEStatus.in_(Invoice.valid_states))
            invoice_sum = sum([invoice.total_ht() for invoice in invoices])

            cinvoices = CancelInvoice.query().join(Task.project)
            cinvoices = cinvoices.filter(
                Project.company_id == self.request.context.id)
            date_condition = and_(
                extract('year', CancelInvoice.taskDate) == self.year,
                extract('month', CancelInvoice.taskDate) == month,
                CancelInvoice.financial_year == self.year,
            )
            if month != 12:
                cinvoices = cinvoices.filter(date_condition)
            else:
                reported_condition = and_(
                    CancelInvoice.financial_year == self.year,
                    extract('year', CancelInvoice.taskDate) != self.year,
                )
                cinvoices = cinvoices.filter(
                    or_(date_condition, reported_condition))

            cinvoices = cinvoices.filter(
                CancelInvoice.CAEStatus.in_(CancelInvoice.valid_states))
            cinvoice_sum = sum([cinvoice.total_ht() for cinvoice in cinvoices])

            result[month] = invoice_sum + cinvoice_sum
            result['year_total'] += result[month]
        return result
Exemplo n.º 9
0
def cancelinvoice(project, user, customer, company, phase):
    task = CancelInvoice(
        company,
        customer,
        project,
        phase,
        user,
    )
    for key, value in TASK.items():
        setattr(task, key, value)
    return task
Exemplo n.º 10
0
    def turnovers(self):
        """
            Return the realised turnovers
        """
        result = dict(year_total=0)
        for month in range(1, 13):

            invoices = Invoice.query().join(Project)
            invoices = invoices.filter(
                Project.company_id==self.request.context.id
                )
            invoices = invoices.filter(
                extract('year', Invoice.taskDate)==self.year
                )
            invoices = invoices.filter(
                extract('month', Invoice.taskDate)==month
                )
            invoices = invoices.filter(
                Invoice.CAEStatus.in_(Invoice.valid_states)
                )
            invoice_sum = sum([invoice.total_ht() for invoice in invoices])

            cinvoices = CancelInvoice.query().join(Project)
            cinvoices = cinvoices.filter(
                    Project.company_id==self.request.context.id
                    )
            cinvoices = cinvoices.filter(
                    extract('year', CancelInvoice.taskDate)==self.year
                    )
            cinvoices = cinvoices.filter(
                    extract('month', CancelInvoice.taskDate)==month
                    )
            cinvoices = cinvoices.filter(
                    CancelInvoice.CAEStatus.in_(CancelInvoice.valid_states)
                    )
            cinvoice_sum = sum([cinvoice.total_ht() for cinvoice in cinvoices])

            result[month] = invoice_sum + cinvoice_sum
            result['year_total'] += result[month]
        return result
Exemplo n.º 11
0
 def test_set_name(self):
     cinv = CancelInvoice()
     cinv.set_sequenceNumber(5)
     cinv.set_name()
     self.assertEqual(cinv.name, u"Avoir 5")
Exemplo n.º 12
0
def cancelinvoice(project, user, customer, company, phase):
    cancelinvoice = CancelInvoice(company, customer, project, phase, user)
    cancelinvoice.address = customer.address
    cancelinvoice.date = datetime.date(2012, 12, 10)

    return cancelinvoice
Exemplo n.º 13
0
def test_set_name():
    cinv = CancelInvoice()
    cinv.set_sequence_number(5)
    cinv.set_name()
    assert cinv.name == u"Avoir 5"
Exemplo n.º 14
0
    def turnovers(self):
        """
            Return the realised turnovers
        """
        result = dict(year_total=0)
        for month in range(1, 13):

            invoices = Invoice.query().join(Task.project)
            invoices = invoices.filter(
                Project.company_id==self.request.context.id
                )
            date_condition = and_(
                    extract('year', Invoice.taskDate)==self.year,
                    extract('month', Invoice.taskDate)==month,
                    Invoice.financial_year==self.year,
                    )
            if month != 12:
                invoices = invoices.filter(date_condition)
            else:
                # for december, we also like to have invoices edited in january
                # and reported to the previous comptability year
                reported_condition = and_(
                        Invoice.financial_year==self.year,
                        extract('year', Invoice.taskDate)!=self.year,
                    )
                invoices = invoices.filter(
                        or_(date_condition, reported_condition)
                    )

            invoices = invoices.filter(
                Invoice.CAEStatus.in_(Invoice.valid_states)
                )
            invoice_sum = sum([invoice.total_ht() for invoice in invoices])

            cinvoices = CancelInvoice.query().join(Task.project)
            cinvoices = cinvoices.filter(
                    Project.company_id==self.request.context.id
                    )
            date_condition = and_(
                    extract('year', CancelInvoice.taskDate)==self.year,
                    extract('month', CancelInvoice.taskDate)==month,
                    CancelInvoice.financial_year==self.year,
                    )
            if month != 12:
                cinvoices = cinvoices.filter(date_condition)
            else:
                reported_condition = and_(
                    CancelInvoice.financial_year==self.year,
                    extract('year', CancelInvoice.taskDate)!=self.year,
                    )
                cinvoices = cinvoices.filter(
                        or_(date_condition, reported_condition)
                        )

            cinvoices = cinvoices.filter(
                    CancelInvoice.CAEStatus.in_(CancelInvoice.valid_states)
                    )
            cinvoice_sum = sum([cinvoice.total_ht() for cinvoice in cinvoices])

            result[month] = invoice_sum + cinvoice_sum
            result['year_total'] += result[month]
        return result
Exemplo n.º 15
0
def test_set_name():
    cinv = CancelInvoice()
    cinv.set_sequence_number(5)
    cinv.set_name()
    assert cinv.name == u"Avoir 5"