コード例 #1
0
 def test_get_control_nominal_without_name(self):
     nominal = Nominal(name="Control")
     with mock.patch("nominals.models.Nominal.objects.get") as mocked_get:
         mocked_get.return_value = nominal
         control_nominal = ControlAccountInvoiceTransactionMixin.get_control_nominal(
             Nominal, control_nominal=nominal)
         self.assertEqual(control_nominal, nominal)
コード例 #2
0
ファイル: test_models.py プロジェクト: shoa3b/accounts
 def test_add_nominal_transactions(self):
     nominal = Nominal(name="nominal")
     header = PurchaseHeader(
         type="pi",
         supplier=self.supplier,
         ref="1",
         date=date.today(),
         period=self.period,
         total=100,
         paid=90,
     )
     line = PurchaseLine(
         header=header,
         line_no=1,
         description="1",
         type="pi"
     )
     g = NominalTransaction(
         module="PL",
         header=1,
         line=1,
         nominal=nominal,
         field="g",
         value=100
     )
     v = NominalTransaction(
         module="PL",
         header=1,
         line=1,
         nominal=nominal,
         field="v",
         value=20
     )
     t = NominalTransaction(
         module="PL",
         header=1,
         line=1,
         nominal=nominal,
         field="t",
         value=-120
     )
     nominal_trans = {
         "g": g,
         "v": v,
         "t": t
     }
     line.add_nominal_transactions(nominal_trans)
     self.assertEqual(
         line.goods_nominal_transaction,
         g
     )
     self.assertEqual(
         line.vat_nominal_transaction,
         v
     )
     self.assertEqual(
         line.total_nominal_transaction,
         t
     )
コード例 #3
0
 def test_bulk_update(self):
     nominal = Nominal(name="duh")
     nominal.save()
     tran = NominalTransaction(module="NL",
                               header=1,
                               line=1,
                               value=0,
                               date=date.today(),
                               period=self.period,
                               field="t",
                               nominal=nominal)
     tran.save()
     new_period = Period.objects.create(fy=self.fy,
                                        fy_and_period="202002",
                                        period="02",
                                        month_start=date(2020, 2, 29))
     tran.period = new_period
     NominalTransaction.objects.bulk_update([tran])
     tran.refresh_from_db()
     self.assertEqual(tran.period, new_period)
コード例 #4
0
 def test_audited_bulk_update_without_fields(self):
     d = date.today()
     h = NominalHeader(
         ref="1",
         period=self.period,
         date=d,
     )
     h.save()
     nominal = Nominal(name="duh")
     nominal.save()
     l = NominalLine(header=h,
                     line_no=1,
                     description="1",
                     nominal=nominal,
                     type="g")
     l.save()
     l.description = "2"
     NominalLine.objects.audited_bulk_update([l])
     l.refresh_from_db()
     self.assertEqual(l.description, "2")
     self.assertEqual(len(NominalLine.history.all()), 2)
コード例 #5
0
ファイル: test_views.py プロジェクト: shoa3b/accounts
 def test_obj_is_model_instance(self):
     n = Nominal(name="n")
     self.assertEqual(
         get_value(n, "name"),
         "n"
     )
コード例 #6
0
 def test_get_vat_nominal_without_name(self):
     nominal = Nominal(name="Vat Control")
     vat_nominal = ControlAccountInvoiceTransactionMixin.get_vat_nominal(
         Nominal, vat_nominal=nominal)
     self.assertEqual(vat_nominal, nominal)