HI, I have a products model and a dealers model . I am creating an app in which a dealer selects a product and then he's routed to purchase order form . I want to create a dynamic multiplication of Products*Price = Total price i.e. when the form opens , he adds the quantity of the product and the default price is multiplied with no. of products to give total price.
What shall I do ?
Please guide. Thanks
There are a lot of good guides out there for Rails 3 and Unobtrusive Javascript (UJS). Here's one that starts you from the ground up:
http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/
Related
I have simple problem which I can't get the right twist on it.
I have a list of "products" with their stock in the range of D3:D13 with a set price, an original stock and a list of "customers" in the range of E3:L3.
Each customer can take a product and the updated stock currently is:
[=SUM(C3-(SUM(E3:L3))) ]
If we take one person he has his combined cost for how many products he took on E14
If a person pays their cost (E14 > 0) and nulls the products he took currently the updated stock gets rested. That is what I dont want.
Basically: SUM Stock IF (any of E14:L14) > 0 THEN =SUM(C3-(SUM(E3:N3)))
Update:
Example:
https://docs.google.com/spreadsheets/d/1SEssivZ8jCbqedc8TG_PO4uWLN_QzpRQwxJ_bGwHvQg/edit?usp=sharing Hope the link works.
That is basically everything and this works for me currently.
The issue is if a user decides to pay their dept.
For example User 1 pays.
Then the currently calculated price for the user (E14) get's nulled and also the cells for how much products they took (E3:E12).
But then because how it is done currently the updated stock gets updated again with the items the user1 took previously because we nulled the E3:E12. But the products where already taken. That is what I want to prevent.
I'm building a food ordering web application with a standard product/category setup - a category (for example Pizza) has many products (Pizza Salami).
Category
--------
id
name
Product
-------
id
name
category_id
The problem: the price of a category depends on the time of the day. For example for 2pm - 6pm and 9pm - 11pm the price for a pizza is cheaper.
How would I design the prices table and relationships in an effective way?
If your pricing is predictable, you could put a "base price" attribute in the product table, then read it from code, and calculate the "final price", depending on the time. You'll then store that final price in your orders table.
But if you want to be able to read tje final price from the database, I sugest you look into your database documentation, for how to create functions and views.
I'd like to cumulate discounts on my prestshop.
For exemple, I have a quantity discount of 20% starts from 5 pieces bought and another discount of 25% on all products who has to be cumulated with the first one.
Now, 25% is apply with less than 5 pieces and 20% with more than 5 pieces.
I'd like to apply 45% if the quantity is more than 5 pieces.
So, I have to cumulate a custom discount (not a cart rule) with a quantity discount.
I don't know how to do that. Maybe it's possible to do it from the administration panel?
Thank you.
You can read the official documentation about Cart Rules.
In Cart Rules > [one of your cart rule] > Conditions there's a Compatibility with other cart rules check box.
I am currently building a Ruby on Rails invoicing application that is multilingual and supports a range of currencies. In the dashboard view all invoices a user has produced are totalled.
Now it would be nice if a user could choose the currency for each invoice.
But how can those invoices be totalled if different currencies are used?
E.g. if these three invoices were created today:
Invoice No. 1: $1000.00
Invoice No. 2: $2000.00
Invoice No. 3: €1000.00
Total: $4333.60
----------------------
The dollar-euro exchange rate would have to be based on each invoice's date of course.
How can this be achieved in Rails and does it even make sense?
Thanks for any pointers.
The sum of of multiple invoices using different currencies is not a single number, it's a collection of numbers. If you have a 20 USD invoice, a 15 EUR invoice, and a 20 EUR invoice, the sum is "20 USD + 35 EUR".
At the time when a payment is made from a single account using a single base currency, then a conversion will be performed to determine how much will have to be paid in that currency to cover the total converted costs. Presumably, there will also be currency conversion fees added at that time.
It would be convenient if you change the currency to a single one, either euro or dollar right when the user makes an invoice. That is, you save the 'converted' value in your database. In this way you won't have to lookup for past day rates.
Eu_central_bank provides exchange rates.
I have a form for creation new order. One order can include several products. Each product has a price. Order's price equals to sum of prices of all product, included into it.
My form needs to update order's price, as user sets a quantity for each of the products.
Ideas ?
Use Javascript and the onchange HTML event on the quantity input fields.
When the user changed the quantity, the Javascript can process the form and calculate the new order price. Javascript is able to calculate the total price for a number of items, by using something like this:
item_quantity = document.getElementById('item_quantity').value;
item_price = document.getElementById('item_price').value;
// Perform some chacks here, to see whether the input values are valid
item_total = item_price * item_quantity;
Do this for all your items and add all item_total values to get the total order price.
By picking handy ids for your price and quantity fields, you can easily loop this and thus be independent of the amount of items in your order.
Since you're using ruby on rails i would you could use an observer, that could check the value change event of your quantity fields. That way you would be keeping the logic out of your view.
http://it.toolbox.com/blogs/database-geek/ror-passing-multiple-parameters-via-observe_field-18656
http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html
You could also just give your user an update quantities button that would submit the form to the same action so if the form is in new.html.erb then pressing the button would call the new action and would redirect them back to the same page, but you could update the total in the controller.