Example #1
0
 def create_transaction(self, amount = 10, description = "spent dough", user_email="*****@*****.**"):
     transaction = Transaction()
     transaction.amount = Decimal(amount)
     transaction.description = description
     transaction.user = User.objects.create_user(user_email)
     transaction.save()
     return transaction
Example #2
0
    def test_sum_one(self):
        mock = Transaction()
        mock.amount = Decimal(10)
        mock.description = 'Test'
        mock.user = User.objects.create_user('*****@*****.**')
        mock.save()

        actual = Transaction.objects.total()
        self.assertEqual(actual, to_decimal(10))
Example #3
0
    def test_sum_one(self):
        mock = Transaction()
        mock.amount = Decimal(10)
        mock.description = 'Test'
        mock.user = User.objects.create_user('*****@*****.**')
        mock.save()

        actual = Transaction.objects.total()
        self.assertEqual(actual, to_decimal(10))
Example #4
0
    def create_transaction(self, amount=10, timestamp=timezone.now(), description="spent dough", user=None):
        if not user:
            user = self.create_user()

        transaction = Transaction()
        transaction.amount = Decimal(amount)
        transaction.description = description
        transaction.user = user
        transaction.timestamp = timestamp
        transaction.save()
        return transaction
Example #5
0
    def create_transaction(self,
                           amount=10,
                           timestamp=timezone.now(),
                           description="spent dough",
                           user=None):
        if not user:
            user = self.create_user()

        transaction = Transaction()
        transaction.amount = Decimal(amount)
        transaction.description = description
        transaction.user = user
        transaction.timestamp = timestamp
        transaction.save()
        return transaction
Example #6
0
    def test_date_filter(self):
        mock = Transaction()
        mock.amount = Decimal(10)
        mock.description = 'Date Test'
        mock.user = User.objects.create_user('*****@*****.**')
        mock.user.activate_timezone()
        mock.timestamp = datetime.datetime(2014, 1, 1, 8, 15, 2, 0, timezone.get_current_timezone())
        mock.save()

        filter_date = datetime.datetime.combine(datetime.datetime(2014, 1, 1),
                                                datetime.time.max)
        actual = Transaction.objects.date(filter_date).first()
        self.assertEqual(actual.description, 'Date Test')

        filter_date = datetime.datetime(2014, 1, 2, 8, 15, 2, 0, timezone.get_current_timezone())
        actual = Transaction.objects.date(filter_date).exists()
        self.assertFalse(actual)
Example #7
0
    def test_date_range_filter(self):
        mock = Transaction()
        mock.amount = Decimal(10)
        mock.description = 'Date Range Test'
        mock.user = User.objects.create_user('*****@*****.**')
        mock.user.activate_timezone()
        mock.timestamp = datetime.datetime(2014, 1, 1, 8, 15, 2, 0, timezone.get_current_timezone())
        mock.save()

        start = datetime.datetime(2013, 12, 31, 5, 5, 5, 5,  timezone.get_current_timezone())
        end = datetime.datetime(2014, 1, 1, 0, 0, 0, 0, timezone.get_current_timezone())
        actual = Transaction.objects.date_range(start, end).first()
        self.assertEqual(actual.description, 'Date Range Test')

        end = datetime.datetime(2013, 12, 31, 12, 12, 12, 12, timezone.get_current_timezone())
        actual = Transaction.objects.date_range(start, end).exists()
        self.assertFalse(actual)
Example #8
0
    def test_date_filter(self):
        mock = Transaction()
        mock.amount = Decimal(10)
        mock.description = 'Date Test'
        mock.user = User.objects.create_user('*****@*****.**')
        mock.user.activate_timezone()
        mock.timestamp = datetime.datetime(2014, 1, 1, 8, 15, 2, 0,
                                           timezone.get_current_timezone())
        mock.save()

        filter_date = datetime.datetime.combine(datetime.datetime(2014, 1, 1),
                                                datetime.time.max)
        actual = Transaction.objects.date(filter_date).first()
        self.assertEqual(actual.description, 'Date Test')

        filter_date = datetime.datetime(2014, 1, 2, 8, 15, 2, 0,
                                        timezone.get_current_timezone())
        actual = Transaction.objects.date(filter_date).exists()
        self.assertFalse(actual)
