コード例 #1
0
    def calculate_order_remain(orders: models.QuerySet) -> dict:
        from apps.order.utils import OrderUtils

        result = {}
        for order in orders:
            result[str(order.pk)] = {
                'uid': order.uid,
                'remain': OrderUtils.get_vnd_total_obj(order) - OrderUtils.get_deposit_amount(order),
            }
        return result
コード例 #2
0
ファイル: tests.py プロジェクト: tbson/24ho
    def test_normal_case(self):
        # Recharge
        recharge_amount = 500000
        money_type = MoneyType.CASH
        TransactionUtils.recharge(recharge_amount, money_type, self.customer, self.staff)

        # Approve
        OrderUtils.approve(self.order, self.staff, self.staff)

        # Set status
        self.order.status = Status.VN_STORE
        self.order.cn_date = Tools.now()
        self.order.vn_date = Tools.now()
        self.order.save()

        # Export
        receipt = ReceiptUtils.seeding(1, True)
        BolUtils.export_order_bols(self.order.order_bols.all(), receipt, self.customer, self.staff)

        deposit = Transaction.objects.get(order=self.order, type=Type.DEPOSIT)
        pay = Transaction.objects.get(order=self.order, type=Type.PAY)
        vnd_total = OrderUtils.get_vnd_total_obj(self.order)

        self.assertEqual(deposit.amount + pay.amount, vnd_total)