our commission is now shown on cart page

This commit is contained in:
Senad Uka
2015-06-14 07:11:46 +02:00
parent ce733c8cd8
commit 4dfc2ffbd1
8 changed files with 46 additions and 10 deletions

View File

@@ -0,0 +1,5 @@
class AddCommissionToItemInCart < ActiveRecord::Migration
def change
add_column :item_in_carts, :commision, :decimal
end
end

View File

@@ -0,0 +1,6 @@
class RenameCommissionInItemInCart < ActiveRecord::Migration
def change
remove_column :item_in_carts, :commision
add_column :item_in_carts, :commission, :decimal
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150420044444) do
ActiveRecord::Schema.define(version: 20150614050336) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -104,6 +104,7 @@ ActiveRecord::Schema.define(version: 20150420044444) do
t.datetime "updated_at", null: false
t.integer "count"
t.decimal "price"
t.decimal "commission"
end
create_table "item_in_groups", force: :cascade do |t|

View File

@@ -13,6 +13,7 @@ class ItemInCart < ActiveRecord::Base
item_in_cart ||= ItemInCart.new(cart_id: cart_id, item_id: item_id)
item_in_cart.count = count
item_in_cart.price = item_in_cart.item.list_price
item_in_cart.commission = ((item_in_cart.item.list_price - item_in_cart.item.current_input_price) / (item_in_cart.item.current_input_price)).round(2)
item_in_cart.save!
item_in_cart.destroy! if count <= 0
end

View File

@@ -25,6 +25,7 @@ var CartPage = React.createClass({
return count > 0 || count === "";
}).map(function (i) {
var count = counts[i.get('id')].get('count');
var commission = counts[i.get('id')].get('commission');
var price = i.get('list_price');
var firstImage = i.get('multi_media_descriptions')[0];
firstImage = firstImage || { resized_url: "https://res.cloudinary.com/lfvt7ps2n/image/upload/c_fit,h_172,w_226/v1421732950/http_www.asms.ru_bitrix_templates_main_images_nophoto_irnofq.png" } ;
@@ -33,13 +34,16 @@ var CartPage = React.createClass({
<td className='text-center'>
<img style={{maxWidth: '90px', maxHeight: '90px'}} src={firstImage.url} alt="product image"/>
</td>
<td>
<td className="cart-price-bigger">
<p> {i.get('brand').name}</p>
<p>
{i.get('name')}
</p>
</td>
<td>{ Globals.FormatCurrency(price) }</td>
<td className="cart-price-bigger text-center">{ Globals.FormatCurrency(price) }
<div className="cart-commision-tiny text-center">{ Globals.FormatPercentage(commission) } RUC</div>
</td>
<td>
<select style={{textAlign: 'center'}} value={count} className="form-control"
onChange={self._onQuantityChange.bind(self, i.get('id'))}
@@ -57,7 +61,7 @@ var CartPage = React.createClass({
<option value="10">10</option>
</select>
</td>
<td>
<td className="cart-price-bigger text-center">
{ Globals.FormatCurrency(count * price) }
</td>
<td>
@@ -109,7 +113,7 @@ var CartPage = React.createClass({
content = (<div>
<table className="table">
<thead>
<tr>
<tr className="text-center">
<th className="col-lg-2"></th>
<th>Proizvod</th>
<th>Cijena</th>

View File

@@ -51,4 +51,11 @@
.cart-table-row {
vertical-align: middle;
}
.cart-price-bigger {
font-size: 21px;
}
.cart-commision-tiny {
font-size: 45%;
}

View File

@@ -7,5 +7,9 @@ module.exports = {
var amount = parseFloat(amount_s);
return ( amount.toFixed(2) + " KM" )
},
FormatPercentage: function(amount_s) {
var amount = parseFloat(amount_s);
return ( amount.toFixed(2) + "%" )
},
MaxNumberOfItemsToBeAdded: 1000
};

File diff suppressed because one or more lines are too long