Example #9
0
    def test_date_range_filter(self):
        mock = Transaction()
        mock.amount = Decimal(10)
        mock.description = 'Date Range Test'
        mock.user = User.objects.create_user('*****@*****.**')
        mock.user.activate_timezone()
        mock.timestamp = datetime.datetime(2014, 1, 1, 8, 15, 2, 0,
                                           timezone.get_current_timezone())
        mock.save()

        start = datetime.datetime(2013, 12, 31, 5, 5, 5, 5,
                                  timezone.get_current_timezone())
        end = datetime.datetime(2014, 1, 1, 0, 0, 0, 0,
                                timezone.get_current_timezone())
        actual = Transaction.objects.date_range(start, end).first()
        self.assertEqual(actual.description, 'Date Range Test')

        end = datetime.datetime(2013, 12, 31, 12, 12, 12, 12,
                                timezone.get_current_timezone())
        actual = Transaction.objects.date_range(start, end).exists()
        self.assertFalse(actual)
Example #10
0
class TestTransaction(TestCase):
    def setUp(self):
        self.test1 = Transaction()
        self.test1.description = 'Test1'
        self.test1.amount = to_decimal(-5, place='0.01')
        self.test1.save()
        self.test1.refresh_from_db()

        self.test2 = Transaction()
        self.test2.description = 'Test2'
        self.test2.amount = to_decimal(-10, place='0.01')
        self.test2.save()
        self.test2.refresh_from_db()

        self.test3 = Transaction()
        self.test3.description = 'Test3'
        self.test3.amount = to_decimal(1.2, place='0.01')
        self.test3.save()
        self.test3.refresh_from_db()

    def test_today_count(self):
        todays = Transaction.objects.today()
        self.assertEqual(todays.count(), 3)

    def test_today_total(self):
        total = Transaction.objects.today().total()
        self.assertEqual(total, to_decimal(-13.8, place='0.01'))
Example #11
0
class TestTransaction(TestCase):
    def setUp(self):
        self.test1 = Transaction()
        self.test1.description = 'Test1'
        self.test1.amount = to_decimal(-5, place='0.01')
        self.test1.save()
        self.test1.refresh_from_db()

        self.test2 = Transaction()
        self.test2.description = 'Test2'
        self.test2.amount = to_decimal(-10, place='0.01')
        self.test2.save()
        self.test2.refresh_from_db()

        self.test3 = Transaction()
        self.test3.description = 'Test3'
        self.test3.amount = to_decimal(1.2, place='0.01')
        self.test3.save()
        self.test3.refresh_from_db()

    def test_today_count(self):
        todays = Transaction.objects.today()
        self.assertEqual(todays.count(), 3)

    def test_today_total(self):
        total = Transaction.objects.today().total()
        self.assertEqual(total, to_decimal(-13.8, place='0.01'))
Example #12
0
import pandas as pd
from tracking.models import Transaction

excel = pd.read_excel('shipmentTracking.xlsx', sheet_name='Sheet1')

col1 = excel['ShipmentID'].tolist()
col2 = excel['PreDONo'].tolist()
col3 = excel['Delivery Order No'].tolist()
col4 = excel['Net Weight Qty'].tolist()
col5 = excel['Weight Out Date'].tolist()

#print(col1[0],col2[0],col3[0],col4[0],col5[0])

for a, b, c, d, e in zip(col1, col2, col3, col4, col5):
    new = Transaction()
    new.shipment_id = a
    new.pre_do_no = b
    new.delivery_order_no = c
    new.net_weight_qty = d
    new.weight_out_date = e
    new.save()
print('success')