Ejemplo n.º 1
0
def deliver():
    """
        Deliver selected order
    """
    coID = request.vars['coID']

    order = Order(coID)
    order.deliver()

    session.flash = SPAN(
        T('Delivered order '),
        A('#', coID, _href=URL('orders', 'edit', vars={'coID': coID})))

    redirect(URL('orders', 'index'))
Ejemplo n.º 2
0
def validate_cart_create_order(cuID, pmID, items):
    """
    :param cuID: db.auth_user.id
    :param items:
    :return:
    """
    from openstudio.os_order import Order

    coID = db.customers_orders.insert(
        auth_customer_id=cuID,
        Status='order_received',
        Origin='pos',
    )
    order = Order(coID)

    # Add items
    for item in items:
        if item['item_type'] == 'product':
            order.order_item_add_product_variant(item['data']['id'],
                                                 item['quantity'])
        elif item['item_type'] == 'classcard':
            order.order_item_add_classcard(item['data']['id'])
        elif item['item_type'] == 'subscription':
            order.order_item_add_subscription(item['data']['id'], TODAY_LOCAL)
        elif item['item_type'] == 'membership':
            order.order_item_add_membership(item['data']['id'], TODAY_LOCAL)
        elif item['item_type'] == 'class_dropin':
            order.order_item_add_class(
                item['data']['clsID'],
                TODAY_LOCAL,
                2  # Attendance Type 2 = drop-in
            )
        elif item['item_type'] == 'class_trial':
            order.order_item_add_class(
                item['data']['clsID'],
                TODAY_LOCAL,
                1  # Attendance Type 1 = trial
            )

    # update order status
    order.set_status_awaiting_payment()

    # mail order to customer
    #    order_received_mail_customer(coID)

    # check if this order needs to be paid or it's free and can be added to the customers' account straight away
    amounts = order.get_amounts()

    # Deliver order, add stuff to customer's account
    result = order.deliver()
    invoice = result['invoice']

    # Add payment
    ipID = invoice.payment_add(
        amounts.TotalPriceVAT,
        TODAY_LOCAL,
        payment_methods_id=pmID,
    )

    return invoice
Ejemplo n.º 3
0
def webhook_order_paid(coID,
                       payment_amount=None,
                       payment_date=None,
                       mollie_payment_id=None,
                       invoice=True,
                       payment=None):
    """
        :param coID: db.customers_orders.id
        :return: None
    """
    # print('webhook order paid')
    # print(payment)
    order = Order(coID)
    result = order.deliver()

    if result and invoice:
        # Add payment to invoice
        invoice = result['invoice']

        if not invoice is None:
            ipID = invoice.payment_add(
                payment_amount,
                payment_date,
                payment_methods_id=100,  # Static id for Mollie payments
                mollie_payment_id=mollie_payment_id)

    if payment:
        # print("payment found")
        # Check for setting to do initial payment using mollie and
        # The following payments using direct debit
        if get_sys_property(
                "shop_subscriptions_payment_method") == "mollie_directdebit":
            # Check for subscription id in order
            # print("correct sys property")
            subscription_found_in_order = False
            items = order.get_order_items_rows()
            for item in items:
                if item.customers_orders_items.school_subscriptions_id:
                    subscription_found_in_order = True
                    break

            # print(payment)
            # print(subscription_found_in_order)

            if subscription_found_in_order and payment.method == "ideal":

                webhook_order_paid_get_bank_info_from_mollie(
                    order.order.auth_customer_id, payment)
Ejemplo n.º 4
0
def webhook_order_paid(coID, payment_amount=None, payment_date=None, mollie_payment_id=None, invoice=True):
    """
        :param coID: db.customers_orders.id
        :return: None
    """
    order = Order(coID)
    result = order.deliver()

    if invoice:
        # Add payment to invoice
        invoice = result['invoice']

        if not invoice is None:
            ipID = invoice.payment_add(
                payment_amount,
                payment_date,
                payment_methods_id=100,  # Static id for Mollie payments
                mollie_payment_id=mollie_payment_id
            )