From d52c0178489f079fd5d6702f75e8cac1ea0d178a Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Thu, 28 Apr 2016 22:41:58 +0200 Subject: [PATCH] suite --- app/assets/stylesheets/public.scss | 20 ++- .../public/account_ribs_controller.rb | 102 ++++++++++++ .../public/commissions_controller.rb | 22 +++ .../public/my_account_controller.rb | 58 +++++++ .../product_customers_auths_controller.rb | 7 + .../public/product_customers_controller.rb | 10 +- .../public/virements_controller.rb | 156 ++++++++++++++++++ app/models/account_rib.rb | 19 +++ app/models/commission.rb | 18 ++ app/models/devise.rb | 14 ++ app/models/product.rb | 2 +- app/models/product_customer.rb | 126 +++++++++++++- app/models/product_order.rb | 70 ++++++-- app/models/product_order_product.rb | 4 + app/models/virement.rb | 63 +++++++ app/models/virement_remise.rb | 20 +++ app/uploaders/rib_uploader.rb | 62 +++++++ .../product_orders/_product_order.html.haml | 2 +- app/views/admin/product_orders/show.html.haml | 4 +- app/views/layouts/public.html.haml | 12 +- .../confirmation_cb.html.haml | 4 +- .../confirmation_cheque.html.haml | 19 +-- app/views/public/account_ribs/_form.html.haml | 26 +++ app/views/public/account_ribs/index.html.haml | 38 +++++ app/views/public/account_ribs/new.html.haml | 8 + .../public/commissions/_commission.html.haml | 51 ++++++ app/views/public/commissions/index.html.haml | 65 ++++++++ .../public/my_account/_address.html.haml | 16 ++ .../public/my_account/_binary_form.html.haml | 5 + app/views/public/my_account/_menu.haml | 16 ++ .../public/my_account/_note_pays.html.haml | 3 + .../my_account/_solde_credits.html.haml | 13 ++ .../public/my_account/_text_pays.html.haml | 51 ++++++ app/views/public/my_account/binary.haml | 51 ++++++ .../public/my_account/edit_infos.html.haml | 44 +++++ app/views/public/my_account/favoris.html.haml | 11 ++ app/views/public/my_account/filleuls.haml | 96 +++++++++++ app/views/public/my_account/index.html.haml | 101 ++++++++++++ .../public/my_account/my_annonces.html.haml | 2 + .../product_categories/_bandeau.html.haml | 9 +- .../public/product_customers/_new_form.haml | 1 - .../product_orders/_mail_recap.html.haml | 4 +- .../public/product_orders/my_cart.html.haml | 6 +- .../payment_instructions.html.haml | 7 +- .../product_orders/select_payment.html.haml | 4 +- app/views/public/products/show.html.haml | 2 +- app/views/public/virements/_form.html.haml | 19 +++ app/views/public/virements/confirm.html.haml | 26 +++ app/views/public/virements/index.html.haml | 40 +++++ app/views/public/virements/new.html.haml | 22 +++ app/views/public/virements/show.html.haml | 145 ++++++++++++++++ config/routes.rb | 22 ++- .../20150614143556_create_commissions.rb | 15 ++ .../20150710094053_add_rbt_to_commissions.rb | 7 + .../20150710105519_create_account_ribs.rb | 28 ++++ ...40_add_count_part_com_id_to_commissions.rb | 5 + .../20150716094451_create_virement_remises.rb | 14 ++ db/migrate/20150716095743_create_virements.rb | 24 +++ db/migrate/20151003193230_create_devises.rb | 12 ++ ...151008144610_add_percent_to_commissions.rb | 6 + ...20151229204119_add_orderable_to_devises.rb | 5 + .../20151229210641_add_devise_to_virements.rb | 8 + ...29210736_add_devise_to_virement_remises.rb | 8 + ...0151229210904_add_devise_to_commissions.rb | 8 + ...0112150541_add_facebook_fields_to_users.rb | 6 + ...60112180801_add_facebook_token_to_users.rb | 5 + db/schema.rb | 106 ++++++++++++ 67 files changed, 1911 insertions(+), 64 deletions(-) create mode 100644 app/controllers/public/account_ribs_controller.rb create mode 100644 app/controllers/public/commissions_controller.rb create mode 100644 app/controllers/public/my_account_controller.rb create mode 100644 app/controllers/public/virements_controller.rb create mode 100644 app/models/account_rib.rb create mode 100644 app/models/commission.rb create mode 100644 app/models/devise.rb create mode 100644 app/models/virement.rb create mode 100644 app/models/virement_remise.rb create mode 100644 app/uploaders/rib_uploader.rb create mode 100644 app/views/public/account_ribs/_form.html.haml create mode 100644 app/views/public/account_ribs/index.html.haml create mode 100644 app/views/public/account_ribs/new.html.haml create mode 100644 app/views/public/commissions/_commission.html.haml create mode 100644 app/views/public/commissions/index.html.haml create mode 100644 app/views/public/my_account/_address.html.haml create mode 100644 app/views/public/my_account/_binary_form.html.haml create mode 100644 app/views/public/my_account/_menu.haml create mode 100644 app/views/public/my_account/_note_pays.html.haml create mode 100644 app/views/public/my_account/_solde_credits.html.haml create mode 100644 app/views/public/my_account/_text_pays.html.haml create mode 100644 app/views/public/my_account/binary.haml create mode 100644 app/views/public/my_account/edit_infos.html.haml create mode 100644 app/views/public/my_account/favoris.html.haml create mode 100644 app/views/public/my_account/filleuls.haml create mode 100644 app/views/public/my_account/index.html.haml create mode 100644 app/views/public/my_account/my_annonces.html.haml create mode 100644 app/views/public/virements/_form.html.haml create mode 100644 app/views/public/virements/confirm.html.haml create mode 100644 app/views/public/virements/index.html.haml create mode 100644 app/views/public/virements/new.html.haml create mode 100644 app/views/public/virements/show.html.haml create mode 100644 db/migrate/20150614143556_create_commissions.rb create mode 100644 db/migrate/20150710094053_add_rbt_to_commissions.rb create mode 100644 db/migrate/20150710105519_create_account_ribs.rb create mode 100644 db/migrate/20150712190240_add_count_part_com_id_to_commissions.rb create mode 100644 db/migrate/20150716094451_create_virement_remises.rb create mode 100644 db/migrate/20150716095743_create_virements.rb create mode 100644 db/migrate/20151003193230_create_devises.rb create mode 100644 db/migrate/20151008144610_add_percent_to_commissions.rb create mode 100644 db/migrate/20151229204119_add_orderable_to_devises.rb create mode 100644 db/migrate/20151229210641_add_devise_to_virements.rb create mode 100644 db/migrate/20151229210736_add_devise_to_virement_remises.rb create mode 100644 db/migrate/20151229210904_add_devise_to_commissions.rb create mode 100644 db/migrate/20160112150541_add_facebook_fields_to_users.rb create mode 100644 db/migrate/20160112180801_add_facebook_token_to_users.rb diff --git a/app/assets/stylesheets/public.scss b/app/assets/stylesheets/public.scss index 005ae1b..7292c8d 100755 --- a/app/assets/stylesheets/public.scss +++ b/app/assets/stylesheets/public.scss @@ -32,7 +32,7 @@ body{ font-size:15px; color:#333333; background:white; - + padding-top:60px; @@ -66,9 +66,11 @@ body{ } .category-container{ - + background:center center no-repeat; + background-size:100%; + background-size:cover; display:block; - min-height:500px; + min-height:200px; img{ width:100%; } @@ -78,7 +80,7 @@ body{ .category-title{ color:white; - font-size: 80px; + font-size: 1.5em; display:block; text-align:center; width:100%; @@ -94,6 +96,7 @@ body{ #footer{ display:block; height:390px; + margin-top:100px; background: url("/images/footer_background.jpg") center center; background-size:cover !important; background-size:100%; @@ -164,7 +167,7 @@ body{ background-size:100%; background-size:cover; - min-height:400px; + img{ width:100%; } @@ -363,12 +366,15 @@ img{ .center{ margin:auto; - max-width:900px; + max-width:1100px; } .product_show{ - + #product_description{ + + max-width:700px; + } .col_images{ float:left; box-sizing:border-box; diff --git a/app/controllers/public/account_ribs_controller.rb b/app/controllers/public/account_ribs_controller.rb new file mode 100644 index 0000000..588a321 --- /dev/null +++ b/app/controllers/public/account_ribs_controller.rb @@ -0,0 +1,102 @@ +class Public::AccountRibsController < ApplicationController + layout "public" + + before_filter :auth_product_customer + + + + def index + + + + @account_rib = current_product_customer.account_ribs.all + + + end + + + def show + @account_rib = AccountRib.find(params[:id]) + session[:mail_prev] = public_account_rib_path(@account_rib) + end + + + def new + @no_search = true + @account_rib = current_product_customer.account_ribs.new(:country => "France") + + + end + + def edit + @account_rib = current_account_rib_account.account_rib.find(params[:id]) + + end + + + + def create + + + @account_rib = current_product_customer.account_ribs.new(params.require(:account_rib).permit!) + + + + + if @account_rib.save + + + redirect_to public_account_ribs_path + + + + else + render :action => "new" + end + end + + + def update + @account_rib = current_product_customer.account_ribs.find(params[:id]) + + + + + respond_to do |format| + if @account_rib.update_attributes(params.require(:account_rib).permit!) + + + + format.html { + redirect_to public_my_account_path + } + format.js + + else + + format.html { render :action => "edit" } + format.js { "" } + end + end + + + + end + + + + def destroy + + @account_rib = current_account_rib_account.account_rib.find(params[:id]) + @account_rib.enabled = nil + @account_rib.save + + redirect_to public_my_account_path, :notice => "Votre account_rib a bien été désactivée" + + + + end + + + +end diff --git a/app/controllers/public/commissions_controller.rb b/app/controllers/public/commissions_controller.rb new file mode 100644 index 0000000..4340a36 --- /dev/null +++ b/app/controllers/public/commissions_controller.rb @@ -0,0 +1,22 @@ +class Public::CommissionsController < ApplicationController + layout "public" + + + + def index + @no_search = true + per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 20 + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + @commissions = current_product_customer.commissions.order("created_at DESC").page(page).per(per_page) + + + + + + end + + + + + +end diff --git a/app/controllers/public/my_account_controller.rb b/app/controllers/public/my_account_controller.rb new file mode 100644 index 0000000..3702252 --- /dev/null +++ b/app/controllers/public/my_account_controller.rb @@ -0,0 +1,58 @@ +class Public::MyAccountController < ApplicationController + + layout "public" + + before_filter :auth_product_customer + + def index + + end + + def edit_infos + @no_search = true + end + + def my_annonces + @no_search = true + end + + def binary + @no_search = true + if params[:parrain_id] and current_product_customer.binary_child_ids.include?(params[:parrain_id].to_i) + @parrain = ProductCustomer.find(params[:parrain_id]) + + + + else + @parrain = current_product_customer + end + end + + def filleuls + @no_search = true + @filleuls = current_product_customer.children + + session[:mail_prev] = public_filleuls_path + + end + + def reconfirm + @no_search = true + ProductCustomerMailer.confirm(current_product_customer).deliver + + redirect_to public_my_account_path, :notice => "Le mail vous a été renvoyé" + end + + + def favoris + + per_page = (params[:per_page] and params[:per_page] != "") ? params[:per_page] : 10 + + page = (params[:page] and params[:page] != "") ? params[:page] : 1 + + @annonces = current_product_customer.annonce_favs.valid_to_show + @annonces = @annonces.page(page).per(per_page).all + end + + +end diff --git a/app/controllers/public/product_customers_auths_controller.rb b/app/controllers/public/product_customers_auths_controller.rb index 8d64d48..44ee70b 100755 --- a/app/controllers/public/product_customers_auths_controller.rb +++ b/app/controllers/public/product_customers_auths_controller.rb @@ -19,6 +19,13 @@ class Public::ProductCustomersAuthsController < ApplicationController end @product_customer = ProductCustomer.new() + if cookies[:mlm_token] and @parent = ProductCustomer.find_parrain(cookies[:mlm_token]) + @product_customer.parent_code = @parent.mlm_token.upcase + + elsif params[:p] and @parent = ProductCustomer.find_parrain(params[:p]) + @product_customer.parent_code = @parent.mlm_token.upcase + + end end diff --git a/app/controllers/public/product_customers_controller.rb b/app/controllers/public/product_customers_controller.rb index 0eafd0e..f3d68b6 100755 --- a/app/controllers/public/product_customers_controller.rb +++ b/app/controllers/public/product_customers_controller.rb @@ -1,7 +1,7 @@ class Public::ProductCustomersController < ApplicationController layout "public" - before_filter :auth_product_customer, :except => [:new, :create, :confirm, :find_parrain] + before_filter :auth_product_customer, :except => [:new, :create, :confirm, :find_parrain, :parrainage] def index @@ -27,10 +27,18 @@ class Public::ProductCustomersController < ApplicationController params[:for_annonce] = nil end + + params[:for_mail] =nil if params[:for_mail] == "" @product_customer = ProductCustomer.new() + if cookies[:mlm_token] and @parent = ProductCustomer.find_parrain(cookies[:mlm_token]) + @product_customer.parent_code = @parent.mlm_token.upcase + elsif params[:p] and @parent = ProductCustomer.find_parrain(params[:p]) + @product_customer.parent_code = @parent.mlm_token.upcase + + end if cookies[:mlm_token] and @parent = ProductCustomer.find_parrain(cookies[:mlm_token]) @product_customer.parent_code = @parent.mlm_token.upcase diff --git a/app/controllers/public/virements_controller.rb b/app/controllers/public/virements_controller.rb new file mode 100644 index 0000000..d4b5b9a --- /dev/null +++ b/app/controllers/public/virements_controller.rb @@ -0,0 +1,156 @@ +class Public::VirementsController < ApplicationController + layout "public" + + before_filter :auth_product_customer + + + + def index + + + + @virements = current_product_customer.virements.all + + + end + + + def show + @virement = current_product_customer.virements.find_by_token(params[:id]) + + @temp_file = "#{Rails.root}/pdf/virements/#{@virement.token}_temp.pdf" + @final_file = "#{Rails.root}/pdf/virements/#{@virement.token}.pdf" + + + view = ActionView::Base.new(Rails.root.join('app/views')) + view.class.include ApplicationHelper + view.class.include Rails.application.routes.url_helpers + + pdf = view.render( + :pdf => "#{@virement.token}", + :template => "public/virements/show.html.haml", + + :locals => {:@virement => @virement, :current_product_customer => current_product_customer}) + + # then save to a file + pdf = WickedPdf.new.pdf_from_string(pdf, :margin => { top: 0, # default 10 (mm) + bottom: 0, + left: 0, + right: 0 }) + + save_path = @temp_file + File.open(save_path, 'wb') do |file| + file << pdf + end + + + + require 'posix/spawn' + + ::POSIX::Spawn::Child.new 'pdftk', @temp_file, 'background', Rails.root.join('pdf_stamp', 'orders.pdf').to_s, 'output', @final_file + + #pdftk /Users/nico/Dev/sideplace_app.old/pdf/order_bills/SP20150700003.pdf background fond.pdf output sortie.pdf + + + + + @data_to_send = File.open( @final_file).read + + send_data @data_to_send, :filename =>"note-commission.pdf" , :type => 'application/pdf',:disposition => (params[:inline] ? 'inline' : "attachment") + + + end + + + def new + @no_search = true + @devise = Devise.first + @virement = current_product_customer.virements.new(:amount_ht => current_product_customer.max_virement, :devise => @devise) + + + end + + def edit + @virement = current_virement_account.virements.find(params[:id]) + + end + + + + def create + + + @virement = current_product_customer.virements.new(params.require(:virement).permit!) + + + + + if @virement.valid? + if params[:confirm] + token = @virement.generate_token + @commission = current_product_customer.commissions.new(:commission_type_id => 4, :amount => ((@virement.amount_ht+5)*(-1)), :devise => @virement.devise) + @virement.commission = @commission + if @virement.save + + redirect_to public_commissions_path + else + render :inline => "test" + end + else + render :action => "confirm" + end + + + + + + else + render :action => "new" + end + end + + + def update + @virement = current_product_customer.virements.find(params[:id]) + + + + + respond_to do |format| + if @virement.update_attributes(params.require(:virement).permit!) + + + + format.html { + redirect_to public_my_account_path + } + format.js + + else + + format.html { render :action => "edit" } + format.js { "" } + end + end + + + + end + + + + def destroy + + @virement = current_virement_account.virements.find(params[:id]) + @virement.enabled = nil + @virement.save + + redirect_to public_my_account_path, :notice => "Votre virement a bien été désactivée" + + + + end + + + +end diff --git a/app/models/account_rib.rb b/app/models/account_rib.rb new file mode 100644 index 0000000..34cf60d --- /dev/null +++ b/app/models/account_rib.rb @@ -0,0 +1,19 @@ +class AccountRib < ActiveRecord::Base + belongs_to :product_customer + + mount_uploader :scan_file, RibUploader + + validates :bank_name, :presence => true + validates :bank_city, :presence => true + validates :country, :presence => true + validates :name, :presence => true + validates :address, :presence => true + validates :tva_number, :presence => true, :if => :tva? + validates :cp, :presence => true + validates :city, :presence => true + validates :iban, :presence => true + validates :bic, :presence => true + + + +end diff --git a/app/models/commission.rb b/app/models/commission.rb new file mode 100644 index 0000000..e005f1c --- /dev/null +++ b/app/models/commission.rb @@ -0,0 +1,18 @@ +class Commission < ActiveRecord::Base + belongs_to :product_customer + has_one :order_solde, :class_name => "Order" + belongs_to :product_order + belongs_to :count_part_com + + has_one :virement + has_one :hipay_virement + + belongs_to :devise + + after_create do + if self.commission_type_id == 1 or self.commission_type_id == 2 or self.commission_type_id == 3 + ProductCustomerMailer.new_commission(self).deliver + end + end + +end diff --git a/app/models/devise.rb b/app/models/devise.rb new file mode 100644 index 0000000..0641c5c --- /dev/null +++ b/app/models/devise.rb @@ -0,0 +1,14 @@ +class Devise < ActiveRecord::Base + + def self.convert(amount, devise_from, devise_to) + result = (amount.to_f/devise_from.rate)*devise_to.rate + + return result.round(2) + + #Devise.convert(10, Devise.find_by_code("EUR"), Devise.find_by_code("USD")) + #Devise.convert(10, Devise.find_by_code("USD"), Devise.find_by_code("EUR")) + #Devise.convert(10, Devise.find_by_code("CHF"), Devise.find_by_code("EUR")) + + end + +end diff --git a/app/models/product.rb b/app/models/product.rb index 8377de8..5bcd93e 100755 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -115,7 +115,7 @@ class Product < ActiveRecord::Base def tva - 0.0 + 0.2 end def price_ttc diff --git a/app/models/product_customer.rb b/app/models/product_customer.rb index 35cb037..1efdb37 100755 --- a/app/models/product_customer.rb +++ b/app/models/product_customer.rb @@ -1,9 +1,12 @@ class ProductCustomer < ActiveRecord::Base - + acts_as_tree has_secure_password validates :email, :presence => true, :uniqueness => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i validates_presence_of :password, :on => :create + has_many :product_orders + has_many :commissions + has_many :account_ribs belongs_to :particular_bill, :class_name => "Particular" @@ -86,5 +89,126 @@ class ProductCustomer < ActiveRecord::Base end + def mlm_detail_ids + + i = 0 + + parents_id = [self.id] + + mlm_children_ids = [] + + mlm_children_id_by_levels = [] + + while i != 14 do + i += 1 + + + parents_id = ProductCustomer.where(:parent_id => parents_id).select(:id).map{ |v| v.id} + + mlm_children_id_by_levels[i] = parents_id + mlm_children_ids.concat parents_id + + + + end + + { + :mlm_children_id_by_levels => mlm_children_id_by_levels, + :mlm_children_ids => mlm_children_ids + } + + + end + + def mlm_children_id_by_levels + self.mlm_detail_ids[:mlm_children_id_by_levels] + end + + def mlm_children_ids + self.mlm_detail_ids[:mlm_children_ids] + end + + def solde_commissions(devise_id=1) + self.commissions.where(:devise_id => devise_id).sum(:amount) + end + + + def max_virement(devise_id=1) + self.solde_commissions(1).floor - 5.0 + + end + def mlm_small_percents + [0,10,6,4,0,0,0,0,0,0,0,0] + end + + def callif_now + {:percents => self.mlm_small_percents} + end + + + def mlm_nbr_niveaux + if self.callif_now + 3 + + else + 0 + end + end + + COUNTRY = [ + + "Suisse", + "France", + "Allemagne", + "Autriche", + "Belgique", + "Espagne", + "Estonie", + "Finlande", + "Grèce", + "Irlande", + "Italie", + "Luxembourg", + "Malte", + "Pays-Bas", + "Portugal", + "Slovaquie", + "Slovénie", + "Croatie", + + + "Bulgarie", + "Danemark", + "Hongrie", + "Lettonie", + "Lituanie", + "Pologne", + "République Tchèque", + "Roumanie", + "Royaume Uni", + "Suède", + "Islande", + "Norvège", + "Liechtenstein", + "Monaco", + + "Guadeloupe", + "Guyane", + "Martinique", + "La Réunion", + "Mayotte", + "Polynésie française", + "Saint-Barthélemy", + #"Saint-Martin", + #"Saint-Pierre-et-Miquelon", + "Wallis-et-Futuna", + "Nouvelle-Calédonie" + + + + + ] + + end diff --git a/app/models/product_order.rb b/app/models/product_order.rb index 5f93a3e..e499a21 100755 --- a/app/models/product_order.rb +++ b/app/models/product_order.rb @@ -29,16 +29,29 @@ class ProductOrder < ActiveRecord::Base attr_accessor :force_fdp_validation, :force_payment, :force_cgv_validation def total_ttc - total_articles + total_fdp - vourcher_reduction + total_articles_ttc + total_fdp - vourcher_reduction_ttc end def total_ttc_without_fdp - total_articles - vourcher_reduction + total_articles_ttc - vourcher_reduction_ttc end - def vourcher_reduction + def total_ht_without_fdp + total_articles_ht - vourcher_reduction_ht + end + + def vourcher_reduction_ttc if self.vourcher_code and 1==1 - (total_articles * (self.vourcher_code.percent / 100 )).round(2) + (total_articles_ttc * (self.vourcher_code.percent / 100 )).round(2) + + else + 0.0 + end + end + + def vourcher_reduction_ht + if self.vourcher_code and 1==1 + (total_articles_ht * (self.vourcher_code.percent / 100 )).round(2) else 0.0 @@ -46,9 +59,9 @@ class ProductOrder < ActiveRecord::Base end - def archived_vourcher_reduction + def archived_vourcher_reduction_ttc if self.vourcher_code_archived and 1==1 - (total_articles * (self.vourcher_code_archived.percent / 100 )).round(2) + (total_articles_ttc * (self.vourcher_code_archived.percent / 100 )).round(2) else 0.0 @@ -58,11 +71,11 @@ class ProductOrder < ActiveRecord::Base def archived_total_ttc - archived_total_articles + archived_total_fdp - archived_vourcher_reduction + archived_total_articles_ttc + archived_total_fdp - archived_vourcher_reduction_ttc end - def archived_total_articles + def archived_total_articles_ttc archived_total = 0.0 product_order_products.each do |p| archived_total += p.archived_final_price_ttc_with_qty @@ -72,7 +85,7 @@ class ProductOrder < ActiveRecord::Base def archived_total_fdp(fdp=self.product_fdp_archived) if fdp - if self.archived_total_articles < fdp.price_max + if self.archived_total_articles_ttc < fdp.price_max fdp.price else 0.0 @@ -160,7 +173,7 @@ class ProductOrder < ActiveRecord::Base end - def total_articles + def total_articles_ttc total = 0.0 product_order_products.each do |p| total += p.final_price_ttc_with_qty @@ -168,6 +181,15 @@ class ProductOrder < ActiveRecord::Base total end + + def total_articles_ht + total = 0.0 + product_order_products.each do |p| + total += p.final_price_ht_with_qty + end + total + end + def total_fdp(fdp=self.product_fdp) if fdp if self.total_ttc_without_fdp < fdp.price_max @@ -195,6 +217,34 @@ class ProductOrder < ActiveRecord::Base end + def commission_mlm_now + if self.product_customer.parent + i = 0 + parent_to_commission = self.product_customer.parent + + while parent_to_commission and i <= 12 + i += 1 + + if parent_to_commission.mlm_nbr_niveaux >= i + com_percent = (parent_to_commission.callif_now[:percents][i].to_f/100) + com = (com_percent*self.total_ht_without_fdp.to_f()).round(2) + puts "Commission à #{parent_to_commission.pseudo}: génération #{i}, #{com_percent}%, #{com}" + + parent_to_commission.commissions.create(:product_order => self, :commission_type_id => 10, :amount => com, :percent => com_percent, :generation => i, :devise_id => 1) + + end + + parent_to_commission = parent_to_commission.parent + + + end + + + end + end + + + protected def verify(size=16) diff --git a/app/models/product_order_product.rb b/app/models/product_order_product.rb index 23e9e09..1ccf1ef 100755 --- a/app/models/product_order_product.rb +++ b/app/models/product_order_product.rb @@ -18,6 +18,10 @@ class ProductOrderProduct < ActiveRecord::Base qty.to_f * product.final_price_ttc.to_f end + def final_price_ht_with_qty + qty.to_f * product.final_price_ht.to_f + end + def archived_price_ttc_with_qty diff --git a/app/models/virement.rb b/app/models/virement.rb new file mode 100644 index 0000000..86ccb2c --- /dev/null +++ b/app/models/virement.rb @@ -0,0 +1,63 @@ +class Virement < ActiveRecord::Base + belongs_to :devise + validates :amount_ht, :presence => true + belongs_to :product_customer + belongs_to :virement_remise + belongs_to :commission + belongs_to :account_rib + + + scope :execute_between, lambda { |start, stop| + execute_after(start).execute_before(stop) + } + + + scope :execute_after, lambda { |date| + joins(:virement_remise).where("(virement_remises.created_at >= ?)", date ) + } + scope :execute_before, lambda { |date| + where("(virement_remises.created_at <= ?)", date ) + } + + def generate_token + self.token = loop do + + token = SecureRandom.hex(6) + break token unless Virement.exists?(token: token) + end + + self.token + end + + + def name_for_edi + value = self.account_rib.name.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n, '').to_s + + # Remove single quotes from input + value.gsub!(/[']+/, '') + + # Replace any non-word character (\W) with a space + value.gsub!(/\W+/, ' ') + + # Remove any whitespace before and after the string + value.strip! + return value + end + + + before_validation do + if self.product_customer.virements.where("sended is null").count >= 1 + errors.add(:amount_ht, "Vous ne pouvez pas avoir plus d'un virements en attente d'execution.") + end + + if !self.product_customer.account_ribs.where(:id => self.account_rib.id, :validated => true).first or !self.account_rib.validated + errors.add(:account_rib, 'Compte sélectionné invalide') + + end + + if self.amount_ht.to_f < 5 or self.amount_ht.to_f > self.product_customer.max_virement + errors.add(:amount_ht, "Le montant doit être compris entre 5 € et #{self.product_customer.max_virement.to_i} €") + + end + end +end diff --git a/app/models/virement_remise.rb b/app/models/virement_remise.rb new file mode 100644 index 0000000..e171ac1 --- /dev/null +++ b/app/models/virement_remise.rb @@ -0,0 +1,20 @@ +class VirementRemise < ActiveRecord::Base + + has_many :virements + + + def init + self.amount = self.virements.sum(:amount_ttc) + + + self.token = loop do + + token = SecureRandom.hex(6) + break token unless VirementRemise.exists?(token: token) + end + + self.save + + + end +end diff --git a/app/uploaders/rib_uploader.rb b/app/uploaders/rib_uploader.rb new file mode 100644 index 0000000..bd1e62b --- /dev/null +++ b/app/uploaders/rib_uploader.rb @@ -0,0 +1,62 @@ +# -*- encoding : utf-8 -*- + +class RibUploader < CarrierWave::Uploader::Base + + # Include RMagick or ImageScience support: + # include CarrierWave::RMagick + # include CarrierWave::ImageScience + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :s3 + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "#{Rails.root}/private_medias/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + def url + #"/download_data_files/#{model.token}" + + end + + def extension_white_list + %w(jpg jpeg png pdf) + end + + # Provide a default URL as a default if there hasn't been a file uploaded: + def default_url + "/images/fallback/" + [version_name, "default.png"].compact.join('_') + end + + # Process files as they are uploaded: + # process :scale => [200, 300] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process :scale => [50, 50] + # end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + # def extension_white_list + # %w(jpg jpeg gif png) + # end + + # Override the filename of the uploaded files: + # def filename + # "something.jpg" if original_filename + # end + + def filename + File.basename(original_filename, File.extname(original_filename)).to_s.to_slug + File.extname(original_filename).to_s if original_filename + + + end + +end diff --git a/app/views/admin/product_orders/_product_order.html.haml b/app/views/admin/product_orders/_product_order.html.haml index 28ecb9c..28f4a60 100755 --- a/app/views/admin/product_orders/_product_order.html.haml +++ b/app/views/admin/product_orders/_product_order.html.haml @@ -20,7 +20,7 @@ %td - =number_to_currency product_order.archived_total_articles + =number_to_currency product_order.archived_total_articles_ttc %td =number_to_currency product_order.archived_total_fdp diff --git a/app/views/admin/product_orders/show.html.haml b/app/views/admin/product_orders/show.html.haml index 4a85314..d516fa4 100755 --- a/app/views/admin/product_orders/show.html.haml +++ b/app/views/admin/product_orders/show.html.haml @@ -32,7 +32,7 @@ %tr %td{:colspan => 5, :style => "border:0;"} %td Total : - %td= number_to_currency(@product_order.archived_total_articles, locale: :fr) + %td= number_to_currency(@product_order.archived_total_articles_ttc, locale: :fr) -if @product_order.vourcher_code_archived %tr @@ -42,7 +42,7 @@ ="("+@product_order.vourcher_code_archived.slug+") :" %td ="-" - =number_to_currency @product_order.archived_vourcher_reduction, locale: :fr + =number_to_currency @product_order.archived_vourcher_reduction_ttc, locale: :fr %tr %td{:colspan => 5, :style => "border:0;"} diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index 57125fb..cd88be3 100755 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -50,7 +50,7 @@ =current_product_customer.email - #header{:style => "background-image:url('#{@image_bandeau}');"} + #header{:style => "background-image:url('#{@image_bandeau}');"+("min-height:400px;"if @image_bandeau).to_s} @@ -68,6 +68,8 @@ .top_right %span#cart_infos =render :partial => "public/shared/cart" +     + =link_to i(:user), "/public/my_account/index" -if flash[:error] or flash[:notice] or flash[:alert] @@ -147,11 +149,13 @@ }); - #content - =yield + =yield =yield :bandeau -if @menu_item and @menu_item.id == 1 - =render :partial => "public/product_categories/bandeau",:collection => ProductCategory.where(parent_id: nil).order(:position), :as => :product_category + + .center.padding.row + + =render :partial => "public/product_categories/bandeau",:collection => ProductCategory.where(parent_id: nil).order(:position), :as => :product_category diff --git a/app/views/product_orders_mails/confirmation_cb.html.haml b/app/views/product_orders_mails/confirmation_cb.html.haml index 69e5e1c..88c9699 100755 --- a/app/views/product_orders_mails/confirmation_cb.html.haml +++ b/app/views/product_orders_mails/confirmation_cb.html.haml @@ -15,7 +15,7 @@ %strong Vitascreen %br - +33 6 52 66 90 82 + %br =link_to "contact@styandus.com", "mailto:contact@styandus.com" @@ -36,7 +36,7 @@ %strong Vitascreen %br - +33 6 52 66 90 82 + %br =link_to "contact@styandus.com", "mailto:contact@styandus.com" diff --git a/app/views/product_orders_mails/confirmation_cheque.html.haml b/app/views/product_orders_mails/confirmation_cheque.html.haml index abd8136..c80300b 100755 --- a/app/views/product_orders_mails/confirmation_cheque.html.haml +++ b/app/views/product_orders_mails/confirmation_cheque.html.haml @@ -12,12 +12,7 @@ Vous pouvez envoyer un chèque d'un montant de = number_to_currency(@product_order.total_ttc, locale: :fr) à l'ordre de StyAndUs à l'adresse suivante : - %br - Galerie La Forestière - %br - 1 rue de la Forestière - %br - 33970 CAP FERRET + %p Vous trouverez ci-dessous le récapitulatif de cette commande : @@ -28,7 +23,7 @@ %strong Vitascreen %br - +33 6 52 66 90 82 + %br =link_to "contact@styandus.com", "mailto:contact@styandus.com" @@ -46,13 +41,7 @@ Vous pouvez envoyer un chèque d'un montant de = number_to_currency(@product_order.total_ttc, locale: :fr) à l'ordre de StyAndUs à l'adresse suivante : - %br - Galerie La Forestière - %br - 1 rue de la Forestière - %br - 33970 CAP FERRET - + %p Vous trouverez ci-dessous le récapitulatif de cette commande : @@ -62,7 +51,7 @@ %strong Vitascreen %br - +33 6 52 66 90 82 + %br =link_to "contact@styandus.com", "mailto:contact@styandus.com" diff --git a/app/views/public/account_ribs/_form.html.haml b/app/views/public/account_ribs/_form.html.haml new file mode 100644 index 0000000..b24070b --- /dev/null +++ b/app/views/public/account_ribs/_form.html.haml @@ -0,0 +1,26 @@ += semantic_form_for [:public, @account_rib] do |f| + .alert.alert-info + %p + =qit "intro-saisie-rib" do + Merci de saisir votre RIB dans le formulaire suivant, en recopiant les informations telles que présentées sur votre RIB + =f.inputs do + + + = f.input :bank_name, :label => qit("label-nom-banque","Nom de la banque :"), :placeholder => "ex : CA Centre Est" + = f.input :bank_city, :label => qit("label-ville-banque","Ville de la banque :"), :placeholder => "ex : GRENOBLE" + = f.input :name, :label => qit("label-intitule-compte","Intitulé du compte :"), :placeholder => "ex : SARL DUPONT où M SERGE DUPONT" + = f.input :address, :label => qit("label-titulaire-compte", "Adresse du titulaire du compte: "), :placeholder => "ex : 13 rue de les Lilas" + = f.input :address2, :label => qit("label-complement-adresse","Complément d'adresse :"), :placeholder => "" + = f.input :cp, :label => qit("label-code-postal","Code postal :"), :placeholder => "" + = f.input :city, :label => "Ville", :placeholder => "" + + = f.input :country, :label => qit("label-pays-compte","Pays du compte"), :as => :select, :include_blank => false, :collection => ProductCustomer::COUNTRY.sort + = f.input :iban, :label => qit("label-iban","IBAN (sans espaces)"), :placeholder => "ex : FR7644444444444444444444444" + = f.input :bic, :label => qit("label-bic","Code BIC / swift"), :placeholder => "ex : AGRIFRPP878" + =f.input :tva, :label => qit("label-tva-case-a-cocher","Vous êtes un professionnel soumis à la TVA ?") + =f.input :tva_number, :label => qit("label-tva-number","Numéro de TVA intracom. :") + =f.input :scan_file, :label => qit("label-rib-file","Fichier du rib lisible (scanné ou version numérique au format pdf, jpg où png) :") + + =f.submit qit("save", "Sauvegarder"), :class => "btn btn-primary" + %br + %br \ No newline at end of file diff --git a/app/views/public/account_ribs/index.html.haml b/app/views/public/account_ribs/index.html.haml new file mode 100644 index 0000000..e6c16a0 --- /dev/null +++ b/app/views/public/account_ribs/index.html.haml @@ -0,0 +1,38 @@ +=render :partial => "public/my_account/menu" +.center + + + .padding + %h1=qit("title-bank-account","Comptes bancaires") + =link_to qit("add-bank-account","ajouter un compte bancaire"), new_public_account_rib_path, :class => "btn btn-primary" + %table.table{:style => "text-align:left"} + %tr + %th=qit("th-bank-account-alias","Intitulé du compte") + %th=qit("th-country", "Pays") + %th=qit("th-bank", "Banque") + %th=qit("th-iban","Iban") + %th=qit("th-tva","Tva") + %th=qit("th-statut","Statut") + %th + -@account_rib.each do |account_rib| + %tr + %td=account_rib.name + %td=account_rib.country + %td=account_rib.bank_name + %td=account_rib.iban + %td + -if account_rib.tva? + =account_rib.tva_number + %td + -if account_rib.validated? + =qit("bank-account-validate","Validé") + -else + =qit("bank-account-validate-progress","En cours de validation") + + %td + -if account_rib.scan_file? + Fichier reçu : + =account_rib.scan_file.file.filename + + + \ No newline at end of file diff --git a/app/views/public/account_ribs/new.html.haml b/app/views/public/account_ribs/new.html.haml new file mode 100644 index 0000000..69435d1 --- /dev/null +++ b/app/views/public/account_ribs/new.html.haml @@ -0,0 +1,8 @@ +=render :partial => "public/my_account/menu" +.center + + + %h1=qit("add-rib","Ajouter un RIB") + + =render :partial => "form" + \ No newline at end of file diff --git a/app/views/public/commissions/_commission.html.haml b/app/views/public/commissions/_commission.html.haml new file mode 100644 index 0000000..960bc87 --- /dev/null +++ b/app/views/public/commissions/_commission.html.haml @@ -0,0 +1,51 @@ +%tr + %td{:style => "width:120px"} + = l commission.created_at, :format => "%d %b %Y" + %td + -if commission.product_order + =commission.product_order.product_customer.pseudo + %td + + -if commission.commission_type_id == 1 + Commission directe + -elsif commission.commission_type_id == 2 + =i :sitemap + Commission binaire + -elsif commission.commission_type_id == 3 + Commission de participation + -elsif commission.commission_type_id == 4 + Virement vers votre compte + =commission.virement.account_rib.iban+", " + + référence du virement : + =commission.virement.token.upcase + %br + =link_to "Détail PDF", public_virement_path(commission.virement.token) if commission.virement.sended + + -elsif commission.commission_type_id == 14 + Virement vers votre compte hipay + =commission.hipay_virement.hipay_email+", " + + référence du virement : + =commission.hipay_virement.token.upcase + %br + =link_to "Détail PDF", public_hipay_virement_path(commission.hipay_virement.token) if commission.hipay_virement.sended + + + + -elsif commission.commission_type_id == 5 + Utilisation du solde pour commande de crédits + + %td + -if (commission.commission_type_id == 4 and !commission.virement.sended) + =i :"clock-o" + -elsif (commission.commission_type_id == 14 and !commission.hipay_virement.sended) + =i :"clock-o" + -elsif commission.commission_type_id == 5 and !commission.order_solde.paid + =link_to paid_public_order_path(commission.order_solde) do + =i :"clock-o" + finaliser ma commande en payant le solde par CB + + %td{:style => "text-align:right;min-width:100px;", :class => (commission.amount < 0 ? "red" : "green")} + =commission.amount < 0 ? "" : "+ " + =number_to_currency commission.amount \ No newline at end of file diff --git a/app/views/public/commissions/index.html.haml b/app/views/public/commissions/index.html.haml new file mode 100644 index 0000000..5232793 --- /dev/null +++ b/app/views/public/commissions/index.html.haml @@ -0,0 +1,65 @@ +=render :partial => "public/my_account/menu" +.center.padding + + + %h1 Commissions + .row + .col-md-4 + + .white + %h4 + Soldes + -if current_product_customer.commissions.sum(:amount) >= 2.00 + disponibles : + -else + disponible : + %h4{:style => "margin-bottom:0;"} + + %table.table + -Devise.where(:orderable => true).all.each do |devise| + %tr + %td + =devise.name + %td + + =number_to_currency current_product_customer.solde_commissions(devise.id), :unit => devise.icon + + + -if current_product_customer.commissions.sum(:amount) >= 10 and current_product_customer.virements.where("sended is null").count < 1 + + %p=link_to "Demander un retrait de commissions par virement SEPA (€)", new_public_virement_path + + %p=link_to "Demander un retrait de commissions par Hipay", new_public_hipay_virement_path + + .white + %h4 Comptes SEPA + -if current_product_customer.account_ribs.where(:validated => true).count > 0 + %table.table + -current_product_customer.account_ribs.each do |account_rib| + %tr + %td + =account_rib.bank_name + ="-" + =account_rib.iban[0..1] + XXXX + =account_rib.iban[-5..-1] + -elsif current_product_customer.account_ribs.count > 0 + %p Votre rib est en cours de validation par notre équipe, nous vous contacterons si nous avons besoin de plus d'informations. + -else + %p Pour pouvoir demander un virement de commission vous devez d'abord enregistrer un RIB. + + + %p + =link_to "Gérer mes comptes bancaires", public_account_ribs_path + + %p + Lorsque vous avez des commissions vous pouvez les utiliser pour acheter d'autres coffrets de crédits ou demander un virement sur un compte bancaire domicilié dans les pays éligibles. + + + .col-md-8 + .white + %h4 Historique des commissions + %table.table#commissions=render @commissions + + #pagination + = paginate @commissions \ No newline at end of file diff --git a/app/views/public/my_account/_address.html.haml b/app/views/public/my_account/_address.html.haml new file mode 100644 index 0000000..b6b9584 --- /dev/null +++ b/app/views/public/my_account/_address.html.haml @@ -0,0 +1,16 @@ += f.input :address, :label => "Adresse" += f.input :address2, :label => "Adresse (suite)" += f.input :cp, :label => "Code postal" += f.input :city, :label => "Ville" +-if @product_customer.id and ProductCustomer.find(@product_customer.id).country? + %strong Pays : + =@product_customer.country + %br + (pour modifier votre pays merci de contacter le support : support@sideplace.com) +-else + -f.object.country = "France" if !f.object.country? and f.object.force_address? + =# f.input :country, :label => "Pays", :as => :select, :include_blank => (@product_customer.force_address? ? false : true), :collection => ProductCustomer::COUNTRY_ORDER.sort + + = f.input :country, :label => "Pays", :locale => 'fr', :priority_countries => ["FR", "CH", "BE", "US", "GB", "CA"], :include_blank => (@product_customer.force_address? ? false : true) + + diff --git a/app/views/public/my_account/_binary_form.html.haml b/app/views/public/my_account/_binary_form.html.haml new file mode 100644 index 0000000..289e45c --- /dev/null +++ b/app/views/public/my_account/_binary_form.html.haml @@ -0,0 +1,5 @@ +-@product_customer = @product_customer || current_product_customer +- @product_customer.binary_preferences = 0 if !@product_customer.binary_preferences += semantic_form_for [:public, @product_customer], :remote => true do |f| + =f.input :binary_preferences, :collection => [["Automatique : branche la plus faible", 0], ["Branche gauche", 1], ["Branche droite", 2]] , :label => "Sélection de la branche binaire pour les nouveaux affiliés :", :as => :radio, :include_blank => false + =f.submit "Sauvegarder", :class => "btn btn-primary" diff --git a/app/views/public/my_account/_menu.haml b/app/views/public/my_account/_menu.haml new file mode 100644 index 0000000..ecdd59b --- /dev/null +++ b/app/views/public/my_account/_menu.haml @@ -0,0 +1,16 @@ + + +%nav#my_account_menu.navbar.navbar-inverse + .container-fluid + + .navbar-header{:class => ("active" if params[:controller] == "public/my_account" and params[:action] == "index")} + = link_to i(:user)+raw("  Mon compte"), public_my_account_path, :class => "navbar-brand" + %ul.nav.navbar-nav + + + + %li{:class => ("active" if params[:controller] == "public/my_account" and params[:action] == "edit_infos")}= link_to " Profil", public_edit_infos_path + %li{:class => ("active" if params[:controller] == "public/my_account" and params[:action] == "filleuls")}= link_to "Affiliés", public_filleuls_path + + %li{:class => ("active" if (params[:controller] == "public/commissions" and params[:action] == "index") or params[:controller] == "public/account_ribs")}= link_to "Commissions / virements", public_commissions_path + \ No newline at end of file diff --git a/app/views/public/my_account/_note_pays.html.haml b/app/views/public/my_account/_note_pays.html.haml new file mode 100644 index 0000000..7c5feb9 --- /dev/null +++ b/app/views/public/my_account/_note_pays.html.haml @@ -0,0 +1,3 @@ +.alert.alert-info + %strong Note concernant les pays + =render :partial => "public/my_account/text_pays" \ No newline at end of file diff --git a/app/views/public/my_account/_solde_credits.html.haml b/app/views/public/my_account/_solde_credits.html.haml new file mode 100644 index 0000000..2019cd6 --- /dev/null +++ b/app/views/public/my_account/_solde_credits.html.haml @@ -0,0 +1,13 @@ +.center.solde_credits + %p + =image_tag "/credit.png" + A ce jour vous avez + =current_product_customer.solde_credits(Date.today) + -if current_product_customer.solde_credits(Date.today) > 1 + crédits + -else + crédit + %br + %br + =link_to "acheter des crédits", public_credit_products_path, :class => "btn btn-primary btn-lg" + diff --git a/app/views/public/my_account/_text_pays.html.haml b/app/views/public/my_account/_text_pays.html.haml new file mode 100644 index 0000000..aa11e73 --- /dev/null +++ b/app/views/public/my_account/_text_pays.html.haml @@ -0,0 +1,51 @@ + +%p Tout le monde peut déposer des annonces localisées dans quasiment tous les pays du monde. +%p Les clients du monde entier peuvent acheter des crédits d'annonces pour mettre en valeur celles-ci. + +%p Tous nos clients peuvent utiliser les commissions touchées via le programme d'affiliation pour acheter d'autres crédits. + +%p Actuellement les clients ayant un compte dans ces pays peuvent recevoir leurs commissions par virement SEPA : + +%p + =ProductCustomer::COUNTRY.sort.join(" - ") +%hr + +-countries = [] +-HipayCountry.where(:enabled => true).all.each do |hc| + -c = ISO3166::Country.new hc.code_pays + -countries << c.translations["fr"].to_s+" (#{hc.code_pays})" if c.translations["fr"] + + +%p + Les clients de ces pays + ="(#{countries.size})" + peuvent recevoir leur commissions sur leur compte + =link_to "Hipay Wallet*", "https://www.hipaywallet.com", :target => "_blank" + (en le créant gratuitement si ils n'en ont pas déjà un) + =":" + +%p + + .row-fluid{:style => "text-align:left;"} + + .col-md-4 + -count = 0 + -countries.sort.each do |c| + -count += 1 + =c + %br + -if count == 55 or count == 110 + =raw("
") + + .clear +%br + + +%p Si vous souhaitez participer au programme d'affiliation et toucher des commissions sur votre compte bancaire mais que celui-ci n'est pas dans un des pays de la liste, contactez-nous et nous étudierons la situation pour trouver une solution si possible. + +%p D'autres pays seront très prochainement ajoutés à la liste des pays supportés automatiquement. +%hr + +%p + *Hipay Wallet est un portefeuille éléctronique, une fois vos commissions reçu sur ce portefeuille vous pourrez les utiliser sur les sites acceptant les paiements par Hipay Wallet ou retirer votre argent sur votre compte bancaire, pour plus d'information sur la société veuillez suivre ce lien : + =link_to "https://www.hipaywallet.com/info/about-us", "https://www.hipaywallet.com/info/about-us", :target => "_blank" \ No newline at end of file diff --git a/app/views/public/my_account/binary.haml b/app/views/public/my_account/binary.haml new file mode 100644 index 0000000..6163f48 --- /dev/null +++ b/app/views/public/my_account/binary.haml @@ -0,0 +1,51 @@ +=render :partial => "public/my_account/menu" +.center{:style => "position:relative"} + + + %h1 Réseau binaire + + %p Vous touchez désormais des commissions sur tous vos affiliés directs et indirects sur 10 générations, il n'y a plus de notions de branche forte où branche faible. Vous touchez donc des commissions sur chacune des ventes de ces affiliés, en instantané. + %p Vous pouvez accéder à la liste de vos affiliés directs et indirectes par la page "mes affiliés" + + +-if 1 == 2 + %p + -if current_product_customer.binary_active_count == 0 + Il n'y a pas encored'inscrits faisant parti de vos affiliés directs dans votre binaire + -elsif current_product_customer.binary_active_count == 1 + Il y a actuellement + un inscrit faisant parti de vos affiliés directs dans votre binaire + -else + Il y a actuellement + =current_product_customer.binary_active_count + inscrits faisant parti de vos affiliés directs dans votre binaire + %p + =render :partial => "public/my_account/binary_form" + + .left_binary + =current_product_customer.left_binary_points + points + -if left = ProductCustomer.where(:binary_parent_id => current_product_customer.id, :binary_side => 1).first + %br + =left.binary_child_ids.size + 1 + =left.binary_child_ids.size > 0 ? "affiliés" : "affilié" + + .right_binary + =current_product_customer.right_binary_points + points + -if right = ProductCustomer.where(:binary_parent_id => current_product_customer.id, :binary_side => 2).first + %br + =right.binary_child_ids.size + 1 + =right.binary_child_ids.size > 0 ? "affiliés" : "affilié" + + + + -@binary_table = ProductCustomer.get_tree(@parrain) + + + -@nbr_levels = 4 + + + + + =render :partial => "public/product_customers/index_binary" \ No newline at end of file diff --git a/app/views/public/my_account/edit_infos.html.haml b/app/views/public/my_account/edit_infos.html.haml new file mode 100644 index 0000000..c474d39 --- /dev/null +++ b/app/views/public/my_account/edit_infos.html.haml @@ -0,0 +1,44 @@ +=render :partial => "public/my_account/menu" + +.center.padding + + + %h1 Modifier mon profil + -@product_customer = @product_customer || current_product_customer + + = semantic_form_for [:public, @product_customer] do |f| + =f.inputs do + = f.input :email, :label => "Email" + + + .row + .col-md-6 + + %h3= qit "Adresse de facturation titre", "Adresse de facturation" + %p +   + =f.semantic_fields_for :particular_bill do |f| + =render :partial => "public/product_orders/particular_form", :locals => {:f => f} + + + + + + + -@particular_idem = f.object.particular_idem + + + + .col-md-6 + %h3=qit "Adresse de livraison titre", "Adresse de livraison" + %p=f.input :particular_idem, :label => qit("phrase-adresse-identique","Adresse de livraison identique à l'adresse de facturation ?"), :input_html => {:onchange => "particular_idem()", :id => "particular_idem_checkbox"} + + #particular_send + + =f.semantic_fields_for :particular_send do |f| + + =render :partial => "public/product_orders/particular_form", :locals => {:f => f} + + =f.submit "Sauvegarder", :class => "btn btn-primary" + %br + \ No newline at end of file diff --git a/app/views/public/my_account/favoris.html.haml b/app/views/public/my_account/favoris.html.haml new file mode 100644 index 0000000..8141c79 --- /dev/null +++ b/app/views/public/my_account/favoris.html.haml @@ -0,0 +1,11 @@ +.center.search_results.padding + + + + %h1 Mes annonces favorites + + -if @annonces.count > 0 + =render :partial => "public/annonces/index" + -else + %p + Pour ajouter une annonce dans vos favoris, vous avez juste à cliquer sur la petite étoile en haut à droite de l'image des annonces que vous préférez. \ No newline at end of file diff --git a/app/views/public/my_account/filleuls.haml b/app/views/public/my_account/filleuls.haml new file mode 100644 index 0000000..a318020 --- /dev/null +++ b/app/views/public/my_account/filleuls.haml @@ -0,0 +1,96 @@ +=render :partial => "public/my_account/menu" +.center.padding + + + %h1 Mes affiliés + + + + -i = 0 + -if current_product_customer.mlm_children_id_by_levels[1].size > 0 + .white + %table.table.table-striped + + + %tr + %th + Génération + %th + Nombre d'affiliés + + + -while i != 10 do + + -i += 1 + + -if current_product_customer.mlm_children_id_by_levels[i].size > 0 + %tr + %td + =i + %td + =current_product_customer.mlm_children_id_by_levels[i].size + + -else + .white + %p + Vous n'avez pas encore d'affiliés, n'hésitez pas à donner votre lien de recommandation à vos amis ! + %p + Votre code de recommandation : + %span{:style => "font-size:1.2em;"} + =current_product_customer.mlm_token.upcase + %p + Votre lien de recommandation : + =link_to mlm_token_url(current_product_customer.mlm_token), mlm_token_url(current_product_customer.mlm_token) + %p + Lorsque que quelqu'un s'inscrit avec votre lien de recommandation nous lui offrons 10 crédits gratuits et nous vous en offrons 5, utilisables pour mettre en valeur vos annonces. + + + + + + + + + -i = 0 + - parents_id = current_product_customer.id + + %table.table.table-striped + + + + -while i != 10 do + + -i += 1 + -filleuls = ProductCustomer.where(:parent_id => parents_id) + -parents_id = filleuls.select(:id).map{ |v| v.id} + + -if filleuls.count > 0 + %h3 + Génération + =i + + %table.table + %tr + + %th Nom + %th Nombre de commandes + %th Affiliés + %th Code de recommandation + + -filleuls.each do |filleul| + %tr.filleul + + + %td{:style => "vertical-align:middle;"}= filleul.pseudo + %td{:style => "vertical-align:middle;"} + -if filleul.product_orders.where(:paid => true).count > 0 + =filleul.product_orders.where(:paid => true).count + %td{:style => "vertical-align:middle;"} + =filleul.children.count + + %td + =link_to filleul.mlm_token.upcase, mlm_token_url(filleul.mlm_token)# if filleul.not_blocked + + + + diff --git a/app/views/public/my_account/index.html.haml b/app/views/public/my_account/index.html.haml new file mode 100644 index 0000000..7c3d06e --- /dev/null +++ b/app/views/public/my_account/index.html.haml @@ -0,0 +1,101 @@ + +=render :partial => "public/my_account/menu" + + + +.center.padding + + + + -if false + .alert.alert-warning + %h1 Vous devez valider votre adresse mail. + %p Vous avez du recevoir un message pour valider votre adresse mail. Tant que vous n'aurez pas cliquer sur le lien présent sur ce mail votre compte ne sera pas activé. + %p + Le mail a été envoyé à l'adresse : + %strong= current_product_customer.email + =link_to "renvoyer le mail de confirmation", public_reconfirm_email_path, :class => "btn btn-primary" + + +.padding + + +-if false and !current_product_customer.uid? + .facebook_connexion.blue_background{:style => "padding:2em 0;padding-top:3.5em;background:rgba(51,141,232,1);color:white;margin-bottom:1em;"} + %p{:style => "text-align:center;"} + Vous avez un compte facebook ? Liez votre compte Vitascreen en deux clics ! Vous pourrez ensuite vous connecter directement par Facebook. + %p{:style => "text-align:center;"} + =link_to i(:facebook) + raw("  Lier mon compte Facebook") , "/auth/facebook" , style: "background-color:#3b5998;color:white;", class: "btn btn-lg" + %p{:style => "text-align:center;font-size:0.9em;color:white;"} + Vitascreen ne publiera rien sur votre compte Facebook. + %br + Les autres utilisateurs Vitascreen ne verront pas votre compte Facebook sans votre accord. + + -if params[:fb_alert] + .alert.alert-danger{:style => "margin:auto;max-width:800px;"} + =flash[:alert] + +.product_customer_dashboard.center.padding + .row + + + -if current_product_customer.parent + .col-md-3 + .panel.panel-default + .panel-heading + Votre recommandeur : + + .panel-body + + + + + + =link_to public_product_customer_path(current_product_customer.parent) do + + + .binary_account{:class => ""} + + = current_product_customer.parent.pseudo + + + .col-md-3 + .panel.panel-default + .panel-heading + Mes commissions + + .panel-body + + Le solde de vos commissions : + %table.table + -Devise.where(:orderable => true).all.each do |devise| + %tr + %td + =devise.name + %td + + =number_to_currency current_product_customer.solde_commissions(devise.id), :unit => devise.icon + + + + + + .col-md-6 + .panel.panel-default + .panel-heading + Recommander le site + + .panel-body + %p + Votre code de recommandation : + %span{:style => "font-size:1.2em;"} + =current_product_customer.mlm_token.upcase + %p + Votre lien de recommandation : + =link_to mlm_token_url(current_product_customer.mlm_token), mlm_token_url(current_product_customer.mlm_token) + %p + Lorsque que quelqu'un s'inscrit avec votre lien de recommandation nous lui offrons 10 crédits gratuits et nous vous en offrons 5, utilisables pour mettre en valeur vos annonces. + + + + diff --git a/app/views/public/my_account/my_annonces.html.haml b/app/views/public/my_account/my_annonces.html.haml new file mode 100644 index 0000000..fa23bfe --- /dev/null +++ b/app/views/public/my_account/my_annonces.html.haml @@ -0,0 +1,2 @@ +%h1 Public::MyAccountController#my_annonces +%p Find me in app/views/public/my_account_controller/my_annonces.html.haml diff --git a/app/views/public/product_categories/_bandeau.html.haml b/app/views/public/product_categories/_bandeau.html.haml index 0b3e2aa..6dc1003 100644 --- a/app/views/public/product_categories/_bandeau.html.haml +++ b/app/views/public/product_categories/_bandeau.html.haml @@ -1,5 +1,6 @@ =link_to public_product_category_path(:id => product_category.id, :slug => product_category.lang(I18n.locale).slug) do - .category-container - =image_tag product_category.image_file.file.url if product_category.image_file - .category-title - = product_category.lang(I18n.locale).name \ No newline at end of file + .col-md-4 + .category-container{:style => "background-image:url('#{(product_category.image_file.file.url if product_category.image_file)}');"} + + .category-title + = product_category.lang(I18n.locale).name \ No newline at end of file diff --git a/app/views/public/product_customers/_new_form.haml b/app/views/public/product_customers/_new_form.haml index fbdd202..85ea346 100755 --- a/app/views/public/product_customers/_new_form.haml +++ b/app/views/public/product_customers/_new_form.haml @@ -1,6 +1,5 @@ .center{:style => "text-align:center"} #new_product_customer_form_container - %h1= qit "Pas encore de compte ?", "Pas encore de compte ?" = semantic_form_for [:public, @product_customer] do |f| diff --git a/app/views/public/product_orders/_mail_recap.html.haml b/app/views/public/product_orders/_mail_recap.html.haml index b010d8c..bfc4a5f 100644 --- a/app/views/public/product_orders/_mail_recap.html.haml +++ b/app/views/public/product_orders/_mail_recap.html.haml @@ -32,7 +32,7 @@ %tr %td{:colspan => 5, :style => "border:0;"} %td Total : - %td= number_to_currency(@product_order.archived_total_articles, locale: :fr) + %td= number_to_currency(@product_order.archived_total_articles_ttc, locale: :fr) -if @product_order.vourcher_code_archived @@ -43,7 +43,7 @@ ="("+@product_order.vourcher_code_archived.slug+") :" %td ="-" - =number_to_currency @product_order.archived_vourcher_reduction, locale: :fr + =number_to_currency @product_order.archived_vourcher_reduction_ttc, locale: :fr diff --git a/app/views/public/product_orders/my_cart.html.haml b/app/views/public/product_orders/my_cart.html.haml index 4c88836..7afca7d 100755 --- a/app/views/public/product_orders/my_cart.html.haml +++ b/app/views/public/product_orders/my_cart.html.haml @@ -7,15 +7,15 @@ -if @product_order.vourcher_code %div.pull-right - = "Total articles : " + number_to_currency(@product_order.total_articles, locale: :fr) + = "Total articles : " + number_to_currency(@product_order.total_articles_ttc, locale: :fr) .clear %div.pull-right =qit "Code réduction tableau", "Code de réduction " ="("+@product_order.vourcher_code.slug+") :" - =number_to_currency @product_order.vourcher_reduction + =number_to_currency @product_order.vourcher_reduction_ttc .clear %div.pull-right - = "Total : " + number_to_currency((@product_order.total_articles-@product_order.vourcher_reduction) , locale: :fr) + = "Total : " + number_to_currency((@product_order.total_articles_ttc-@product_order.vourcher_reduction_ttc) , locale: :fr) .clear %center diff --git a/app/views/public/product_orders/payment_instructions.html.haml b/app/views/public/product_orders/payment_instructions.html.haml index 3c5d2c7..fe51555 100644 --- a/app/views/public/product_orders/payment_instructions.html.haml +++ b/app/views/public/product_orders/payment_instructions.html.haml @@ -5,12 +5,7 @@ Pour finaliser celle-ci, merci de nous envoyer votre réglement par chèque d'un montant de = number_to_currency(@product_order_ar.total_ttc, locale: :fr) à l'ordre de StyAndUs à l'adresse suivante : - %br - Galerie La Forestière - %br - 1 rue de la Forestière - %br - 33970 CAP FERRET + %p Si vous souhaitez finalement payer cette commande par carte banque vous pouvez la retrouver dans votre compte client. diff --git a/app/views/public/product_orders/select_payment.html.haml b/app/views/public/product_orders/select_payment.html.haml index 5773bc2..c8c580c 100755 --- a/app/views/public/product_orders/select_payment.html.haml +++ b/app/views/public/product_orders/select_payment.html.haml @@ -10,7 +10,7 @@ %tr %td{:colspan => 5, :style => "border:0;"} %td Total : - %td= number_to_currency(@product_order.total_articles, locale: :fr) + %td= number_to_currency(@product_order.total_articles_ttc, locale: :fr) -if @product_order.vourcher_code %tr @@ -20,7 +20,7 @@ ="("+@product_order.vourcher_code.slug+") :" %td ="-" - =number_to_currency @product_order.vourcher_reduction, locale: :fr + =number_to_currency @product_order.vourcher_reduction_ttc, locale: :fr diff --git a/app/views/public/products/show.html.haml b/app/views/public/products/show.html.haml index 941b6c4..47ef8fe 100755 --- a/app/views/public/products/show.html.haml +++ b/app/views/public/products/show.html.haml @@ -1,4 +1,4 @@ -.product_show +.center.product_show .row .col_images diff --git a/app/views/public/virements/_form.html.haml b/app/views/public/virements/_form.html.haml new file mode 100644 index 0000000..cac2d6e --- /dev/null +++ b/app/views/public/virements/_form.html.haml @@ -0,0 +1,19 @@ +=semantic_form_for [:public, @virement] do |f| + + + = f.inputs do + =f.hidden_field :devise_id + =f.input :account_rib, :label => "Compte bénéficiaire", :as => :select, :include_blank => false, :collection => f.object.product_customer.account_ribs.where(:validated => true), :member_label => :iban + %p Veuillez indiquer ci dessous le montant du virement demandé (hors frais) + %p + Votre solde de commissions est de + =number_to_currency current_product_customer.solde_commissions(1) + vous pouvez donc demander un virement de + =number_to_currency current_product_customer.max_virement(1) + (Actuellement 5€ de frais par virements) + + + + =f.input :amount_ht, :label => "Montant :" + + =f.submit "Sauvegarder", :class => "btn btn-primary" diff --git a/app/views/public/virements/confirm.html.haml b/app/views/public/virements/confirm.html.haml new file mode 100644 index 0000000..c757f7e --- /dev/null +++ b/app/views/public/virements/confirm.html.haml @@ -0,0 +1,26 @@ + +=render :partial => "public/my_account/menu" +.center + + + %h1 Demander un virement de commission + %p + Vous avez demander un virement de + =number_to_currency @virement.amount_ht, :unit => @virement.devise.icon + vers le compte + =@virement.account_rib.iban + ="." + %p + En incluant les frais de virement de 5€, + =number_to_currency (@virement.amount_ht + 5.0), :unit => @virement.devise.icon + seront déduit de votre solde de commissions. + %p Votre compte sera crédité sous 1 à 3 jours ouvré suivant la banque de votre compte. + =semantic_form_for [:public, @virement] do |f| + =f.hidden_field :account_rib_id + =f.hidden_field :amount_ht + =f.hidden_field :devise_id + + =hidden_field_tag :confirm, true + + =f.submit "Confirmer ma demande", :class => "btn btn-primary" + \ No newline at end of file diff --git a/app/views/public/virements/index.html.haml b/app/views/public/virements/index.html.haml new file mode 100644 index 0000000..6a91c17 --- /dev/null +++ b/app/views/public/virements/index.html.haml @@ -0,0 +1,40 @@ +=render :partial => "public/my_account/menu" + +.center.padding + + + .padding + %h1 Comptes bancaires + =link_to "Demander un virement de commissions", new_public_virement_path, :class => "btn btn-primary" + %table.table{:style => "text-align:left"} + %tr + %th Intitulé du compte + %th Pays + %th Banque + %th + Iban + %th + Tva + %th Statut + %th + -@virements.each do |virement| + %tr + %td=virement.name + %td=virement.country + %td=virement.bank_name + %td=virement.iban + %td + -if virement.tva? + =virement.tva_number + %td + -if virement.validated? + Validé + -else + En cours de validation + %td + -if virement.scan_file? + Fichier reçu : + =virement.scan_file.file.filename + + + \ No newline at end of file diff --git a/app/views/public/virements/new.html.haml b/app/views/public/virements/new.html.haml new file mode 100644 index 0000000..12bb174 --- /dev/null +++ b/app/views/public/virements/new.html.haml @@ -0,0 +1,22 @@ +=render :partial => "public/my_account/menu" +.center.padding + + + %h3 Demander un virement de commission + .white + + -if current_product_customer.account_ribs.where(:validated => true).count > 0 + =render :partial => "form" + -elsif current_product_customer.account_ribs.count > 0 + %p + Vous devez attendre que nous ayons validé votre RIB pour pouvoir effectuer une demande de virement. Une fois saisis les RIBs sont généralement validés dans les 48h. + Vous pouvez suivre l'état sur cette page : + %p + =link_to "Gérer mes comptes bancaires", public_account_ribs_path + -else + %p + Vous devez enregistrer un RIB pour pouvoir demander un virement de vos commissions. Une fois saisi le RIB sera généralement activé dans les 48h. Vous pouvez enregistrer vos RIBs à sur cette page : + %p + =link_to "Gérer mes comptes bancaires", public_account_ribs_path + + \ No newline at end of file diff --git a/app/views/public/virements/show.html.haml b/app/views/public/virements/show.html.haml new file mode 100644 index 0000000..088d21a --- /dev/null +++ b/app/views/public/virements/show.html.haml @@ -0,0 +1,145 @@ +!!! +%html + %head + + %meta{:"http-equiv" => "Content-Type", :content=>"text/html; charset=UTF-8"} + %meta{:name=>"viewport", :content=>"width=device-width,initial-scale=1"} + :css + body{ + font-size:11pt; + padding :0px; + margin:0px; + background-color: transparent; + + font-family:"Arial" ; + } + #main{ + //margin-left:4.2cm; + + } + td, th{ + //border:1px solid black; + padding:5px; + vertical-align:top; + + } + th{ + font-weight:normal; + border-bottom:1px solid gray; + text-align:right; + } + + table{ + border-collapse:collapse; + + } + + tr{ + page-break-inside:avoid; + + } + + #bottom{ + page-break-inside:avoid; + + } + .right{ + text-align:right; + + } + .line p{ + margin:0px; + } + .description{ + padding-top:2pt; + display:block; + + } + + .bot_separate{ + height:50pt; + + } + + + + + + + + + + %body + #main + %div{:style => "height:2cm;"} + + + #document_info{:style => "position:absolute;top:2cm;left:12cm;"} + =#"Facture n°#{current_product_customer.bill_number}" + %br + ="Le #{l(@virement.created_at, :format => :date)}" + #recipient_address{:style => "position:absolute;top:5cm;left:12cm;"} + + -if current_product_customer.organisation? + =current_product_customer.organisation + + -else + =current_product_customer.firstname + =current_product_customer.name + + %br + =current_product_customer.address + %br + -if current_product_customer.address2? + =current_product_customer.address2 + %br + + =current_product_customer.cp + =current_product_customer.city + %br + =current_product_customer.country + + + + #header{:style => ""} + + + + %div{:style => "margin-top:8cm;margin-left:1cm;margin-right:1cm;margin-bottom:0cm;position:relative;"} + %p + %strong Note de virement de commission + %p + Référence du virement : + %strong= @virement.token.upcase + %p + Date de la demande de virement : + %strong= @virement.created_at + %p + Référence compte destinataire : + %strong= @virement.account_rib.iban + %p + Montant du virement : + %strong=number_to_currency @virement.amount_ttc + -tva = true if @virement.tva.to_f > 0 + -if tva + %p + dont + =number_to_currency @virement.tva + de TVA + ( + Votre numéro de TVA : + =@virement.account_rib.tva_number + ) + + + + #footer{:style => "margin:1cm 1cm;margin-top:5cm"} + + + %p Important : Nous vous rappelons que vous devez déclarer les commissions que nous vous versons dans vos revenus ou dans les recettes de votre structure. En cas de doute sur la manière de déclarer vos commissions n'hésitez pas à vous rapprocher d'une personne compétente comme un expert comptable par exemple. + + + + + + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 2038966..7daac95 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,8 +13,11 @@ Rails.application.routes.draw do get "sitemap.:f" => "public/sitemap#sitemap" - scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do + + + scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do + get 'p/:mlm_token' => "public/product_customers#parrainage", :as => :mlm_token get "cat/:id/:slug.:format" => "public/product_categories#show", :as => :public_product_category, :format => "html" get "produit/:id/:slug.:format" => "public/products#show", :as => :public_product, :format => "html" get "" => 'public/menu_items#show' @@ -88,6 +91,23 @@ Rails.application.routes.draw do end namespace :public do + + get 'my_account/favoris', :as => "favs" + get 'my_account/filleuls', :as => "filleuls" + get 'my_account/binary', :as => "binary" + get 'my_account/index', :as => "my_account" + get 'my_account/edit_infos', :as => "edit_infos" + get 'my_account/my_annonces', :as => "my_annonces" + get 'my_account/reconfirm', :as => "reconfirm_email" + + resources :virements + + resources :commissions + + resources :account_ribs + + + resources :press_releases resources :label_produits do collection do diff --git a/db/migrate/20150614143556_create_commissions.rb b/db/migrate/20150614143556_create_commissions.rb new file mode 100644 index 0000000..7cfa1e1 --- /dev/null +++ b/db/migrate/20150614143556_create_commissions.rb @@ -0,0 +1,15 @@ +class CreateCommissions < ActiveRecord::Migration + def change + create_table :commissions do |t| + t.references :product_customer, index: true + t.decimal :amount, precision: 10, scale: 2 + t.boolean :canceled + t.datetime :canceled_at + t.integer :commission_type_id + t.integer :product_order_id + + t.timestamps null: false + end + add_foreign_key :commissions, :product_customers + end +end diff --git a/db/migrate/20150710094053_add_rbt_to_commissions.rb b/db/migrate/20150710094053_add_rbt_to_commissions.rb new file mode 100644 index 0000000..29f74e9 --- /dev/null +++ b/db/migrate/20150710094053_add_rbt_to_commissions.rb @@ -0,0 +1,7 @@ +class AddRbtToCommissions < ActiveRecord::Migration + def change + add_column :commissions, :canceled_id, :integer + add_column :commissions, :binary_point_id, :integer + + end +end diff --git a/db/migrate/20150710105519_create_account_ribs.rb b/db/migrate/20150710105519_create_account_ribs.rb new file mode 100644 index 0000000..ccb5c6d --- /dev/null +++ b/db/migrate/20150710105519_create_account_ribs.rb @@ -0,0 +1,28 @@ +class CreateAccountRibs < ActiveRecord::Migration + def change + create_table :account_ribs do |t| + t.references :product_customer, index: true + t.string :bank_name + t.string :bank_city + t.string :country + t.string :name + t.string :address + t.string :address2 + t.string :cp + t.string :city + t.string :iban + t.string :bic + t.string :tva_number + t.boolean :tva + t.boolean :enabled + t.boolean :validated + t.datetime :validated_at + t.boolean :archived + t.datetime :archived_at + t.string :scan_file + + t.timestamps null: false + end + + end +end diff --git a/db/migrate/20150712190240_add_count_part_com_id_to_commissions.rb b/db/migrate/20150712190240_add_count_part_com_id_to_commissions.rb new file mode 100644 index 0000000..714fdf9 --- /dev/null +++ b/db/migrate/20150712190240_add_count_part_com_id_to_commissions.rb @@ -0,0 +1,5 @@ +class AddCountPartComIdToCommissions < ActiveRecord::Migration + def change + + end +end diff --git a/db/migrate/20150716094451_create_virement_remises.rb b/db/migrate/20150716094451_create_virement_remises.rb new file mode 100644 index 0000000..1d1cdd5 --- /dev/null +++ b/db/migrate/20150716094451_create_virement_remises.rb @@ -0,0 +1,14 @@ +class CreateVirementRemises < ActiveRecord::Migration + def change + create_table :virement_remises do |t| + t.string :token + t.decimal :amount, :precision => 10, :scale => 2 + t.integer :virement_type_id + t.boolean :sended + t.boolean :confirmed + t.string :note + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20150716095743_create_virements.rb b/db/migrate/20150716095743_create_virements.rb new file mode 100644 index 0000000..aa6ecc9 --- /dev/null +++ b/db/migrate/20150716095743_create_virements.rb @@ -0,0 +1,24 @@ +class CreateVirements < ActiveRecord::Migration + def change + create_table :virements do |t| + t.string :token + t.integer :virement_type_id + t.boolean :sended + t.boolean :confirmed + t.boolean :done + t.string :note + t.references :product_customer, index: true + t.references :virement_remise, index: true + t.decimal :amount_ht, :precision => 10, :scale => 2 + t.decimal :amount_ttc, :precision => 10, :scale => 2 + t.decimal :tva, :precision => 10, :scale => 2 + t.decimal :frais + t.decimal :solde + t.references :commission, index: true + t.references :account_rib, index: true + + t.timestamps null: false + end + + end +end diff --git a/db/migrate/20151003193230_create_devises.rb b/db/migrate/20151003193230_create_devises.rb new file mode 100644 index 0000000..ad545bf --- /dev/null +++ b/db/migrate/20151003193230_create_devises.rb @@ -0,0 +1,12 @@ +class CreateDevises < ActiveRecord::Migration + def change + create_table :devises do |t| + t.string :name + t.string :icon + t.string :code + t.decimal :rate, :precision => 10, :scale => 2 + t.string :text_format + t.timestamps null: false + end + end +end diff --git a/db/migrate/20151008144610_add_percent_to_commissions.rb b/db/migrate/20151008144610_add_percent_to_commissions.rb new file mode 100644 index 0000000..68d1cd8 --- /dev/null +++ b/db/migrate/20151008144610_add_percent_to_commissions.rb @@ -0,0 +1,6 @@ +class AddPercentToCommissions < ActiveRecord::Migration + def change + add_column :commissions, :percent, :decimal, :precision => 10, :scale => 2 + add_column :commissions, :generation, :integer + end +end diff --git a/db/migrate/20151229204119_add_orderable_to_devises.rb b/db/migrate/20151229204119_add_orderable_to_devises.rb new file mode 100644 index 0000000..bbb82a4 --- /dev/null +++ b/db/migrate/20151229204119_add_orderable_to_devises.rb @@ -0,0 +1,5 @@ +class AddOrderableToDevises < ActiveRecord::Migration + def change + add_column :devises, :orderable, :boolean + end +end diff --git a/db/migrate/20151229210641_add_devise_to_virements.rb b/db/migrate/20151229210641_add_devise_to_virements.rb new file mode 100644 index 0000000..589e20b --- /dev/null +++ b/db/migrate/20151229210641_add_devise_to_virements.rb @@ -0,0 +1,8 @@ +class AddDeviseToVirements < ActiveRecord::Migration + def change + add_reference :virements, :devise, index: true + add_foreign_key :virements, :devises + + Virement.all.update_all(:devise_id => 1) + end +end diff --git a/db/migrate/20151229210736_add_devise_to_virement_remises.rb b/db/migrate/20151229210736_add_devise_to_virement_remises.rb new file mode 100644 index 0000000..68a1fb6 --- /dev/null +++ b/db/migrate/20151229210736_add_devise_to_virement_remises.rb @@ -0,0 +1,8 @@ +class AddDeviseToVirementRemises < ActiveRecord::Migration + def change + add_reference :virement_remises, :devise, index: true + add_foreign_key :virement_remises, :devises + + VirementRemise.all.update_all(:devise_id => 1) + end +end diff --git a/db/migrate/20151229210904_add_devise_to_commissions.rb b/db/migrate/20151229210904_add_devise_to_commissions.rb new file mode 100644 index 0000000..985c102 --- /dev/null +++ b/db/migrate/20151229210904_add_devise_to_commissions.rb @@ -0,0 +1,8 @@ +class AddDeviseToCommissions < ActiveRecord::Migration + def change + add_reference :commissions, :devise, index: true + add_foreign_key :commissions, :devises + + Commission.all.update_all(:devise_id => 1) + end +end diff --git a/db/migrate/20160112150541_add_facebook_fields_to_users.rb b/db/migrate/20160112150541_add_facebook_fields_to_users.rb new file mode 100644 index 0000000..68934b8 --- /dev/null +++ b/db/migrate/20160112150541_add_facebook_fields_to_users.rb @@ -0,0 +1,6 @@ +class AddFacebookFieldsToUsers < ActiveRecord::Migration + def change + add_column :product_customers, :provider, :string + add_column :product_customers, :uid, :string + end +end diff --git a/db/migrate/20160112180801_add_facebook_token_to_users.rb b/db/migrate/20160112180801_add_facebook_token_to_users.rb new file mode 100644 index 0000000..91802b0 --- /dev/null +++ b/db/migrate/20160112180801_add_facebook_token_to_users.rb @@ -0,0 +1,5 @@ +class AddFacebookTokenToUsers < ActiveRecord::Migration + def change + add_column :product_customers, :facebook_token, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index a71cad8..82266ee 100755 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,6 +13,32 @@ ActiveRecord::Schema.define(version: 20160428093204) do + create_table "account_ribs", force: :cascade do |t| + t.integer "product_customer_id", limit: 4 + t.string "bank_name", limit: 255 + t.string "bank_city", limit: 255 + t.string "country", limit: 255 + t.string "name", limit: 255 + t.string "address", limit: 255 + t.string "address2", limit: 255 + t.string "cp", limit: 255 + t.string "city", limit: 255 + t.string "iban", limit: 255 + t.string "bic", limit: 255 + t.string "tva_number", limit: 255 + t.boolean "tva", limit: 1 + t.boolean "enabled", limit: 1 + t.boolean "validated", limit: 1 + t.datetime "validated_at" + t.boolean "archived", limit: 1 + t.datetime "archived_at" + t.string "scan_file", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "account_ribs", ["product_customer_id"], name: "index_account_ribs_on_product_customer_id", using: :btree + create_table "admins", force: :cascade do |t| t.string "name", limit: 255 t.string "firstname", limit: 255 @@ -166,6 +192,27 @@ ActiveRecord::Schema.define(version: 20160428093204) do t.boolean "newsletter", limit: 1 end + create_table "commissions", force: :cascade do |t| + t.integer "product_customer_id", limit: 4 + t.decimal "amount", precision: 10, scale: 2 + t.boolean "canceled", limit: 1 + t.datetime "canceled_at" + t.integer "commission_type_id", limit: 4 + t.integer "order_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "canceled_id", limit: 4 + t.integer "binary_point_id", limit: 4 + t.integer "count_part_com_id", limit: 4 + t.decimal "percent", precision: 10, scale: 2 + t.integer "generation", limit: 4 + t.integer "devise_id", limit: 4 + end + + add_index "commissions", ["count_part_com_id"], name: "index_commissions_on_count_part_com_id", using: :btree + add_index "commissions", ["devise_id"], name: "index_commissions_on_devise_id", using: :btree + add_index "commissions", ["product_customer_id"], name: "index_commissions_on_product_customer_id", using: :btree + create_table "data_file_categories", force: :cascade do |t| t.string "name", limit: 255 t.string "slug", limit: 255 @@ -192,6 +239,17 @@ ActiveRecord::Schema.define(version: 20160428093204) do add_index "data_files", ["image_file_id"], name: "index_data_files_on_image_file_id", using: :btree + create_table "devises", force: :cascade do |t| + t.string "name", limit: 255 + t.string "icon", limit: 255 + t.string "code", limit: 255 + t.decimal "rate", precision: 10, scale: 2 + t.string "text_format", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.boolean "orderable", limit: 1 + end + create_table "download_contents", force: :cascade do |t| t.string "title", limit: 255 t.string "style", limit: 255 @@ -578,6 +636,9 @@ ActiveRecord::Schema.define(version: 20160428093204) do t.string "mlm_token", limit: 255 t.boolean "parent_at_create", limit: 1 t.string "parent_code", limit: 255 + t.string "provider", limit: 255 + t.string "uid", limit: 255 + t.string "facebook_token", limit: 255 end create_table "product_fdps", force: :cascade do |t| @@ -927,6 +988,47 @@ ActiveRecord::Schema.define(version: 20160428093204) do t.datetime "updated_at" end + create_table "virement_remises", force: :cascade do |t| + t.string "token", limit: 255 + t.decimal "amount", precision: 10, scale: 2 + t.integer "virement_type_id", limit: 4 + t.boolean "sended", limit: 1 + t.boolean "confirmed", limit: 1 + t.string "note", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "devise_id", limit: 4 + end + + add_index "virement_remises", ["devise_id"], name: "index_virement_remises_on_devise_id", using: :btree + + create_table "virements", force: :cascade do |t| + t.string "token", limit: 255 + t.integer "virement_type_id", limit: 4 + t.boolean "sended", limit: 1 + t.boolean "confirmed", limit: 1 + t.boolean "done", limit: 1 + t.string "note", limit: 255 + t.integer "product_customer_id", limit: 4 + t.integer "virement_remise_id", limit: 4 + t.decimal "amount_ht", precision: 10, scale: 2 + t.decimal "amount_ttc", precision: 10, scale: 2 + t.decimal "tva", precision: 10, scale: 2 + t.decimal "frais", precision: 10 + t.decimal "solde", precision: 10 + t.integer "commission_id", limit: 4 + t.integer "account_rib_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "devise_id", limit: 4 + end + + add_index "virements", ["account_rib_id"], name: "index_virements_on_account_rib_id", using: :btree + add_index "virements", ["commission_id"], name: "index_virements_on_commission_id", using: :btree + add_index "virements", ["devise_id"], name: "index_virements_on_devise_id", using: :btree + add_index "virements", ["product_customer_id"], name: "index_virements_on_product_customer_id", using: :btree + add_index "virements", ["virement_remise_id"], name: "index_virements_on_virement_remise_id", using: :btree + create_table "vourcher_codes", force: :cascade do |t| t.boolean "archived", limit: 1, default: false t.string "slug", limit: 255 @@ -940,6 +1042,8 @@ ActiveRecord::Schema.define(version: 20160428093204) do add_foreign_key "articles", "article_authors" add_foreign_key "block_contents", "image_files" + add_foreign_key "commissions", "devises" + add_foreign_key "commissions", "product_customers" add_foreign_key "data_files", "image_files" add_foreign_key "home_slider_slides", "home_sliders" add_foreign_key "lang_pages", "lang_sites" @@ -959,4 +1063,6 @@ ActiveRecord::Schema.define(version: 20160428093204) do add_foreign_key "products", "product_categories" add_foreign_key "products", "product_collections" add_foreign_key "video_files", "image_files" + add_foreign_key "virement_remises", "devises" + add_foreign_key "virements", "devises" end