Exemplo n.º 1
0
    def re_cal(self, item: models.QuerySet) -> models.QuerySet:
        from .utils import OrderUtils

        statistics = OrderUtils.cal_statistics(item)

        item.__dict__.update(OrderUtils.cal_all(item), statistics=statistics)

        item.save()
        return item
Exemplo n.º 2
0
Arquivo: utils.py Projeto: tbson/24ho
    def deposit(order: models.QuerySet, staff: models.QuerySet):
        from .models import Type, MoneyType
        from .models import Transaction
        from apps.order.utils import OrderUtils

        TransactionUtils.undeposit(order)

        amount = OrderUtils.get_deposit_amount(order)
        can_deposit = OrderUtils.can_deposit(order)
        if not can_deposit:
            raise ValidationError("Đơn hàng {} không đủ tiền đặt cọc.".format(
                order.uid))

        transaction = Transaction(order=order,
                                  customer=order.customer,
                                  staff=staff,
                                  amount=amount,
                                  type=Type.DEPOSIT,
                                  money_type=MoneyType.INDIRECT,
                                  note="Đặt cọc đơn {}".format(order.uid))
        order.deposit = amount
        order.save()
        transaction.save()
Exemplo n.º 3
0
Arquivo: utils.py Projeto: tbson/24ho
 def force_cal(order: models.QuerySet) -> models.QuerySet:
     order.__dict__.update(OrderUtils.cal_all(order))
     order.save()
     return order
Exemplo n.º 4
0
Arquivo: utils.py Projeto: tbson/24ho
 def unpending(order: models.QuerySet) -> str:
     potential_bols = order.potential_bols
     order.pending = False
     order.save()
     return potential_bols
Exemplo n.º 5
0
Arquivo: utils.py Projeto: tbson/24ho
 def pending(order: models.QuerySet) -> models.QuerySet:
     order.do_not_check_pending = True
     order.pending = True
     order.save()
     return order
Exemplo n.º 6
0
Arquivo: utils.py Projeto: tbson/24ho
 def undeposit(order: models.QuerySet):
     from .models import Type
     for transaction in order.order_transactions.filter(type=Type.DEPOSIT):
         transaction.delete()
     order.deposit = 0
     order.save()
Exemplo n.º 7
0
 def save(item: models.QuerySet, status: Status) -> models.QuerySet:
     item.status = status
     item.save()
     return item