Example #1
0
    def _test_get_current_ledger_transactions(self, tester_fn):
        tester_fn(self.transactions)

        date = datetime.utcnow()
        report, _ = self.create_report([
            STrans(case_id='c1',
                   section_id='s1',
                   product_id='p1',
                   action='soh',
                   quantity=864)
        ],
                                       date=date)
        create_models_for_stock_report(self.domain, report)

        # create second report with the same date
        # results should have this transaction and not the previous one
        report, _ = self.create_report([
            STrans(case_id='c1',
                   section_id='s1',
                   product_id='p1',
                   action='soh',
                   quantity=1)
        ],
                                       date=date)
        create_models_for_stock_report(self.domain, report)

        new_trans = self.transactions.copy()
        new_trans['c1']['s1']['p1'] = 1

        tester_fn(new_trans)
Example #2
0
    def _test_get_current_ledger_transactions(self, tester_fn):
        tester_fn(self.transactions)

        date = datetime.utcnow()
        report, _ = self.create_report([
            STrans(
                case_id='c1',
                section_id='s1',
                product_id='p1',
                action='soh',
                quantity=864)
        ], date=date)
        create_models_for_stock_report(self.domain, report)

        # create second report with the same date
        # results should have this transaction and not the previous one
        report, _ = self.create_report([
            STrans(
                case_id='c1',
                section_id='s1',
                product_id='p1',
                action='soh',
                quantity=1)
        ], date=date)
        create_models_for_stock_report(self.domain, report)

        new_trans = self.transactions.copy()
        new_trans['c1']['s1']['p1'] = 1

        tester_fn(new_trans)
Example #3
0
    def setUp(self):
        self.case_ids = {'c1': 10, 'c2': 30, 'c3': 50}
        self.section_ids = {'s1': 2, 's2': 9}
        self.product_ids = {'p1': 1, 'p2': 3, 'p3': 5}

        self.domain = self._get_name_for_domain()
        create_domain(self.domain)

        SQLProduct.objects.bulk_create(
            [SQLProduct(product_id=id) for id in self.product_ids])

        transactions_flat = []
        self.transactions = {}
        for case, c_bal in self.case_ids.items():
            for section, s_bal in self.section_ids.items():
                for product, p_bal in self.product_ids.items():
                    bal = c_bal + s_bal + p_bal
                    transactions_flat.append(
                        STrans(case_id=case,
                               section_id=section,
                               product_id=product,
                               action='soh',
                               quantity=bal))
                    self.transactions.setdefault(case, {}).setdefault(
                        section, {})[product] = bal

        self.new_stock_report, self.form = self.create_report(
            transactions_flat)
        create_models_for_stock_report(self.domain, self.new_stock_report)
Example #4
0
    def setUp(self):
        self.case_ids = {'c1': 10, 'c2': 30, 'c3': 50}
        self.section_ids = {'s1': 2, 's2': 9}
        self.product_ids = {'p1': 1, 'p2': 3, 'p3': 5}

        self.domain = self._get_name_for_domain()
        create_domain(self.domain)

        SQLProduct.objects.bulk_create([
            SQLProduct(product_id=id) for id in self.product_ids
        ])

        transactions_flat = []
        self.transactions = {}
        for case, c_bal in self.case_ids.items():
            for section, s_bal in self.section_ids.items():
                for product, p_bal in self.product_ids.items():
                    bal = c_bal + s_bal + p_bal
                    transactions_flat.append(
                        STrans(
                            case_id=case,
                            section_id=section,
                            product_id=product,
                            action='soh',
                            quantity=bal
                        )
                    )
                    self.transactions.setdefault(case, {}).setdefault(section, {})[product] = bal

        self.new_stock_report, self.form = self.create_report(transactions_flat)
        create_models_for_stock_report(self.domain, self.new_stock_report)