Ejemplo n.º 1
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.º 2
0
    def get_orders_with_items_and_amounts(self):
        """
            Returns orders info for a customer with additional info
        """
        from openstudio.os_order import Order

        db = current.db

        orders = []
        rows = self.get_orders_rows()
        for i, row in enumerate(rows):
            repr_row = list(rows[i:i + 1].render())[0]

            order_obj = Order(row.customers_orders.id)
            order = {}
            order['row'] = row
            order['repr_row'] = repr_row
            order['items'] = order_obj.get_order_items_rows()

            orders.append(order)

        return orders
Ejemplo n.º 3
0
def order():
    """
        Page to show order content
    """
    coID = request.vars['coID']

    features = db.customers_profile_features(1)
    if not features.Orders:
        redirect(URL('profile', 'index'))

    order = Order(coID)
    if not order.order.auth_customer_id == auth.user.id:
        return 'Not authorized'

    rows = order.get_order_items_rows()
    amounts = order.get_amounts()

    response.title = T('Order')
    response.subtitle = T('# ') + coID

    back = os_gui.get_button('back', URL('profile', 'orders'), _class='btn-link')

    return dict(rows=rows, amounts=amounts, order=order.order, back=back)
Ejemplo n.º 4
0
def edit():
    """
        :return: shows order
    """
    response.title = T('Order #') + request.vars['coID']
    response.subtitle = T('Edit')
    response.view = 'general/only_content.html'

    coID = request.vars['coID']

    order = Order(coID)
    cuID = order.order.auth_customer_id
    customer = Customer(cuID)
    # Info table
    info = TABLE(THEAD(
        TR(
            TH(T('Customer')),
            TH(T('Ordered on')),
            TH(T('Status')),
        )),
                 _class='table')

    # Display status
    for field in db.customers_orders:
        field.readable = False
        field.writable = False

    db.customers_orders.Status.readable = True
    db.customers_orders.Status.writable = True

    crud.messages.record_updated = T('Saved')
    form = crud.update(db.customers_orders, coID)

    result = set_form_id_and_get_submit_button(form, 'MainForm')
    form = result['form']
    submit = result['submit']

    form = DIV(
        XML('<form id="MainForm" action="#" enctype="multipart/form-data" method="post">'
            ), form.custom.widget.Status, form.custom.end)

    #status = form

    # status = represent_customers_orders_status(order.order.Status, order.order)
    # Display ordered on
    ordered_on = represent_datetime(order.order.DateCreated, order.order)
    customer_link = A(customer.get_name(),
                      _href=URL('customers', 'edit', args=customer.row.id))
    info.append(TR(TD(customer_link), TD(ordered_on), TD(form)))

    # Info content
    content = DIV(DIV(info, _class='col-md-8 no-padding-left'))

    # Display items
    rows = order.get_order_items_rows()

    header = THEAD(
        TR(
            TH(T('Product')),
            TH(T('Description')),
            TH(SPAN(T('Amount incl. VAT'), _class='right')),
            TH(T("G/L Account")),
            TH(T("Cost center")),
            TH(),
        ))
    table = TABLE(header, _class='table table-striped table-hover order-items')

    for i, row in enumerate(rows):
        repr_row = list(rows[i:i + 1].render())[0]

        table.append(
            TR(
                TD(repr_row.customers_orders_items.ProductName),
                TD(repr_row.customers_orders_items.Description),
                TD(
                    SPAN(repr_row.customers_orders_items.TotalPriceVAT,
                         _class='right')),
                TD(repr_row.customers_orders_items.accounting_glaccounts_id),
                TD(repr_row.customers_orders_items.accounting_costcenters_id),
                TD(),
            ))

    # Display totals
    amounts = order.get_amounts()

    footer = TFOOT(
        TR(
            TD(), TD(B(T('Subtotal'))),
            TD(
                SPAN(CURRSYM,
                     ' ',
                     format(amounts.TotalPrice, '.2f'),
                     _class='bold right')), TD()),
        TR(
            TD(), TD(B(T('VAT'))),
            TD(
                SPAN(CURRSYM,
                     ' ',
                     format(amounts.VAT, '.2f'),
                     _class='bold right')), TD()),
        TR(
            TD(), TD(B(T('Total'))),
            TD(
                SPAN(CURRSYM,
                     ' ',
                     format(amounts.TotalPriceVAT, '.2f'),
                     _class='bold right')), TD()))
    table.append(footer)

    content.append(table)

    # Customer message
    customer_message = ''
    if order.order.CustomerNote:
        customer_message = DIV(
            B(T('Customer message')),
            BR(),
            BR(),
            XML(order.order.CustomerNote.replace("\n", "<br>")),
        )
    content.append(customer_message)

    back = os_gui.get_button('back', edit_get_return_url(cuID))

    return dict(content=content, back=back, save=submit)