Skip to content

Instantly share code, notes, and snippets.

View victorgiraldes's full-sized avatar
🏠
Working from home

Victor Giraldes victorgiraldes

🏠
Working from home
View GitHub Profile
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)
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
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])
class EntryBuilder
def self.build
builder = new
yield(builder)
builder.entry
end
def initialize
@entry = Entry.new
end
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
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
module StockService
class Base
include ActiveModel::Model
attr_accessor :permitted_params
def initialize(permitted_params)
@permitted_params = permitted_params
end
end
end
require 'rest-client'
module Services
module Webhook
class Base
attr_accessor :url
def initialize
@url = 'http://localhost:3000/api/v1'
end
require './lib/services/webhook/base'
module Services
module Webhook
class WebhookData < Services::Webhook::Base
def create(params)
url.concat('/webhook')
http_post(params)
end
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