This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@block_edit = false | |
@bank_debit = current_company.bank_debits.new(permitted_params[:bank_debit]) | |
if @bank_debit.save | |
@bank_debit.update_attribute(:user_id, current_user.id) | |
current_user.up_score!(1.3) if current_user.Potencial? | |
#plot debit | |
plots_debit(params[:bank_debit][:plots], params[:plots_count].to_i, @bank_debit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Group.all.each do |group| | |
Expense.where(company_id: group.company_ids).each do |expense| | |
next unless expense.procedure | |
expense_procedure = expense.procedure.description | |
group_procedures = group.procedures.where(description: expense_procedure).first | |
expense.update(procedure_id: group_procedures.id) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module StockService | |
class CreateImportEntry | |
include ActiveModel::Model | |
attr_accessor :entry, :file, :company, :user, :file, :provider | |
def initialize(options = {}) | |
@company = Company.find_by(options[:token]) | |
@user = User.find_by(options[:token]) | |
@stock_group = options[:stock_group] | |
@provider = Provider.find_by(options[:token]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EntryBuilder | |
def self.build | |
builder = new | |
yield(builder) | |
builder.entry | |
end | |
def initialize | |
@entry = Entry.new | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module StockService | |
class CreateImportEntry | |
include ActiveModel::Model | |
attr_accessor :entry, :company, :user, :file | |
def initialize(options = {}, company, user, stock_group, file) | |
@options = options | |
@company = company | |
@user = user | |
@stock_group = stock_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module StockService | |
class CreateImportEntry | |
include ActiveModel::Model | |
attr_accessor :entry, :company, :user, :file | |
def initialize(options = {}, company, user, stock_group, file) | |
@options = options | |
@company = company | |
@user = user | |
@stock_group = stock_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module StockService | |
class Base | |
include ActiveModel::Model | |
attr_accessor :permitted_params | |
def initialize(permitted_params) | |
@permitted_params = permitted_params | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rest-client' | |
module Services | |
module Webhook | |
class Base | |
attr_accessor :url | |
def initialize | |
@url = 'http://localhost:3000/api/v1' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './lib/services/webhook/base' | |
module Services | |
module Webhook | |
class WebhookData < Services::Webhook::Base | |
def create(params) | |
url.concat('/webhook') | |
http_post(params) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Api | |
module V1 | |
class WebhookController < Api::V1::ApplicationController | |
def index | |
service = Services::Webhook::WebhookData.new | |
rs = service.all | |
render json: rs.body, status: rs.code | |
end |
OlderNewer