Example #1
0
 def post(self, request, *args, **kwargs):
     case_id = request.POST.get('case_id')
     section_id = request.POST.get('section_id')
     product_id = request.POST.get('product_id')
     if None in (case_id, section_id, product_id):
         return HttpResponseBadRequest()
     rebuild_stock_state(case_id, section_id, product_id)
     return HttpResponseRedirect('.')
Example #2
0
 def post(self, request, *args, **kwargs):
     case_id = request.POST.get('case_id')
     section_id = request.POST.get('section_id')
     product_id = request.POST.get('product_id')
     if None in (case_id, section_id, product_id):
         return HttpResponseBadRequest()
     rebuild_stock_state(case_id, section_id, product_id)
     return HttpResponseRedirect('.')
Example #3
0
    def test_simple(self):
        self._submit_ledgers(LEDGER_BLOCKS_SIMPLE)
        stock_state, latest_txn, all_txns = self._get_stats()
        self.assertEqual(stock_state.stock_on_hand, 100)
        self.assertEqual(latest_txn.stock_on_hand, 100)
        self.assertEqual(all_txns.count(), 2)

        rebuild_stock_state(**self._stock_state_key)

        stock_state, latest_txn, all_txns = self._get_stats()
        self.assertEqual(stock_state.stock_on_hand, 200)
        self.assertEqual(latest_txn.stock_on_hand, 200)
        self.assertEqual(all_txns.count(), 2)
Example #4
0
    def test_simple(self):
        self._submit_ledgers(LEDGER_BLOCKS_SIMPLE)
        stock_state, latest_txn, all_txns = self._get_stats()
        self.assertEqual(stock_state.stock_on_hand, 100)
        self.assertEqual(latest_txn.stock_on_hand, 100)
        self.assertEqual(all_txns.count(), 2)

        rebuild_stock_state(**self._stock_state_key)

        stock_state, latest_txn, all_txns = self._get_stats()
        self.assertEqual(stock_state.stock_on_hand, 200)
        self.assertEqual(latest_txn.stock_on_hand, 200)
        self.assertEqual(all_txns.count(), 2)
Example #5
0
    def test_inferred(self):
        self._submit_ledgers(LEDGER_BLOCKS_INFERRED)
        # this is weird behavior:
        # it just doesn't process the second one
        # even though knowing yesterday's certainly changes the meaning
        # of today's transfer

        # UPDATE SK 2016-03-14: this happens because the transactions are received out of order
        # (they appear out of order in the form XML) and hence saved out of order.
        # When the older transaction is saved it will only look back in time
        # to create inferred transactions and not ahead.
        self._assert_stats(2, 50, 50)

        rebuild_stock_state(**self._stock_state_key)

        self._assert_stats(2, 150, 150)
Example #6
0
    def test_inferred(self):
        self._submit_ledgers(LEDGER_BLOCKS_INFERRED)
        # this is weird behavior:
        # it just doesn't process the second one
        # even though knowing yesterday's certainly changes the meaning
        # of today's transfer

        # UPDATE SK 2016-03-14: this happens because the transactions are received out of order
        # (they appear out of order in the form XML) and hence saved out of order.
        # When the older transaction is saved it will only look back in time
        # to create inferred transactions and not ahead.
        self._assert_stats(2, 50, 50)

        rebuild_stock_state(**self._stock_state_key)

        self._assert_stats(2, 150, 150)
Example #7
0
    def test_inferred(self):
        self._submit_ledgers(LEDGER_BLOCKS_INFERRED)
        stock_state, latest_txn, all_txns = self._get_stats()
        # this is weird behavior:
        # it just doesn't process the second one
        # even though knowing yesterday's certainly changes the meaning
        # of today's transfer
        self.assertEqual(stock_state.stock_on_hand, 50)
        self.assertEqual(latest_txn.stock_on_hand, 50)
        self.assertEqual(all_txns.count(), 3)

        rebuild_stock_state(**self._stock_state_key)

        stock_state, latest_txn, all_txns = self._get_stats()

        self.assertEqual(stock_state.stock_on_hand, 150)
        self.assertEqual(latest_txn.stock_on_hand, 150)
        self.assertEqual(all_txns.count(), 2)
Example #8
0
    def test_inferred(self):
        self._submit_ledgers(LEDGER_BLOCKS_INFERRED)
        stock_state, latest_txn, all_txns = self._get_stats()
        # this is weird behavior:
        # it just doesn't process the second one
        # even though knowing yesterday's certainly changes the meaning
        # of today's transfer
        self.assertEqual(stock_state.stock_on_hand, 50)
        self.assertEqual(latest_txn.stock_on_hand, 50)
        self.assertEqual(all_txns.count(), 3)

        rebuild_stock_state(**self._stock_state_key)

        stock_state, latest_txn, all_txns = self._get_stats()

        self.assertEqual(stock_state.stock_on_hand, 150)
        self.assertEqual(latest_txn.stock_on_hand, 150)
        self.assertEqual(all_txns.count(), 2)
Example #9
0
 def rebuild_ledger_state(self, case_id, section_id, entry_id):
     rebuild_stock_state(case_id, section_id, entry_id)
Example #10
0
 def rebuild_ledger_state(self, case_id, section_id, entry_id):
     rebuild_stock_state(case_id, section_id, entry_id)