Exemple #1
0
 def test_get_products(self):
     obj = SageInvoice(invoice=MagicMock())
     obj.products['1'] = {'test_key':'test'}
     self.assertTrue(
             obj.get_product('1', 'dontcare', 'dontcare').has_key('test_key'))
     self.assertEqual(len(obj.get_product('2', 'tva_compte_cg',
         'tva_code').keys()), 3)
Exemple #2
0
    def _test_product_book_entry(
            self,
            method,
            exp_analytic_line,
            prod_cg='P0001'):
        """
        test a book_entry output (one of a product)
        """
        tvas, products, invoice = prepare()
        config = get_config()
        wrapped_invoice = SageInvoice(invoice=invoice, compte_cgs=config)
        wrapped_invoice.populate()
        book_entry_factory = self.factory(config)
        book_entry_factory.set_invoice(wrapped_invoice)
        product = wrapped_invoice.products[prod_cg]

        general_line, analytic_line = getattr(book_entry_factory, method)(product)

        exp_analytic_line['date'] = '020213'
        exp_analytic_line['num_facture'] = 'INV_001'
        exp_analytic_line['code_journal'] = 'CODE_JOURNAL'
        exp_general_line = exp_analytic_line.copy()
        exp_analytic_line['type_'] = 'A'
        exp_general_line['type_'] = 'G'
        exp_general_line.pop('num_analytique', '')

        self.assertEqual(general_line, exp_general_line)
        self.assertEqual(analytic_line, exp_analytic_line)
Exemple #3
0
 def test_populate_invoice_lines(self):
     tvas, products, invoice = prepare()
     wrapper = SageInvoice(invoice=invoice)
     wrapper._populate_invoice_lines()
     wrapper._round_products()
     self.assertEqual(wrapper.products.keys(), ['P0001', 'P0002'])
     self.assertEqual(wrapper.products['P0001']['ht'], 20000)
     self.assertEqual(wrapper.products['P0001']['tva'], 3920)
     self.assertEqual(wrapper.products['P0002']['ht'], 10000)
     self.assertEqual(wrapper.products['P0002']['tva'], 700)
Exemple #4
0
 def test_populate_expenses(self):
     tvas, products, invoice = prepare()
     wrapper = SageInvoice(invoice=invoice, compte_cgs=get_config())
     wrapper.expense_tva_compte_cg = "TVA0001"
     wrapper._populate_expenses()
     wrapper._round_products()
     self.assertEqual(wrapper.products.keys(), ['CG_FA'])
     self.assertEqual(wrapper.products['CG_FA']['ht'], 20000)
     self.assertEqual(wrapper.products['CG_FA']['tva'], 1960)
def sageinvoice_discount(def_tva, invoice_discount, app_config):
    return SageInvoice(invoice=invoice_discount,
                       config=app_config,
                       default_tva=def_tva)
def sageinvoice_bug400(def_tva, invoice_bug400, app_config):
    return SageInvoice(
        invoice=invoice_bug400,
        config=app_config,
        default_tva=def_tva,
    )
Exemple #7
0
    def test_populate_discount_lines(self):
        tvas, products, invoice = prepare(discount=True)
        wrapper = SageInvoice(invoice=invoice, compte_cgs=get_config())
        wrapper._populate_discounts()
        wrapper._round_products()
        self.assertEqual(wrapper.products.keys(), ['CG_RRR'])
        self.assertEqual(
                wrapper.products['CG_RRR']['code_tva'],
                "CODE_TVA_RRR")
        self.assertEqual(
                wrapper.products['CG_RRR']['compte_cg_tva'],
                "CG_TVA_RRR")
        self.assertEqual(wrapper.products['CG_RRR']['ht'], 20000)
        self.assertEqual(wrapper.products['CG_RRR']['tva'], 2660)

        # If one of compte_cg_tva_rrr or code_tva_rrr is not def
        # No entry should be returned
        config = get_config()
        config.pop("compte_cg_tva_rrr")
        wrapper = SageInvoice(invoice=invoice, compte_cgs=config)
        wrapper._populate_discounts()
        self.assertEqual(wrapper.products.keys(), [])

        config = get_config()
        config.pop("code_tva_rrr")
        wrapper = SageInvoice(invoice=invoice, compte_cgs=config)
        wrapper._populate_discounts()
        self.assertEqual(wrapper.products.keys(), [])
Exemple #8
0
def sageinvoice_discount(def_tva, invoice_discount):
    return SageInvoice(invoice=invoice_discount,
                       config=get_config(),
                       default_tva=def_tva)
Exemple #9
0
def sageinvoice(def_tva, invoice):
    return SageInvoice(
        invoice=invoice,
        config=get_config(),
        default_tva=def_tva,
    )