def downgrade():
    for p in PaymentMode.query():
        DBSESSION().delete(p)
    for p in Payment.query():
        if p.mode == u"par chèque":
            p.mode = u"cheque"
        elif p.mode == u"par virement":
            p.mode = u"virement"
        elif p.mode == u"en liquide":
            p.mode = u"liquide"
        else:
            p.mode = "inconnu"
        DBSESSION().merge(p)
Пример #2
0
def test_gen_cancelinvoice_with_payment(dbsession, full_invoice, tva, mode,
                                        user):
    from autonomie.models.task.invoice import Payment
    payment = Payment(mode=mode.label, amount=10000000, tva=tva)
    full_invoice.payments = [payment]
    cinv = full_invoice.gen_cancelinvoice(user)
    assert len(cinv.default_line_group.lines) == len(
        full_invoice.default_line_group.lines) + len(
            full_invoice.discounts) + 1

    # Le paiement est indiqué ttc, ici on a le HT (tva inversée)
    assert cinv.default_line_group.lines[-1].cost == 8333333
    assert cinv.default_line_group.lines[-1].tva == 2000
def downgrade():
    for p in PaymentMode.query():
        DBSESSION().delete(p)
    for p in Payment.query():
        if p.mode == u"par chèque":
            p.mode = u"cheque"
        elif p.mode == u"par virement":
            p.mode = u"virement"
        elif p.mode == u"en liquide":
            p.mode = u"liquide"
        else:
            p.mode = "inconnu"
        DBSESSION().merge(p)
Пример #4
0
def downgrade():
    from autonomie.models.task.invoice import PaymentMode, Payment
    for p in PaymentMode.query():
        DBSESSION().delete(p)
    for p in Payment.query():
        if p.mode == u"par chèque":
            p.mode = u"cheque"
        elif p.mode == u"par virement":
            p.mode = u"virement"
        elif p.mode == u"en liquide":
            p.mode = u"liquide"
        else:
            p.mode = "inconnu"
        DBSESSION().merge(p)
def upgrade():
    for payment in Payment.query():
        if payment.mode in (u"cheque", u"CHEQUE"):
            payment.mode = u"par chèque"
        elif payment.mode in (u"virement", u"VIREMENT"):
            payment.mode = u"par virement"
        elif payment.mode in (u"liquide", u"LIQUIDE"):
            payment.mode = u"en liquide"
        else:
            payment.mode = "mode de paiement inconnu"
        DBSESSION().merge(payment)

    for mode in (u"par chèque", u"par virement", u"en liquide"):
        pmode = PaymentMode(label=mode)
        DBSESSION().add(pmode)
def upgrade():
    for payment in Payment.query():
        if payment.mode in (u"cheque", u"CHEQUE"):
            payment.mode = u"par chèque"
        elif payment.mode in (u"virement", u"VIREMENT"):
            payment.mode = u"par virement"
        elif payment.mode in (u"liquide", u"LIQUIDE"):
            payment.mode = u"en liquide"
        else:
            payment.mode = "mode de paiement inconnu"
        DBSESSION().merge(payment)

    for mode in (u"par chèque", u"par virement", u"en liquide"):
        pmode = PaymentMode(label=mode)
        DBSESSION().add(pmode)
def upgrade():
    from autonomie.models.task.invoice import ManualInvoice
    # Fix an error in table names for some installations
    class OldManualInvoice(DBBASE):
        """
            Modèle pour les factures manuelles (ancienne version)
        """
        __tablename__ = 'manualinvoice'
        id = Column('id', BigInteger, primary_key=True)
        officialNumber = Column('sequence_id', BigInteger)
        description = Column('libelle', String(255))
        montant_ht = Column("montant_ht", Integer)
        tva = Column("tva", Integer)
        payment_ok = Column("paiement_ok", Integer)
        statusDate = Column("paiement_date", Date())
        paymentMode = Column("paiement_comment", String(255))
        taskDate = Column("date_emission", Date(),
                                    default=datetime.datetime.now)
        created_at = Column("created_at", DateTime,
                                        default=datetime.datetime.now)
        updated_at = Column("updated_at", DateTime,
                                        default=datetime.datetime.now,
                                        onupdate=datetime.datetime.now)
        client_id = Column('client_id', Integer,
                                ForeignKey('customer.code'))

        company_id = Column('compagnie_id', Integer,
                                ForeignKey('company.id'))


    if not table_exists("manualinvoice"):
        force_rename_table('manual_invoice', 'manualinvoice')
    from autonomie_base.models.base import DBSESSION
    for manualinv in OldManualInvoice.query().all():
        m = ManualInvoice()
        m.montant_ht = manualinv.montant_ht
        m.tva = manualinv.tva
        m.client_id = manualinv.client_id
        m.company_id = manualinv.company_id
        m.description = manualinv.description
        m.CAEStatus = 'valid'
        if manualinv.payment_ok == '1' or manualinv.montant_ht < 0:
            m.CAEStatus = "resulted"
        if manualinv.montant_ht < 0:
            if manualinv.paymentMode == u"chèque":
                payment_mode = "CHEQUE"
            elif manualinv.paymentMode == u"virement":
                payment_mode = "VIREMENT"
            else:
                payment_mode = None
            if payment_mode:
                # We don't care about amounts since there is only one payment
                payment = Payment(mode=payment_mode, date=manualinv.statusDate,
                                amount=0)
                m.payments.append(payment)
        m.statusDate = manualinv.statusDate
        m.taskDate = manualinv.taskDate
        m.creationDate = manualinv.created_at
        m.updateDate = manualinv.updated_at
        m.phase_id = 0
        m.name = u"Facture manuelle %s" % manualinv.officialNumber
        m.officialNumber = manualinv.officialNumber
        m.owner_id = 0
        DBSESSION.add(m)
Пример #8
0
def test_payment_get_amount():
    from autonomie.models.task.invoice import Payment
    payment = Payment(amount=1895000, mode="test")
    assert payment.get_amount() == 1895000
Пример #9
0
def test_payment_get_amount():
    from autonomie.models.task.invoice import Payment
    payment = Payment(amount=1895000, mode="test")
    assert payment.get_amount() == 1895000