I would need to define specific prices for each customer group.
But not per channel.
How can I do this from the Back-Office?
Thanks.
Related
So I have fields of Customer #, Order #, Order Date, and Shipping Address all in the same table.
What I need to know is the Customer # and Order #'s from the customer's that have made more than one order in a single day that have different shipping addresses in their orders.
This is in SQL.
Thanks!
I'm trying to build a price comparison database with n products and a definitive but changing number of vendors that sell these products.
For my price comparison database, I need to store both current prices for a product across different vendors and historical prices (one lowest price).
As I see it, I have 2 options to design the database tables:
1. Put all vendor prices into the main table.
I know how many vendors there will be and if I add or remove a vendor I can add or remove a column.
Historical prices (lowest price on certain date across all vendors), goes into a separate table with a product name, a price and a date.
2. Have one table for products and one table for prices
I will have only the static attribute data in the main table such as categories, attributes etc and then add prices to a separate product table where I store price, vendor, date in it and I can store the lowest price as a pseudo-vendor in that table for each date or I can store it in a separate table as well.
Which method would you suggest and am I missing something?
You should store the base data in a normalized format that contains all the history. This means that you have tables for:
products, with one row per product and the static information about the products.
vendors, with one row per vendor and the static information about the vendor.
prices, with one row per price along with the date and product and vendor.
You can get the current and lowest prices using a query, such as:
select pr.*
from (select pr.*, min(price) over (partition by product) as min_price
row_number() over (partition by product, vendor order by price_datetime desc) as seqnum
from prices pr
where pr.product_id = XXX
) pr
where seqnum = 1;
For performance, you want an index on prices(product, vendor, price_datetime desc).
Eventually, you may find that this query runs too slowly. In that case, you will then consider optimizations. One optimization would simply be storing the latest date for each price/vendor combination using a trigger, along with the minimum price in the products table -- presumably using triggers.
Another would be maintaining a summary table for each product and vendor using triggers. However, that is probably not how you should start the endeavor.
However, you might be surprised at how well the above query can perform on your data.
I am helping someone build a grocery deliver service. Very simple site and order process. The problem I am having is knowing how to come up with schema for the orders. The order would have contact information, but would also need to have all of the products they ordered. Since it can/will be different for each persons order, how would I go about designing this? Would I just have a products ordered field with a string list of all the items? Or would I need multiple linked tables?
Thanks!
You need three tables:
a) Products - Contains the product details
b) Orders - Contains the order header, contact information etc
c) Product_Orders - is a table with two columns: product_id and order_id, that bind the orders to the products, and a quantity field and unit price.
You could have a customers table, but ideally information like the delivery address, etc, would be attached to the order so that if the user changes his address it will not affect your order history.
For the same reason unit price must be in Product_Orders, so that if a product price changes it does not affect previous orders.
Product table
with name and price of all products.
Customer table
with name, address, phone etc...
Order table
with entries for each order: order id, cusomer id, date etc
Order Items table
with all ordered items, with link to id in ordertable, product table, quantity, price, etc...
In Openerp v7, I have sent two (or more) purchase orders to the same supplier and he sent me one invoice for those orders.
Is there a way or a module to create one invoice grouping the two orders.
Note 1: I don't want to merge the orders, but just one unique invoice (as I received) related to both.
Note 2 : the orders concern service type product so, there are no pickings to be invoiced.
Thank you
Ok,
one solution is to set the invoice_method to "Based on Purchase Order lines" for this type or orders.
Then, when we receive the supplier invoice, we can select the concerned purchase order lines and create an invoice in accordance to the one received.
Not exactly group nor merge but it can do the trick
this is my invoice table:
Invoice Table:
invoice_id
creation_date
due_date
payment_date
status enum('not paid','paid','expired')
user_id
total_price
I wonder if it's Useful to have a payment table in order to record user payments for invoices.
payment table can be like this:
payment_id
payment_date
invoice_id
price_paid
status enum('successful', 'not successful')
If you want to allow more than one payment for an invoices, then yes a payment table would be useful.
It's also a good idea to keep your database normalized as much as possible.
Yes. Sometimes they might not pay in full or overpay, or pay in multiple transactions. Having the separate table allows you to keep track of this.
With just one table, all you can see is the original amount and the amount remaining to be paid, but not the history of payments.
Could a payment span multiple invoices?
Could an invoice be payed via multiple payments?
My guess is you will need a payment table and probably an account table and some sort of transaction table as well.
Many accounting applications have invoice_header, invoice_line, account_ledger, ledger_application and account tables.
The account_ledger table typically contains the items on the customer/vendor accounts. These items could be invoices, payments, or whatever.
The ledger_application table holds the information on the many-to-many relationship between payments and invoices.
The invoice_header table contains all information associated with an invoice which does not belong in the account_ledger table.
The invoice_line table has the data pertaining to the individual items/quantities/amounts on the invoice.
The account table stores data about the customer/vendor such as address, contact info, etc.