our commission is now shown on cart page
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
class AddCommissionToItemInCart < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :item_in_carts, :commision, :decimal
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -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
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -104,6 +104,7 @@ ActiveRecord::Schema.define(version: 20150420044444) do
|
|||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.integer "count"
|
t.integer "count"
|
||||||
t.decimal "price"
|
t.decimal "price"
|
||||||
|
t.decimal "commission"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "item_in_groups", force: :cascade do |t|
|
create_table "item_in_groups", force: :cascade do |t|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class ItemInCart < ActiveRecord::Base
|
|||||||
item_in_cart ||= ItemInCart.new(cart_id: cart_id, item_id: item_id)
|
item_in_cart ||= ItemInCart.new(cart_id: cart_id, item_id: item_id)
|
||||||
item_in_cart.count = count
|
item_in_cart.count = count
|
||||||
item_in_cart.price = item_in_cart.item.list_price
|
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.save!
|
||||||
item_in_cart.destroy! if count <= 0
|
item_in_cart.destroy! if count <= 0
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ var CartPage = React.createClass({
|
|||||||
return count > 0 || count === "";
|
return count > 0 || count === "";
|
||||||
}).map(function (i) {
|
}).map(function (i) {
|
||||||
var count = counts[i.get('id')].get('count');
|
var count = counts[i.get('id')].get('count');
|
||||||
|
var commission = counts[i.get('id')].get('commission');
|
||||||
var price = i.get('list_price');
|
var price = i.get('list_price');
|
||||||
var firstImage = i.get('multi_media_descriptions')[0];
|
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" } ;
|
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'>
|
<td className='text-center'>
|
||||||
<img style={{maxWidth: '90px', maxHeight: '90px'}} src={firstImage.url} alt="product image"/>
|
<img style={{maxWidth: '90px', maxHeight: '90px'}} src={firstImage.url} alt="product image"/>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className="cart-price-bigger">
|
||||||
<p> {i.get('brand').name}</p>
|
<p> {i.get('brand').name}</p>
|
||||||
<p>
|
<p>
|
||||||
{i.get('name')}
|
{i.get('name')}
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</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>
|
<td>
|
||||||
<select style={{textAlign: 'center'}} value={count} className="form-control"
|
<select style={{textAlign: 'center'}} value={count} className="form-control"
|
||||||
onChange={self._onQuantityChange.bind(self, i.get('id'))}
|
onChange={self._onQuantityChange.bind(self, i.get('id'))}
|
||||||
@@ -57,7 +61,7 @@ var CartPage = React.createClass({
|
|||||||
<option value="10">10</option>
|
<option value="10">10</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className="cart-price-bigger text-center">
|
||||||
{ Globals.FormatCurrency(count * price) }
|
{ Globals.FormatCurrency(count * price) }
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -109,7 +113,7 @@ var CartPage = React.createClass({
|
|||||||
content = (<div>
|
content = (<div>
|
||||||
<table className="table">
|
<table className="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr className="text-center">
|
||||||
<th className="col-lg-2"></th>
|
<th className="col-lg-2"></th>
|
||||||
<th>Proizvod</th>
|
<th>Proizvod</th>
|
||||||
<th>Cijena</th>
|
<th>Cijena</th>
|
||||||
|
|||||||
@@ -52,3 +52,10 @@
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cart-price-bigger {
|
||||||
|
font-size: 21px;
|
||||||
|
}
|
||||||
|
.cart-commision-tiny {
|
||||||
|
font-size: 45%;
|
||||||
|
}
|
||||||
@@ -7,5 +7,9 @@ module.exports = {
|
|||||||
var amount = parseFloat(amount_s);
|
var amount = parseFloat(amount_s);
|
||||||
return ( amount.toFixed(2) + " KM" )
|
return ( amount.toFixed(2) + " KM" )
|
||||||
},
|
},
|
||||||
|
FormatPercentage: function(amount_s) {
|
||||||
|
var amount = parseFloat(amount_s);
|
||||||
|
return ( amount.toFixed(2) + "%" )
|
||||||
|
},
|
||||||
MaxNumberOfItemsToBeAdded: 1000
|
MaxNumberOfItemsToBeAdded: 1000
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user