From 2957c7a5e78d38dd1688432afb6e3a8f522a57ff Mon Sep 17 00:00:00 2001 From: Augusto Samame Date: Sat, 10 Sep 2022 13:35:12 -0500 Subject: [PATCH 01/10] work on woocomerce invoicing 1 --- .ruby-version | 2 +- .../ecommerce/orders_controller.rb | 10 + app/models/ecommerce/order.rb | 220 ++++++++++++++++++ config/routes.rb | 1 + lib/ecommerce/version.rb | 2 +- 5 files changed, 233 insertions(+), 2 deletions(-) diff --git a/.ruby-version b/.ruby-version index 6bf7c6fa..849c0c47 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.5.1 +ruby-2.7.5 diff --git a/app/controllers/ecommerce/orders_controller.rb b/app/controllers/ecommerce/orders_controller.rb index 81532ea3..806c6eca 100644 --- a/app/controllers/ecommerce/orders_controller.rb +++ b/app/controllers/ecommerce/orders_controller.rb @@ -29,6 +29,16 @@ def show render "ecommerce/#{Ecommerce.ecommerce_layout}/order/show" end + def einvoice_webhook + einvoice_data = JSON.parse(params[:data]) + result = Order.new.generate_einvoice_from_woocommerce(einvoice_data) + if result[:success] + render json: { einvoice_number: result[:einvoice_number] } + else + render json: { error: result[:error] }, :status => 422 + end + end + def culqi_webhook if params[:object] == "event" && params[:type] == "order.status.changed" Rollbar.info("Webhook Received", diff --git a/app/models/ecommerce/order.rb b/app/models/ecommerce/order.rb index ec2f5a7b..6885de9a 100644 --- a/app/models/ecommerce/order.rb +++ b/app/models/ecommerce/order.rb @@ -313,5 +313,225 @@ def clear_einvoice self.save end + def generate_einvoice_from_woocommerce(payload) + return {einvoice_number: rand(1..100).to_s.rjust(8, "0") } + invoice_lines_array = Array.new + line = 0 + weight = 0.0 + total_order_amount = (self.amount).to_f - (self.points_redeemed_amount.to_f / 100) + discount_total = ((self.discount_amount).to_f.abs + (self.points_redeemed_amount.to_f / 100)) / 1.18 + #since igv amount is taken by certifact as the sum of igv lines, the igv in tax lines need to be reduced based on the discount + OrderItem.where(order_id: self.id).includes(:product).each do |item| + invoice_lines_array << {name: item.product.name, quantity: item.quantity, product_id: item.product.id, price_total: (item.price * item.quantity).to_f, price_subtotal: item.price.to_f, weight: (item.quantity * item.product.weight).to_f } + igv_found = item.product.product_taxes.find_by(tax_id: Ecommerce::Tax.first.try(:id)) + weight += (item.quantity * item.product.weight).to_f + if igv_found + invoice_lines_array[line][:igv_tax] = true + invoice_lines_array[line][:igv_amount] = igv_found.try(:tax_amount) + else + invoice_lines_array[line][:igv_tax] = false + invoice_lines_array[line][:igv_amount] = 0 + end + isc_found = item.product.product_taxes.find_by(tax_id: Ecommerce::Tax.second.try(:id)) + if isc_found + invoice_lines_array[line][:isc_tax] = true + invoice_lines_array[line][:isc_amount] = isc_found.try(:tax_amount) + else + invoice_lines_array[line][:isc_tax] = false + invoice_lines_array[line][:isc_amount] = 0 + end + line +=1 + end + if self.shipping_amount_cents > 0 + invoice_lines_array << {name: "Costo de envío (shipping)", quantity: 1, product_id: 1000, price_total: shipping_amount.to_i, price_subtotal: shipping_amount.to_i, igv_tax: true, igv_amount: 18 } + end + + case self.payment_status + when "paid" + return false if efact_number + case self.efact_type + when "boleta" + invoice_hash = { + einvoice_type: "boleta", + number: "B#{Ecommerce.serie_boleta}-#{Ecommerce::Control.find_by!(name: "next_boleta_number").integer_value}", + currency_id: "USD", + id: self.id, + zip: "030101", + catalog_06_id: (self.required_doc.blank? || self.required_doc.try(:strip).try(:length) == 8) ? "1 - DNI" : "4 - CARNET DE EXTRANJERIA", + partner_id: "#{self.user.first_name} #{self.user.last_name} (#{self.user.username})", + company_id: Ecommerce.company_legal_name, + email: self.user.email, + vat: self.amount.to_i >= 210 ? self.required_doc : "", + company_id_city: Ecommerce.company_city, + company_id_street: Ecommerce.company_street, + date_invoice: smart_date_invoice, + payment_term_id: "Contado", + date: smart_date_invoice, + amount_total: total_order_amount, + discount_total: discount_total, + weight: weight, + observation: self.delivery_comments, + company_id_zip: 33, + partner_shipping_id: "shipping_id", + company_id_vat: Ecommerce.company_vat, + street: payload.try(:street), + district_id: payload.try(:district), + province_id: payload.try(:city), + state_id: payload.try(:state), + invoice_line_ids: invoice_lines_array + } + correlativo_to_update_on_200 = Ecommerce::Control.find_by!(name: "next_boleta_number") + when "factura" + invoice_hash = { + einvoice_type: "factura", + number: "F#{Ecommerce.serie_factura}-#{Ecommerce::Control.find_by!(name: "next_factura_number").integer_value}", + currency_id: "USD", + id: self.id, + zip: "030101", + catalog_06_id: "6 - RUC", + partner_id: Ecommerce::DataBizInvoice.find_by(user_id: self.user.id).try(:razon_social) + " (#{self.user.username})", + company_id: Ecommerce.company_legal_name, + email: self.user.email, + vat: Ecommerce::DataBizInvoice.find_by(user_id: self.user.id).try(:vat), + company_id_city: Ecommerce.company_city, + company_id_street: Ecommerce.company_street, + date_invoice: smart_date_invoice, + payment_term_id: "Contado", + date: smart_date_invoice, + amount_total: total_order_amount, + discount_total: discount_total, + weight: weight, + observation: self.delivery_comments, + company_id_zip: 33, + partner_shipping_id: "shipping_id", + company_id_vat: Ecommerce.company_vat, + street: payload.try(:street), + district_id: payload.try(:district), + province_id: payload.try(:city), + state_id: payload.try(:state), + street_razon_social: Ecommerce::DataBizInvoice.find_by(user_id: self.user.id).try(:address), + district_id_razon_social: "", + province_id_razon_social: Ecommerce::DataBizInvoice.find_by(user_id: self.user.id).try(:city), + state_id_razon_social: Ecommerce::DataBizInvoice.find_by(user_id: self.user.id).try(:city), + invoice_line_ids: invoice_lines_array + } + correlativo_to_update_on_200 = Ecommerce::Control.find_by!(name: "next_factura_number") + end + when "refunded" + return false if !efact_number || efact_refund_number + case self.efact_number[0] + when "B" + invoice_hash = { + einvoice_type: "nota_de_credito", + number: "B#{Ecommerce.serie_nota_de_credito}-#{Ecommerce::Control.find_by!(name: "next_nota_de_credito_boleta_number").integer_value}", + affected_document: self.efact_number, + currency_id: "USD", + id: self.id, + zip: "030101", + catalog_06_id: (self.required_doc.blank? || self.required_doc.try(:strip).try(:length) == 8) ? "1 - DNI" : "4 - CARNET DE EXTRANJERIA", + partner_id: "#{self.user.first_name} #{self.user.last_name}", + company_id: Ecommerce.company_legal_name, + email: self.user.email, + vat: self.amount.to_i >= 210 ? self.required_doc : "", + company_id_city: Ecommerce.company_city, + company_id_street: Ecommerce.company_street, + date_invoice: smart_date_invoice, + payment_term_id: "Contado", + date: smart_date_invoice, + amount_total: total_order_amount, + company_id_zip: 33, + partner_shipping_id: "shipping_id", + company_id_vat: Ecommerce.company_vat, + street: payload.try(:street), + district_id: payload.try(:district), + province_id: payload.try(:city), + state_id: payload.try(:state), + invoice_line_ids: invoice_lines_array + } + correlativo_to_update_on_200 = Ecommerce::Control.find_by!(name: "next_nota_de_credito_boleta_number") + when "F" + invoice_hash = { + einvoice_type: "nota_de_credito", + number: "F#{Ecommerce.serie_nota_de_credito}-#{Ecommerce::Control.find_by!(name: "next_nota_de_credito_factura_number").integer_value}", + affected_document: self.efact_number, + currency_id: "USD", + id: self.id, + zip: "030101", + catalog_06_id: "6 - RUC", + partner_id: Ecommerce::DataBizInvoice.find_by(user_id: self.user.id).try(:razon_social), + company_id: Ecommerce.company_legal_name, + email: self.user.email, + vat: Ecommerce::DataBizInvoice.find_by(user_id: self.user.id).try(:vat), + company_id_city: Ecommerce.company_city, + company_id_street: Ecommerce.company_street, + date_invoice: smart_date_invoice, + payment_term_id: "Contado", + date: smart_date_invoice, + amount_total: total_order_amount, + company_id_zip: 33, + partner_shipping_id: "shipping_id", + company_id_vat: Ecommerce.company_vat, + street: payload.try(:street), + district_id: payload.try(:district), + province_id: payload.try(:city), + state_id: payload.try(:state), + street_razon_social: Ecommerce::DataBizInvoice.find_by(user_id: self.user.id).try(:address), + district_id_razon_social: "", + province_id_razon_social: Ecommerce::DataBizInvoice.find_by(user_id: self.user.id).try(:city), + state_id_razon_social: Ecommerce::DataBizInvoice.find_by(user_id: self.user.id).try(:city), + invoice_line_ids: invoice_lines_array + } + correlativo_to_update_on_200 = Ecommerce::Control.find_by!(name: "next_nota_de_credito_factura_number") + end + when "payment_void" + return false if !efact_number + invoice_hash = { + einvoice_type: "anulacion", + affected_document: self.efact_number, + void_reason: "Cancelación" + } + else + invoice_hash = { + error: "invoice is unpaid" + } + end + + url = URI(Ecommerce::Control.find_by(name: 'efact_url').text_value) + puts "invoice_hash: #{invoice_hash.to_json} sent to #{url}" + Rails.logger.debug "invoice_hash: #{invoice_hash.to_json} sent to #{url}" + http = Net::HTTP.new(url.host, url.port) + http.use_ssl = true if url.scheme == "https" + request = Net::HTTP::Post.new(url) + request["Content-Type"] = 'application/json' + #TODO add type of authentication field in backoffice to support Bearer Token + request["Authorization"] = "Bearer #{Ecommerce::Control.find_by!(name: "efact_token").text_value}" + request["Cache-Control"] = 'no-cache' + request.body = invoice_hash.to_json + self.update_columns(efact_sent_text: invoice_hash.to_json) + response = http.request(request) + if response.code == "200" + response_body = JSON.parse(response.read_body) + if response.read_body && response_body["response_text"] == "OK" + case invoice_hash[:einvoice_type] + when "nota_de_credito" + self.update_columns(efact_response_text: "OK", efact_refund_url: response_body["response_url"], efact_refund_number: invoice_hash[:number] ) + when "anulacion" + self.update_columns(efact_response_text: "OK", efact_void_url: response_body["response_url"] ) + else + self.update_columns(efact_response_text: "OK", efact_invoice_url: response_body["response_url"], efact_number: invoice_hash[:number] ) + end + correlativo_to_update_on_200.update_columns(integer_value: correlativo_to_update_on_200.integer_value + 1) if correlativo_to_update_on_200 + else + self.update_columns(efact_response_text: "Internal Error #{response.code} - #{response_body["response_text"]}") + AdminMailer.einvoice_error_email(self).deliver! #unless Rails.env == "development" + end + return response_body.to_json + else + self.update_columns(efact_response_text: "Internal Error #{response.code}") + AdminMailer.einvoice_error_email(self).deliver! #unless Rails.env == "development" + return response.read_body + end + end + end end diff --git a/config/routes.rb b/config/routes.rb index e8bfc2c1..92b17d6b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -72,6 +72,7 @@ post '/calculate_coupon', :to => 'orders#calculate_coupon' post '/culqi_webhook', :to => 'orders#culqi_webhook' + post '/einvoice_webhook', :to => 'orders#einvoice_webhook' resources :carts, except: [:index, :new, :create] resources :cart_items diff --git a/lib/ecommerce/version.rb b/lib/ecommerce/version.rb index d8317340..c775487d 100644 --- a/lib/ecommerce/version.rb +++ b/lib/ecommerce/version.rb @@ -1,3 +1,3 @@ module Ecommerce - VERSION = '0.7.2.3' + VERSION = '0.7.2.4' end From dc5409cfebe125497d713ca16cb06963b5694dda Mon Sep 17 00:00:00 2001 From: Augusto Samame Date: Sat, 10 Sep 2022 13:47:51 -0500 Subject: [PATCH 02/10] work on woocomerce invoicing 2 --- app/controllers/ecommerce/orders_controller.rb | 4 ++-- lib/ecommerce/version.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/ecommerce/orders_controller.rb b/app/controllers/ecommerce/orders_controller.rb index 806c6eca..b3c354ae 100644 --- a/app/controllers/ecommerce/orders_controller.rb +++ b/app/controllers/ecommerce/orders_controller.rb @@ -3,8 +3,8 @@ module Ecommerce class OrdersController < ApplicationController - skip_before_action :verify_authenticity_token, only: [:culqi_webhook] - skip_before_action :authenticate_user!, only: [:culqi_webhook] + skip_before_action :verify_authenticity_token, only: [:culqi_webhook, :einvoice_webhook] + skip_before_action :authenticate_user!, only: [:culqi_webhook, :einvoice_webhook] prepend_view_path "ecommerce/store/#{Ecommerce.ecommerce_layout}" before_action :set_order, only: [:show] diff --git a/lib/ecommerce/version.rb b/lib/ecommerce/version.rb index c775487d..cdada1ad 100644 --- a/lib/ecommerce/version.rb +++ b/lib/ecommerce/version.rb @@ -1,3 +1,3 @@ module Ecommerce - VERSION = '0.7.2.4' + VERSION = '0.7.2.5' end From 29116ab1c58cc3bca7fa93ee51bde966e992bc3b Mon Sep 17 00:00:00 2001 From: Augusto Samame Date: Mon, 12 Sep 2022 00:10:28 -0500 Subject: [PATCH 03/10] fix Fog class --- app/controllers/ecommerce/orders_controller.rb | 10 ---------- config/initializers/fix_fog.rb | 1 + 2 files changed, 1 insertion(+), 10 deletions(-) create mode 100644 config/initializers/fix_fog.rb diff --git a/app/controllers/ecommerce/orders_controller.rb b/app/controllers/ecommerce/orders_controller.rb index b3c354ae..5e9675e1 100644 --- a/app/controllers/ecommerce/orders_controller.rb +++ b/app/controllers/ecommerce/orders_controller.rb @@ -29,16 +29,6 @@ def show render "ecommerce/#{Ecommerce.ecommerce_layout}/order/show" end - def einvoice_webhook - einvoice_data = JSON.parse(params[:data]) - result = Order.new.generate_einvoice_from_woocommerce(einvoice_data) - if result[:success] - render json: { einvoice_number: result[:einvoice_number] } - else - render json: { error: result[:error] }, :status => 422 - end - end - def culqi_webhook if params[:object] == "event" && params[:type] == "order.status.changed" Rollbar.info("Webhook Received", diff --git a/config/initializers/fix_fog.rb b/config/initializers/fix_fog.rb new file mode 100644 index 00000000..8778e577 --- /dev/null +++ b/config/initializers/fix_fog.rb @@ -0,0 +1 @@ +module CarrierWave; module Storage; class Fog; end; end; end \ No newline at end of file From 286574cb40435a11fe8c4eb5e4334c0243cc96d4 Mon Sep 17 00:00:00 2001 From: Augusto Samame Date: Mon, 12 Sep 2022 00:10:48 -0500 Subject: [PATCH 04/10] bump version --- lib/ecommerce/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ecommerce/version.rb b/lib/ecommerce/version.rb index cdada1ad..38082727 100644 --- a/lib/ecommerce/version.rb +++ b/lib/ecommerce/version.rb @@ -1,3 +1,3 @@ module Ecommerce - VERSION = '0.7.2.5' + VERSION = '0.7.2.6' end From f4be95a268ec2ecd9ecb321006db9484a59d8b15 Mon Sep 17 00:00:00 2001 From: Augusto Samame Date: Mon, 12 Sep 2022 01:10:19 -0500 Subject: [PATCH 05/10] remove all references to Fog --- config/initializers/carrierwave.rb | 16 ++++++++-------- config/initializers/culqi.rb | 4 ++-- config/initializers/fix_fog.rb | 2 +- lib/ecommerce/version.rb | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index 6bc6ea09..a3603284 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -6,13 +6,13 @@ Dotenv::Railtie.load - config.fog_provider = 'fog/aws' + #config.fog_provider = 'fog/aws' - config.fog_credentials = { - :provider => 'AWS', - :aws_access_key_id => ENV["S3_AWS_ACCESS_KEY_ID"] || "A12345", - :aws_secret_access_key => ENV["S3_AWS_SECRET_ACCESS_KEY"] || "A12345" - } - config.fog_directory = ENV["CARRIERWAVE_CONFIG_FOG_DIRECTORY"] - config.storage = :fog + #config.fog_credentials = { + # :provider => 'AWS', + #:aws_access_key_id => ENV["S3_AWS_ACCESS_KEY_ID"] || "A12345", + #:aws_secret_access_key => ENV["S3_AWS_SECRET_ACCESS_KEY"] || "A12345" + #} + #config.fog_directory = ENV["CARRIERWAVE_CONFIG_FOG_DIRECTORY"] + #config.storage = :fog end diff --git a/config/initializers/culqi.rb b/config/initializers/culqi.rb index 493b2d86..9a8375d3 100644 --- a/config/initializers/culqi.rb +++ b/config/initializers/culqi.rb @@ -1,4 +1,4 @@ if ActiveRecord::Base.connection.table_exists? 'ecommerce_payment_methods' - Culqi.public_key = Ecommerce::PaymentMethod.find_by(name: "Card", processor: "Culqi").try(:key) - Culqi.secret_key = Ecommerce::PaymentMethod.find_by(name: "Card", processor: "Culqi").try(:secret) + #Culqi.public_key = Ecommerce::PaymentMethod.find_by(name: "Card", processor: "Culqi").try(:key) + #Culqi.secret_key = Ecommerce::PaymentMethod.find_by(name: "Card", processor: "Culqi").try(:secret) end diff --git a/config/initializers/fix_fog.rb b/config/initializers/fix_fog.rb index 8778e577..5ab163fb 100644 --- a/config/initializers/fix_fog.rb +++ b/config/initializers/fix_fog.rb @@ -1 +1 @@ -module CarrierWave; module Storage; class Fog; end; end; end \ No newline at end of file +#module CarrierWave; module Storage; class Fog; end; end; end \ No newline at end of file diff --git a/lib/ecommerce/version.rb b/lib/ecommerce/version.rb index 38082727..fb797213 100644 --- a/lib/ecommerce/version.rb +++ b/lib/ecommerce/version.rb @@ -1,3 +1,3 @@ module Ecommerce - VERSION = '0.7.2.6' + VERSION = '0.7.2.7' end From ffac668a585de7f50cd7f899fdcc4b8de6d87a6c Mon Sep 17 00:00:00 2001 From: Augusto Samame Date: Mon, 12 Sep 2022 03:06:27 -0500 Subject: [PATCH 06/10] disable fog in uploaders --- app/uploaders/ecommerce/brand_logo_uploader.rb | 2 +- app/uploaders/ecommerce/campaign_image_uploader.rb | 2 +- .../ecommerce/category_home_image_uploader.rb | 2 +- app/uploaders/ecommerce/category_image_uploader.rb | 2 +- app/uploaders/ecommerce/product_image_uploader.rb | 2 +- app/uploaders/ecommerce/slider_image_uploader.rb | 2 +- config/initializers/carrierwave.rb | 12 ++++++------ lib/ecommerce/version.rb | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/uploaders/ecommerce/brand_logo_uploader.rb b/app/uploaders/ecommerce/brand_logo_uploader.rb index 9d37e3ff..6a774d4b 100644 --- a/app/uploaders/ecommerce/brand_logo_uploader.rb +++ b/app/uploaders/ecommerce/brand_logo_uploader.rb @@ -7,7 +7,7 @@ class Ecommerce::BrandLogoUploader < CarrierWave::Uploader::Base # Choose what kind of storage to use for this uploader: #storage :file - storage :fog + #storage :fog # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: diff --git a/app/uploaders/ecommerce/campaign_image_uploader.rb b/app/uploaders/ecommerce/campaign_image_uploader.rb index 4b848f16..b9d770cb 100644 --- a/app/uploaders/ecommerce/campaign_image_uploader.rb +++ b/app/uploaders/ecommerce/campaign_image_uploader.rb @@ -7,7 +7,7 @@ class Ecommerce::CampaignImageUploader < CarrierWave::Uploader::Base # Choose what kind of storage to use for this uploader: #storage :file - storage :fog + #storage :fog # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: diff --git a/app/uploaders/ecommerce/category_home_image_uploader.rb b/app/uploaders/ecommerce/category_home_image_uploader.rb index 48ea7ae9..8851f444 100644 --- a/app/uploaders/ecommerce/category_home_image_uploader.rb +++ b/app/uploaders/ecommerce/category_home_image_uploader.rb @@ -7,7 +7,7 @@ class Ecommerce::CategoryHomeImageUploader < CarrierWave::Uploader::Base # Choose what kind of storage to use for this uploader: #storage :file - storage :fog + #storage :fog # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: diff --git a/app/uploaders/ecommerce/category_image_uploader.rb b/app/uploaders/ecommerce/category_image_uploader.rb index 95755b92..9f17a624 100644 --- a/app/uploaders/ecommerce/category_image_uploader.rb +++ b/app/uploaders/ecommerce/category_image_uploader.rb @@ -7,7 +7,7 @@ class Ecommerce::CategoryImageUploader < CarrierWave::Uploader::Base # Choose what kind of storage to use for this uploader: #storage :file - storage :fog + #storage :fog # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: diff --git a/app/uploaders/ecommerce/product_image_uploader.rb b/app/uploaders/ecommerce/product_image_uploader.rb index 49b17aa6..dfd18a79 100644 --- a/app/uploaders/ecommerce/product_image_uploader.rb +++ b/app/uploaders/ecommerce/product_image_uploader.rb @@ -7,7 +7,7 @@ class Ecommerce::ProductImageUploader < CarrierWave::Uploader::Base # Choose what kind of storage to use for this uploader: #storage :file - storage :fog + #storage :fog # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: diff --git a/app/uploaders/ecommerce/slider_image_uploader.rb b/app/uploaders/ecommerce/slider_image_uploader.rb index c212a31e..034fd255 100644 --- a/app/uploaders/ecommerce/slider_image_uploader.rb +++ b/app/uploaders/ecommerce/slider_image_uploader.rb @@ -7,7 +7,7 @@ class Ecommerce::SliderImageUploader < CarrierWave::Uploader::Base # Choose what kind of storage to use for this uploader: #storage :file - storage :fog + #storage :fog # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index a3603284..19e30f89 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -1,10 +1,10 @@ -require 'carrierwave' -require 'carrierwave/storage/fog' -require 'dotenv-rails' +#require 'carrierwave' +#require 'carrierwave/storage/fog' +#require 'dotenv-rails' -CarrierWave.configure do |config| +#CarrierWave.configure do |config| - Dotenv::Railtie.load + #Dotenv::Railtie.load #config.fog_provider = 'fog/aws' @@ -15,4 +15,4 @@ #} #config.fog_directory = ENV["CARRIERWAVE_CONFIG_FOG_DIRECTORY"] #config.storage = :fog -end +#end diff --git a/lib/ecommerce/version.rb b/lib/ecommerce/version.rb index fb797213..0ee53bdb 100644 --- a/lib/ecommerce/version.rb +++ b/lib/ecommerce/version.rb @@ -1,3 +1,3 @@ module Ecommerce - VERSION = '0.7.2.7' + VERSION = '0.7.2.8' end From adfe6e4fee8f3075728d230c9046d5e58b6ba198 Mon Sep 17 00:00:00 2001 From: Augusto Samame Date: Mon, 12 Sep 2022 03:45:08 -0500 Subject: [PATCH 07/10] remove carrierwave --- app/uploaders/ecommerce/brand_logo_uploader.rb | 2 +- app/uploaders/ecommerce/campaign_image_uploader.rb | 2 +- app/uploaders/ecommerce/category_home_image_uploader.rb | 2 +- app/uploaders/ecommerce/category_image_uploader.rb | 2 +- app/uploaders/ecommerce/product_image_uploader.rb | 2 +- app/uploaders/ecommerce/slider_image_uploader.rb | 2 +- ecommerce.gemspec | 2 +- lib/ecommerce/version.rb | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/uploaders/ecommerce/brand_logo_uploader.rb b/app/uploaders/ecommerce/brand_logo_uploader.rb index 6a774d4b..da8f41c0 100644 --- a/app/uploaders/ecommerce/brand_logo_uploader.rb +++ b/app/uploaders/ecommerce/brand_logo_uploader.rb @@ -1,5 +1,5 @@ class Ecommerce::BrandLogoUploader < CarrierWave::Uploader::Base - include CarrierWave::MiniMagick + #include CarrierWave::MiniMagick # Include RMagick or MiniMagick support: # include CarrierWave::RMagick diff --git a/app/uploaders/ecommerce/campaign_image_uploader.rb b/app/uploaders/ecommerce/campaign_image_uploader.rb index b9d770cb..af9c95b2 100644 --- a/app/uploaders/ecommerce/campaign_image_uploader.rb +++ b/app/uploaders/ecommerce/campaign_image_uploader.rb @@ -1,5 +1,5 @@ class Ecommerce::CampaignImageUploader < CarrierWave::Uploader::Base - include CarrierWave::MiniMagick + #include CarrierWave::MiniMagick # Include RMagick or MiniMagick support: # include CarrierWave::RMagick diff --git a/app/uploaders/ecommerce/category_home_image_uploader.rb b/app/uploaders/ecommerce/category_home_image_uploader.rb index 8851f444..8aeb5acc 100644 --- a/app/uploaders/ecommerce/category_home_image_uploader.rb +++ b/app/uploaders/ecommerce/category_home_image_uploader.rb @@ -1,5 +1,5 @@ class Ecommerce::CategoryHomeImageUploader < CarrierWave::Uploader::Base - include CarrierWave::MiniMagick + #include CarrierWave::MiniMagick # Include RMagick or MiniMagick support: # include CarrierWave::RMagick diff --git a/app/uploaders/ecommerce/category_image_uploader.rb b/app/uploaders/ecommerce/category_image_uploader.rb index 9f17a624..afd80a1f 100644 --- a/app/uploaders/ecommerce/category_image_uploader.rb +++ b/app/uploaders/ecommerce/category_image_uploader.rb @@ -1,5 +1,5 @@ class Ecommerce::CategoryImageUploader < CarrierWave::Uploader::Base - include CarrierWave::MiniMagick + #include CarrierWave::MiniMagick # Include RMagick or MiniMagick support: # include CarrierWave::RMagick diff --git a/app/uploaders/ecommerce/product_image_uploader.rb b/app/uploaders/ecommerce/product_image_uploader.rb index dfd18a79..e82cba12 100644 --- a/app/uploaders/ecommerce/product_image_uploader.rb +++ b/app/uploaders/ecommerce/product_image_uploader.rb @@ -1,5 +1,5 @@ class Ecommerce::ProductImageUploader < CarrierWave::Uploader::Base - include CarrierWave::MiniMagick + #include CarrierWave::MiniMagick # Include RMagick or MiniMagick support: # include CarrierWave::RMagick diff --git a/app/uploaders/ecommerce/slider_image_uploader.rb b/app/uploaders/ecommerce/slider_image_uploader.rb index 034fd255..fc42f525 100644 --- a/app/uploaders/ecommerce/slider_image_uploader.rb +++ b/app/uploaders/ecommerce/slider_image_uploader.rb @@ -1,5 +1,5 @@ class Ecommerce::SliderImageUploader < CarrierWave::Uploader::Base - include CarrierWave::MiniMagick + #include CarrierWave::MiniMagick # Include RMagick or MiniMagick support: # include CarrierWave::RMagick diff --git a/ecommerce.gemspec b/ecommerce.gemspec index d3838200..d6577986 100644 --- a/ecommerce.gemspec +++ b/ecommerce.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.add_dependency 'decorators' s.add_dependency 'kaminari'#, "~> 1.1.1" s.add_dependency 'friendly_id'#, '~> 5.1.0' - s.add_dependency 'carrierwave'#, '~> 1.2.1' + #s.add_dependency 'carrierwave'#, '~> 1.2.1' s.add_dependency 'fog-aws'#, '~> 1.4.1' s.add_dependency 'mini_magick'#, '~> 4.8.0' s.add_dependency 'social-share-button' diff --git a/lib/ecommerce/version.rb b/lib/ecommerce/version.rb index 0ee53bdb..22f1df07 100644 --- a/lib/ecommerce/version.rb +++ b/lib/ecommerce/version.rb @@ -1,3 +1,3 @@ module Ecommerce - VERSION = '0.7.2.8' + VERSION = '0.7.2.9' end From 8befa877bbc90aa2058c4d0e1dc84a060b907504 Mon Sep 17 00:00:00 2001 From: Augusto Samame Date: Thu, 5 Jan 2023 18:04:18 -0500 Subject: [PATCH 08/10] add logging for einvoice webhook --- app/controllers/ecommerce/orders_controller.rb | 6 ++++++ lib/ecommerce/version.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/ecommerce/orders_controller.rb b/app/controllers/ecommerce/orders_controller.rb index 5e9675e1..9cc6e15b 100644 --- a/app/controllers/ecommerce/orders_controller.rb +++ b/app/controllers/ecommerce/orders_controller.rb @@ -54,6 +54,12 @@ def culqi_webhook head :ok end + def einvoice_webhook + Rails.logger.info "Webhook Received" + Rails.logger.info params + Rails.logger.info params.to_json + end + def calculate_coupon puts params found_coupon = Coupon.find_by(coupon_code: params[:coupon_code]) diff --git a/lib/ecommerce/version.rb b/lib/ecommerce/version.rb index 22f1df07..350059c6 100644 --- a/lib/ecommerce/version.rb +++ b/lib/ecommerce/version.rb @@ -1,3 +1,3 @@ module Ecommerce - VERSION = '0.7.2.9' + VERSION = '0.7.3.0' end From 5847977528d55fb6ad02f54c6bc53a6306501b67 Mon Sep 17 00:00:00 2001 From: Augusto Samame Date: Thu, 5 Jan 2023 19:48:55 -0500 Subject: [PATCH 09/10] remove carrierwave v2 --- Gemfile.lock | 5 ----- lib/ecommerce.rb | 4 ++-- lib/ecommerce/version.rb | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ad996cd0..d65b6304 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,7 +5,6 @@ PATH best_in_place bootstrap-sass browser - carrierwave cocoon culqi-ruby decorators @@ -80,10 +79,6 @@ GEM sass (>= 3.3.4) browser (2.5.3) builder (3.2.3) - carrierwave (1.2.3) - activemodel (>= 4.0.0) - activesupport (>= 4.0.0) - mime-types (>= 1.16) cocoon (1.2.11) coffee-rails (4.2.2) coffee-script (>= 2.2.0) diff --git a/lib/ecommerce.rb b/lib/ecommerce.rb index edcf7ca2..d36ccf95 100644 --- a/lib/ecommerce.rb +++ b/lib/ecommerce.rb @@ -1,8 +1,8 @@ require "ecommerce/engine" require 'decorators' require "friendly_id" -require 'carrierwave' -require 'carrierwave/storage/fog' +#require 'carrierwave' +#require 'carrierwave/storage/fog' require 'mini_magick' require 'social-share-button' require 'simple_form' diff --git a/lib/ecommerce/version.rb b/lib/ecommerce/version.rb index 350059c6..fba8cc0c 100644 --- a/lib/ecommerce/version.rb +++ b/lib/ecommerce/version.rb @@ -1,3 +1,3 @@ module Ecommerce - VERSION = '0.7.3.0' + VERSION = '0.7.3.1' end From 9b22b8349c3706e7088553cb76f6449cb5c05e8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Jan 2023 00:50:07 +0000 Subject: [PATCH 10/10] Bump rake from 12.3.1 to 13.0.6 Bumps [rake](https://github.com/ruby/rake) from 12.3.1 to 13.0.6. - [Release notes](https://github.com/ruby/rake/releases) - [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc) - [Commits](https://github.com/ruby/rake/compare/v12.3.1...v13.0.6) --- updated-dependencies: - dependency-name: rake dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 192 +++++++++++++++++++++++++++------------------------ 1 file changed, 102 insertions(+), 90 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d65b6304..2c3a3e00 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,6 +23,7 @@ PATH sass-rails simple_form social-share-button + sweetify GEM remote: https://rubygems.org/ @@ -69,118 +70,130 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) arel (9.0.0) - autoprefixer-rails (8.6.5) - execjs + autoprefixer-rails (10.4.7.0) + execjs (~> 2) best_in_place (3.1.1) actionpack (>= 3.2) railties (>= 3.2) - bootstrap-sass (3.3.7) + bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) - sass (>= 3.3.4) - browser (2.5.3) + sassc (>= 2.0.0) + browser (5.3.1) builder (3.2.3) - cocoon (1.2.11) - coffee-rails (4.2.2) + cocoon (1.2.15) + coffee-rails (5.0.0) coffee-script (>= 2.2.0) - railties (>= 4.0.0) + railties (>= 5.2.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) concurrent-ruby (1.0.5) crass (1.0.4) - culqi-ruby (0.0.8) - decorators (2.0.4) - railties (>= 4.0.0, < 6) - dotenv (2.5.0) - dotenv-rails (2.5.0) - dotenv (= 2.5.0) - railties (>= 3.2, < 6.0) + culqi-ruby (0.1.0) + date (3.3.3) + decorators (2.0.5) + railties (>= 4.0.0, < 7) + dotenv (2.8.1) + dotenv-rails (2.8.1) + dotenv (= 2.8.1) + railties (>= 3.2) erubi (1.7.1) - excon (0.62.0) - execjs (2.7.0) - ffi (1.9.25) - fog-aws (3.0.0) + excon (0.96.0) + execjs (2.8.1) + ffi (1.15.5) + fog-aws (3.15.0) fog-core (~> 2.1) fog-json (~> 1.1) fog-xml (~> 0.1) - ipaddress (~> 0.8) - fog-core (2.1.0) + fog-core (2.3.0) builder - excon (~> 0.58) - formatador (~> 0.2) + excon (~> 0.71) + formatador (>= 0.2, < 2.0) mime-types fog-json (1.2.0) fog-core multi_json (~> 1.10) - fog-xml (0.1.3) + fog-xml (0.1.4) fog-core nokogiri (>= 1.5.11, < 2.0.0) - font-awesome-rails (4.7.0.4) - railties (>= 3.2, < 6.0) - formatador (0.2.5) - friendly_id (5.2.4) + font-awesome-rails (4.7.0.8) + railties (>= 3.2, < 8.0) + formatador (1.1.0) + friendly_id (5.5.0) activerecord (>= 4.0.0) - geocoder (1.4.9) - globalid (0.4.1) - activesupport (>= 4.2.0) + geocoder (1.8.1) + globalid (1.0.0) + activesupport (>= 5.0) i18n (1.0.1) concurrent-ruby (~> 1.0) - ipaddress (0.8.3) jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) - kaminari (1.1.1) + kaminari (1.2.2) activesupport (>= 4.1.0) - kaminari-actionview (= 1.1.1) - kaminari-activerecord (= 1.1.1) - kaminari-core (= 1.1.1) - kaminari-actionview (1.1.1) + kaminari-actionview (= 1.2.2) + kaminari-activerecord (= 1.2.2) + kaminari-core (= 1.2.2) + kaminari-actionview (1.2.2) actionview - kaminari-core (= 1.1.1) - kaminari-activerecord (1.1.1) + kaminari-core (= 1.2.2) + kaminari-activerecord (1.2.2) activerecord - kaminari-core (= 1.1.1) - kaminari-core (1.1.1) + kaminari-core (= 1.2.2) + kaminari-core (1.2.2) loofah (2.2.2) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.0) + mail (2.8.0) mini_mime (>= 0.1.1) - marcel (0.3.2) + net-imap + net-pop + net-smtp + marcel (0.3.3) mimemagic (~> 0.3.2) - material_icons (2.2.1) + material_icons (4.0.0) railties (>= 3.2) method_source (0.9.0) - mime-types (3.1) + mime-types (3.4.1) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mimemagic (0.3.2) - mini_magick (4.8.0) - mini_mime (1.0.0) + mime-types-data (3.2022.0105) + mimemagic (0.3.10) + nokogiri (~> 1) + rake + mini_magick (4.12.0) + mini_mime (1.1.2) mini_portile2 (2.3.0) minitest (5.11.3) - monetize (1.7.0) - money (~> 6.9) - money (6.11.3) - i18n (>= 0.6.4, < 1.1) - money-rails (1.11.0) + monetize (1.12.0) + money (~> 6.12) + money (6.16.0) + i18n (>= 0.6.4, <= 2) + money-rails (1.15.0) activesupport (>= 3.0) - monetize (~> 1.7.0) - money (~> 6.11.0) + monetize (~> 1.9) + money (~> 6.13) railties (>= 3.0) - multi_json (1.13.1) - nio4r (2.3.1) + multi_json (1.15.0) + net-imap (0.3.4) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.3.3) + net-protocol + nio4r (2.5.8) nokogiri (1.8.2) mini_portile2 (~> 2.3.0) pg (1.0.0) - pg_search (2.1.2) - activerecord (>= 4.2) - activesupport (>= 4.2) - arel (>= 6) + pg_search (2.3.6) + activerecord (>= 5.2) + activesupport (>= 5.2) rack (2.0.5) rack-test (1.0.0) rack (>= 1.0, < 3) @@ -208,43 +221,42 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (12.3.1) - rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) - record_tag_helper (1.0.0) - actionview (~> 5.x) - sass (3.5.6) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) - railties (>= 4.0.0, < 6) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) - simple_form (4.0.1) - actionpack (>= 5.0) - activemodel (>= 5.0) - social-share-button (1.1.0) + rake (13.0.6) + record_tag_helper (1.0.1) + actionview (>= 5) + sass-rails (6.0.0) + sassc-rails (~> 2.1, >= 2.1.1) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + simple_form (5.1.0) + actionpack (>= 5.2) + activemodel (>= 5.2) + social-share-button (1.2.4) coffee-rails - sprockets (3.7.2) + sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) + sprockets-rails (3.4.2) + actionpack (>= 5.2) + activesupport (>= 5.2) sprockets (>= 3.0.0) + sweetify (2.0.0) + actionpack thor (0.20.0) thread_safe (0.3.6) - tilt (2.0.8) + tilt (2.0.11) + timeout (0.3.1) tzinfo (1.2.5) thread_safe (~> 0.1) - websocket-driver (0.7.0) + websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) + websocket-extensions (0.1.5) PLATFORMS ruby