source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/shein_orders_controller.rb
Ruby
mit
191
main
1,591
# app/controllers/shein_orders_controller.rb class SheinOrdersController < ApplicationController before_action :set_shein_order, only: [:show, :edit, :update, :destroy] def index @shein_orders = SheinOrder.where("data ->> 'Status do pedido' IN (?)", ['A ser coletado pela SHEIN', 'Pendente', 'Para ser enviado'...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/application_controller.rb
Ruby
mit
191
main
1,336
# frozen_string_literal: true class ApplicationController < ActionController::Base include Pundit::Authorization include ForgeryProtection include SetPlatform before_action :authenticate_user! before_action :set_locale_from_cookie # Keeps the system with the same translation selected before by user. set_cu...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/bling_module_situations_controller.rb
Ruby
mit
191
main
1,285
class BlingModuleSituationsController < ApplicationController before_action :set_bling_module_situation, only: [:show, :edit, :update, :destroy] def index @bling_module_situations = BlingModuleSituation.all.order(:module_id, :situation_id) end def show end def new @bling_module_situation = BlingM...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/customers_controller.rb
Ruby
mit
191
main
2,819
# frozen_string_literal: true require 'customer/import_customer_csv' class CustomersController < ApplicationController before_action :set_customer, only: %i[show edit update destroy] include Pagy::Backend # GET /customers # GET /customers.json def index authorize Customer customers = Customer.where(a...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/orders_control_controller.rb
Ruby
mit
191
main
8,301
# frozen_string_literal: true class OrdersControlController < ApplicationController def show_orders_control @send_orders = [] list_orders # unique_order @orders.each do |order| # if order['Wspedido']['pedidostatus_id'] == '23' || order['Wspedido']['pedidostatus_id'] == '3' @send_orders <<...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/employees_controller.rb
Ruby
mit
191
main
372
# frozen_string_literal: true class EmployeesController < ApplicationController def create @employee = Employee.new(employee_params) respond_to do |format| format.html { redirect_to info_path, notice: 'Funcionário adicionado' } if @employee.save end end private def employee_params param...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/shein_dashboards_controller.rb
Ruby
mit
191
main
551
class SheinDashboardsController < ApplicationController def index finance_per_status @finance_data = FinanceDatum.order(:date) end private def finance_per_status @pendings = SheinOrder.where("data ->> 'Status do pedido' = ?", "Pendente") @to_be_colected = SheinOrder.where("data ->> 'Status do...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/groups_controller.rb
Ruby
mit
191
main
2,205
# frozen_string_literal: true class GroupsController < ApplicationController before_action :set_group, only: %i[show edit update destroy] # GET /groups # GET /groups.json def index @groups = Group.all end # GET /groups/1 # GET /groups/1.json def show; end # GET /groups/new def new @group...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/productions_controller.rb
Ruby
mit
191
main
13,331
# app/controllers/productions_controller.rb require 'prawn' include ActionView::Helpers::NumberHelper class ProductionsController < ApplicationController before_action :set_production, only: [:show, :edit, :update, :destroy, :verify] before_action :set_tailors, only: [:new, :edit, :create, :update] def index ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/sales_controller.rb
Ruby
mit
191
main
3,815
# frozen_string_literal: true class SalesController < ApplicationController before_action :set_sale, only: %i[show edit update destroy] include Pagy::Backend # GET /sales # GET /sales.json def index sales = Sale.includes(:sale_products, :customer).where(account_id: current_tenan...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/products_controller.rb
Ruby
mit
191
main
9,374
# frozen_string_literal: true class ProductsController < ApplicationController skip_before_action :verify_authenticity_token skip_before_action :authenticate_user!, only: %i[index_defer tags_index_defer] before_action :set_product, only: %i[show edit update destroy destroy_from_index] include Pagy::Backend i...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/locales_controller.rb
Ruby
mit
191
main
693
class LocalesController < ApplicationController before_action :set_locale def default_locale_option cookies.delete(:locale) cookies.permanent[:locale] = I18n.default_locale # save cookies with default language end def set_locale if params[:locale].present? if params[:locale] == 'defau...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/purchases_controller.rb
Ruby
mit
191
main
2,329
# frozen_string_literal: true class PurchasesController < ApplicationController before_action :set_purchase, only: %i[show edit update destroy] include Pagy::Backend # GET /purchases # GET /purchases.json def index purchases = Purchase.where(account_id: current_tenant) @pagy, @purchases = pagy(purcha...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/bling_data_controller.rb
Ruby
mit
191
main
1,257
class BlingDataController < ApplicationController before_action :set_bling_datum, only: [:show, :edit, :update, :destroy] # GET /bling_data def index authorize Customer @bling_data = BlingDatum.all end # GET /bling_data/1 def show authorize Customer end # GET /bling_data/new def new ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/stores_controller.rb
Ruby
mit
191
main
1,367
class StoresController < ApplicationController before_action :set_store, only: %i[show edit update destroy] def index @search = Store.reverse_chronologically.ransack(params[:q]) respond_to do |format| format.any(:html, :json) { @stores = set_page_and_extract_portion_from @search.result } forma...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/checkout_orders_controller.rb
Ruby
mit
191
main
2,278
class CheckoutOrdersController < ApplicationController def index @combined_order_data ||= [] end def process_file if params[:document].present? file_path = params[:document].tempfile package_codes = File.readlines(file_path).map(&:chomp) elsif params[:text_block].present? package_c...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/sale_products_controller.rb
Ruby
mit
191
main
2,500
# frozen_string_literal: true class SaleProductsController < ApplicationController before_action :set_sale_product, only: %i[show edit update destroy] include Pagy::Backend # GET /sale_products # GET /sale_products.json def index sale_products = SaleProduct.where(account_id: current_tenant) @pagy, @s...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/bling_order_item_histories_controller.rb
Ruby
mit
191
main
3,977
# frozen_string_literal: true # There is a necessity to know the revenue from the last 15 days # In order to take better commercial decisions. class BlingOrderItemHistoriesController < ApplicationController before_action :date_range, :paid_bling_order_items, :day_quantities_presenter, only: %i[day_qu...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/revenue_estimations_controller.rb
Ruby
mit
191
main
254
class RevenueEstimationsController < ApplicationController inherit_resources private def resource_params return [] if request.get? params.require(:revenue_estimation).permit(:date, :month, :average_ticket, :revenue, :quantity) end end
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/warehouses_controller.rb
Ruby
mit
191
main
992
class WarehousesController < ApplicationController before_action :set_warehouse, only: [:show, :edit, :update, :destroy] def index @warehouses = Warehouse.all end def show end def new @warehouse = Warehouse.new end def create @warehouse = Warehouse.new(warehouse_params) if @warehous...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/bling_order_item_owners_controller.rb
Ruby
mit
191
main
6,212
# frozen_string_literal: true # There is a necessity to know the revenue from the last 15 days # In order to take better commercial decisions. class BlingOrderItemOwnersController < ApplicationController before_action :date_range, :paid_bling_order_items, :day_quantities_presenter, only: %i[day_quant...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/shein_bling_order_items_controller.rb
Ruby
mit
191
main
740
# frozen_string_literal: true class SheinBlingOrderItemsController < ApplicationController def index @bling_shein_orders = BlingOrderItem .select('bling_order_items.*, shein_orders.data ->> \'Pacote do comerciante\' as pacote_do_comerciante, shein_orders.data ->> \'Número do pedido\' a...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/tailors_controller.rb
Ruby
mit
191
main
946
class TailorsController < ApplicationController before_action :set_tailor, only: [:show, :edit, :update, :destroy] def index @tailors = Tailor.all end def show end def new @tailor = Tailor.new end def edit end def create @tailor = Tailor.new(tailor_params) if @tailor.save ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/home_controller.rb
Ruby
mit
191
main
7,951
# frozen_string_literal: true class HomeController < ApplicationController before_action :refresh_token, :default_initial_date, :default_final_date, :date_range, :bling_order_items, :current_done_order_items, :set_monthly_revenue_estimation, :token_expires_at, :get_in_progress_order_i...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/categories_controller.rb
Ruby
mit
191
main
2,223
# frozen_string_literal: true class CategoriesController < ApplicationController before_action :set_category, only: %i[show edit update destroy] include Pagy::Backend include ActionView::RecordIdentifier # GET /categories # GET /categories.json def index categories = Category.where(account_id: current_...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/group_products_controller.rb
Ruby
mit
191
main
2,124
# frozen_string_literal: true class GroupProductsController < ApplicationController before_action :set_group_product, only: %i[show edit update destroy] # GET /group_products # GET /group_products.json def index @group_products = GroupProduct.all end # GET /group_products/1 # GET /group_products/1....
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/dashboards_controller.rb
Ruby
mit
191
main
11,255
require 'csv' class DashboardsController < ApplicationController before_action :token_expires_at, :date_range, :bling_order_items, :canceled_orders, :get_in_progress_order_items, :current_done_order_items, :set_monthly_revenue_estimation, :get_printed_order_items, :get_pending_order_i...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/items_controller.rb
Ruby
mit
191
main
334
class ItemsController < ApplicationController def update_status @item = Item.find(params[:id]) case params[:status] when 'resolved' @item.resolve! when 'unresolved' @item.unresolve! end redirect_back(fallback_location: show_pending_orders_path, notice: 'Status atualizado com sucess...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/bling_order_items_controller.rb
Ruby
mit
191
main
4,302
require 'csv' class BlingOrderItemsController < ApplicationController before_action :set_filter_params include Pagy::Backend inherit_resources actions :all, except: %i[new create] decorates_assigned :bling_order_item def index authorize Customer bling_order_items = filtered_bling_order_items ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/suppliers_controller.rb
Ruby
mit
191
main
2,255
# frozen_string_literal: true class SuppliersController < ApplicationController before_action :set_supplier, only: %i[show edit update destroy] include Pagy::Backend # GET /suppliers # GET /suppliers.json def index suppliers = Supplier.where(account_id: current_tenant) @pagy, @suppliers = pagy(suppli...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/stocks_controller.rb
Ruby
mit
191
main
12,788
# frozen_string_literal: true class StocksController < ApplicationController include Pagy::Backend before_action :set_stock, only: [:show, :apply_discount] def index respond_to do |format| format.html do @stocks_with_data = collection end format.csv do if params[:detailed] ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/finance_data_controller.rb
Ruby
mit
191
main
3,509
class FinanceDataController < ApplicationController before_action :set_finance_data, only: [:show, :edit, :update, :destroy] def index @finance_data = FinanceDatum.all end def show end def new @finance_data = FinanceDatum.new end def create @finance_data = FinanceDatum.new(finance_...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/reports_controller.rb
Ruby
mit
191
main
3,364
# frozen_string_literal: true class ReportsController < ApplicationController def daily_sale @total_daily = Sale.find_by_sql("SELECT s.created_at::DATE, SUM(s.value) AS value, SUM(s.discount) AS discount FROM sales s WHERE exchange = FALSE A...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/purchase_products_controller.rb
Ruby
mit
191
main
5,287
# frozen_string_literal: true class PurchaseProductsController < ApplicationController before_action :set_purchase_product, only: %i[show edit update destroy] include Pagy::Backend # GET /purchase_products # GET /purchase_products.json def index purchase_products = PurchaseProduct.includes(:product).refe...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/concerns/set_platform.rb
Ruby
mit
191
main
230
# frozen_string_literal: true module SetPlatform extend ActiveSupport::Concern included do helper_method :platform end private def platform @platform ||= ApplicationPlatform.new(request.user_agent) end end
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/api/v1/bling_controller.rb
Ruby
mit
191
main
1,036
module Api module V1 class BlingController < ApplicationController def update_stock warehouse_id = params[:warehouse_id].presence || Warehouse.find_by(account_id: current_tenant, is_default: true)&.bling_id || Warehouse.first&.bling_id result = S...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/api/v1/products_controller.rb
Ruby
mit
191
main
1,920
# frozen_string_literal: true module Api module V1 class ProductsController < ActionController::API include ActionController::MimeResponds set_current_tenant_through_filter before_action :set_tenant_from_qr_data def show_by_id begin @product = Product.find_by!(id: param...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/api/v1/purchase_products_controller.rb
Ruby
mit
191
main
2,583
# frozen_string_literal: true module Api module V1 class PurchaseProductsController < ApplicationController skip_before_action :verify_authenticity_token before_action :set_products, only: %i[add_products add_inventory_quantity] def add_products save_succeeded = true @target_re...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/api/v1/sale_products_controller.rb
Ruby
mit
191
main
1,236
# frozen_string_literal: true module Api module V1 class SaleProductsController < ApplicationController skip_before_action :verify_authenticity_token before_action :set_products, only: %i[remove_products] def remove_products save_succeeded = true @target_records = [] sa...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/api/v1/checkout/orders_controller.rb
Ruby
mit
191
main
954
# frozen_string_literal: true module Api module V1 module Checkout class OrdersController < ApplicationController skip_before_action :authenticate_user!, only: [:find_order] def find_order @bling_shein_orders = BlingOrderItem .select('bling_order_items.*, shein_orders.d...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/controllers/api/v1/bling/orders_controller.rb
Ruby
mit
191
main
2,489
# frozen_string_literal: true module Api module V1 module Bling class OrdersController < ApplicationController def show @orders = Services::Bling::Order.call(order_command: 'find_orders') end def get_token code = params[:code] client_id = ENV['CLIENT_I...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/reports/daily_revenue_report.rb
Ruby
mit
191
main
1,567
# frozen_string_literal: true # DailyRevenueReport returns the hash the Chart js needs. # From the Char.js doc, https://www.chartjs.org/docs/latest/general/data-structures.html#parsing class DailyRevenueReport attr_accessor :bling_order_item_collection, :filter, :initial_date, :final_date, :record, :axi_x def ini...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/printed_order_items_job.rb
Ruby
mit
191
main
431
class PrintedOrderItemsJob < BlingOrderItemCreatorBaseJob STATUS = BlingOrderItem::Status::PRINTED.freeze attr_accessor :account_id def perform(account_id) @status = STATUS @account_id = account_id orders = Services::Bling::Order.call(order_command: 'find_orders', tenant: account_id, ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/checked_bling_order_items_job.rb
Ruby
mit
191
main
2,111
# frozen_string_literal: true # CheckedOrderItemsJob perform against created orders set previously # with another status. # For this reason, we should call this job as an updater job. # The crucial difference here is the absence of the alteration date in the bling API response. # It is possible to filter by alteration...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/collected_bling_order_items_job.rb
Ruby
mit
191
main
2,600
# frozen_string_literal: true # CollectedOrderItemsJob perform against created orders set previously # with another status, such as CHECKED. # For this reason, we should call this job as an updater job. # The crucial difference here is the absence of the alteration date in the bling API response. # It is possible to f...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/status_update_job.rb
Ruby
mit
191
main
650
# frozen_string_literal: true # StatusUpdateJob raises to update massive number of orders with old status # Tip: use it with # Model.find_in_batches(batch_size: small_number) do |batch_group_array| # bling_order_ids = batch_group_array.map(&:bling_order_id) # StatusUpdateJob.perform_later(bling_order_ids, new_stat...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/bling_order_job_updater.rb
Ruby
mit
191
main
575
class BlingOrderJobUpdater < ApplicationJob queue_as :bling_order_updater retry_on StandardError, attempts: 10, wait: :exponentially_longer def perform(record, account_id) result = Services::Bling::FindOrder.call(id: record.bling_order_id, order_command: 'find_order', tenant: account_id) raise StandardEr...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/daily_fulfilled_order_job.rb
Ruby
mit
191
main
1,568
# frozen_string_literal: true # DailyFulfilledOrderJob perform against created orders set previously # with another status. # For this reason, we should call this job as an updater job. # The crucial difference here is the absence of the alteration date in the bling API response. # It is possible to filter by alterati...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/stock_sync_job.rb
Ruby
mit
191
main
475
# frozen_string_literal: true class StockSyncJob < ApplicationJob queue_as :default rescue_from(StandardError) do |exception| Sentry.capture_message(exception) end retry_on StandardError, wait: :exponentially_longer, attempts: 5 def perform(tenant, options = {}) Product.find_in_batches(batch_size: ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/product_sync_job.rb
Ruby
mit
191
main
339
# frozen_string_literal: true class ProductSyncJob < ApplicationJob queue_as :default rescue_from(StandardError) do |exception| Sentry.capture_message(exception) end retry_on StandardError, wait: :exponentially_longer, attempts: 5 def perform(tenant, options = {}) Product.synchronize_bling(tenant, ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/current_done_bling_order_item_job.rb
Ruby
mit
191
main
657
# frozen_string_literal: true class CurrentDoneBlingOrderItemJob < BlingOrderItemCreatorBaseJob DONE_STATUSES = [BlingOrderItem::Status::CHECKED, BlingOrderItem::Status::VERIFIED].freeze def perform(account_id) @alteration_date = Date.today.strftime('%Y-%m-%d') options = { dataAlteracaoInicial: alteration...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/bling_order_item_creator_base_job.rb
Ruby
mit
191
main
1,399
# frozen_string_literal: true class BlingOrderItemCreatorBaseJob < ApplicationJob attr_accessor :account_id, :alteration_date def list_status_situation BlingOrderItem::Status::ALL end def fetch_order_data(order_id) Services::Bling::FindOrder.call(id: order_id, order_command: 'find_order', ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/application_job.rb
Ruby
mit
191
main
477
# frozen_string_literal: true class ApplicationJob < ActiveJob::Base # Automatically retry jobs that encountered a deadlock # retry_on ActiveRecord::Deadlocked # Most jobs are safe to ignore if the underlying records are no longer available # discard_on ActiveJob::DeserializationError queue_as :default r...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/change_order_status_job.rb
Ruby
mit
191
main
534
class ChangeOrderStatusJob < ApplicationJob attr_accessor :account_id def perform(old_status, new_status, account_id) orders = Services::Bling::Order.call(order_command: 'find_orders', tenant: account_id, situation: old_status) orders = orders['data'] orders_id...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/order_items_job.rb
Ruby
mit
191
main
1,377
class OrderItemsJob < ApplicationJob queue_as :items def perform(bling_order_id) record = BlingOrderItem.find_by(bling_order_id:) account_id = record.account_id items_attributes = [] label_attributes = [] order = Services::Bling::FindOrder.call(id: bling_order_id, order_command: 'find_order', t...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/shein_orders_job.rb
Ruby
mit
191
main
605
class SheinOrdersJob < ApplicationJob queue_as :default def perform(file_path, current_tenant_id) begin spreadsheet = Roo::Spreadsheet.open(file_path) headers = spreadsheet.row(1) (2..spreadsheet.last_row).each do |i| row = Hash[[headers, spreadsheet.row(i)].transpose] ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/update_bling_order_status_job.rb
Ruby
mit
191
main
2,202
class UpdateBlingOrderStatusJob < ApplicationJob queue_as :default MAX_RETRIES = 3 RETRY_DELAY = 5 # seconds def perform(current_status, new_status, tenant_id, batch_size = 100) Rails.logger.info("Starting to update orders from status #{current_status} to #{new_status} for account #{tenant_i...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/weekly_canceled_order_items_job.rb
Ruby
mit
191
main
1,031
# frozen_string_literal: true # WeeklyCanceledOrderItemJob # As the store increase its purchases, it is more often many canceling status appearing # Every status can jump from itself to canceled status. # Canceled status accumulates quantities and do not revert to its previous status. # As the time passes, requesting ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/flexible_order_items_job.rb
Ruby
mit
191
main
1,281
# frozen_string_literal: true class FlexibleOrderItemsJob < BlingOrderItemCreatorBaseJob queue_as :default attr_accessor :account_id, :statuses, :start_date, :end_date def perform(account_id, statuses, options = {}) @account_id = account_id @statuses = Array(statuses) set_date_range...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/local_shein_orders_job.rb
Ruby
mit
191
main
698
class LocalSheinOrdersJob < ApplicationJob queue_as :default def perform(file_path, current_tenant_id) begin SheinOrder.delete_all spreadsheet = Roo::Spreadsheet.open(file_path) headers = spreadsheet.row(1) orders = [] (2..spreadsheet.last_row).each do |i| row = Ha...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/bling_order_item_destroyer_job.rb
Ruby
mit
191
main
327
class BlingOrderItemDestroyerJob < ApplicationJob def perform(bling_order_id) order = BlingOrderItem.find_by(bling_order_id:) if order.not_found_at_bling? order.update(situation_id: BlingOrderItemStatus::DELETED_AT_BLING) else order.update(situation_id: order.original_situation_id) end e...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/verified_bling_order_items_job.rb
Ruby
mit
191
main
1,690
# frozen_string_literal: true # VerifiedBlingOrderItemsJob perform against created orders set previously # with another status. # For this reason, we should call this job as an updater job. # The crucial difference here is the absence of the alteration date in the bling API response. # It is possible to filter by alte...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/generate_stocks_csv_job.rb
Ruby
mit
191
main
251
class GenerateStocksCsvJob < ApplicationJob queue_as :default def perform(tenant_id, email) stocks_export = Stock.where(account_id: tenant_id) csv_data = stocks_export.to_csv StockMailer.send_csv(email, csv_data).deliver_now end end
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/daily_error_order_job.rb
Ruby
mit
191
main
1,552
# frozen_string_literal: true # DailyErrorOrderJob perform against created orders set previously # with another status. # For this reason, we should call this job as an updater job. # The crucial difference here is the absence of the alteration date in the bling API response. # It is possible to filter by alteration d...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/insert_shein_order_job.rb
Ruby
mit
191
main
511
class InsertSheinOrderJob < ApplicationJob queue_as :default def perform(row, current_tenant_id) begin shein_order = SheinOrder.where("data ->> 'Número do pedido' = ?", row["Número do pedido"].to_s).first_or_initialize # Update and save the order with all columns shein_order.update(dat...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/bling_order_item_creator_job.rb
Ruby
mit
191
main
877
class BlingOrderItemCreatorJob < BlingOrderItemCreatorBaseJob def perform(account_id) @account_id = account_id list_status_situation.each do |status| orders = Services::Bling::Order.call(order_command: 'find_orders', tenant: account_id, situation: status) ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/daily_canceled_order_job.rb
Ruby
mit
191
main
1,564
# frozen_string_literal: true # DailyCanceledOrderJob perform against created orders set previously # with another status. # For this reason, we should call this job as an updater job. # The crucial difference here is the absence of the alteration date in the bling API response. # It is possible to filter by alteratio...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/update_items_bling_order_items_job.rb
Ruby
mit
191
main
384
class UpdateItemsBlingOrderItemsJob < ApplicationJob queue_as :default def perform(store_id, situation_id, current_tenant_id) bling_order_ids = BlingOrderItem.where(store_id: store_id, situation_id: situation_id, items: nil).pluck(:bling_order_id) Services::Bling::FindOrders.call(order_command: 'find_order...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/in_progress_order_items_job.rb
Ruby
mit
191
main
438
class InProgressOrderItemsJob < BlingOrderItemCreatorBaseJob STATUS = BlingOrderItem::Status::IN_PROGRESS.freeze attr_accessor :account_id def perform(account_id) @status = STATUS @account_id = account_id orders = Services::Bling::Order.call(order_command: 'find_orders', tenant: account_id, ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/canceled_bling_order_items_job.rb
Ruby
mit
191
main
782
# frozen_string_literal: true # CanceledBlingOrderItemsJob perform against created orders set previously # with another status. # For this reason, we should call this job as an updater job. # We keep the create block as it is since we can not prove bling # erp first create a e.g. checked status then # update its own d...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/find_orders_by_status_job.rb
Ruby
mit
191
main
2,725
class FindOrdersByStatusJob < ApplicationJob queue_as :default MAX_RETRIES = 3 RETRY_DELAY = 5 # seconds def perform(status, tenant_id) orders = BlingOrderItem.where(account_id: tenant_id, situation_id: status) bling_datum = BlingDatum.find_by(account_id: tenant_id) if bling_d...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/jobs/pending_order_items_job.rb
Ruby
mit
191
main
516
# frozen_string_literal: true class PendingOrderItemsJob < BlingOrderItemCreatorBaseJob queue_as :default STATUS = BlingOrderItem::Status::PENDING.freeze attr_accessor :account_id def perform(account_id, options = {}) @status = STATUS @account_id = account_id orders = Services::Bling::Order.cal...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/decorators/bling_order_item_decorator.rb
Ruby
mit
191
main
1,117
# frozen_string_literal: true # Decorator Pattern applied, check https://github.com/drapergem/draper class BlingOrderItemDecorator < Draper::Decorator include AbstractController::Translation include ActionView::Helpers::NumberHelper delegate_all def title "#{human_attribute(:bling_order_id)} #{model.bling...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/decorators/error_decorator.rb
Ruby
mit
191
main
244
# frozen_string_literal: true # To call ErrorDecorator.new(model.errors).full_messages inside an invalid request action class ErrorDecorator < Draper::Decorator delegate_all def full_messages object.full_messages.join(', ') end end
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/decorators/product_decorator.rb
Ruby
mit
191
main
802
# frozen_string_literal: true # Decorator Pattern applied, check https://github.com/drapergem/draper class ProductDecorator < Draper::Decorator include AbstractController::Translation include ActionView::Helpers::NumberHelper delegate_all LIMIT_TO_TRUNCATE_SKU = 17 def human_attribute(attribute_key) mo...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/purchase.rb
Ruby
mit
191
main
606
# frozen_string_literal: true # == Schema Information # # Table name: purchases # # id :bigint not null, primary key # value :float # created_at :datetime not null # updated_at :datetime not null # supplier_id :bigint # # Indexes # # index_purchases_on_supplier_id (sup...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/warehouse.rb
Ruby
mit
191
main
1,506
# == Schema Information # # Table name: warehouses # # id :bigint not null, primary key # description :string not null # ignore_balance :boolean default(FALSE), not null # is_default :boolean default(FALSE), not null # status :integer defaul...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/sale.rb
Ruby
mit
191
main
2,262
# frozen_string_literal: true # == Schema Information # # Table name: sales # # id :bigint not null, primary key # disclosure :boolean # discount :float # exchange :boolean default(FALSE) # online :boolean # order_code ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/tailor.rb
Ruby
mit
191
main
435
# == Schema Information # # Table name: tailors # # id :bigint not null, primary key # name :string # created_at :datetime not null # updated_at :datetime not null # account_id :integer # # Indexes # # index_tailors_on_account_id (account_id) # class Tailor < ApplicationRe...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/post_datum.rb
Ruby
mit
191
main
426
# frozen_string_literal: true # == Schema Information # # Table name: post_data # # id :bigint not null, primary key # cep :string # client_name :string # post_code :string # post_type :string # send_date :datetime # state :string # value :float # created_at :date...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/shein_order.rb
Ruby
mit
191
main
2,006
# == Schema Information # # Table name: shein_orders # # id :bigint not null, primary key # data :jsonb # created_at :datetime not null # updated_at :datetime not null # account_id :integer # # Indexes # # index_shein_orders_on_account_id (account_id) require 'zip' class...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/bling_datum.rb
Ruby
mit
191
main
480
# == Schema Information # # Table name: bling_data # # id :bigint not null, primary key # access_token :string # expires_at :datetime # expires_in :integer # refresh_token :string # scope :text # token_type :string # created_at :datetime not null # updated_at ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/bling_order_item.rb
Ruby
mit
191
main
8,121
# == Schema Information # # Table name: bling_order_items # # id :bigint not null, primary key # aliquotaIPI :decimal(, ) # alteration_date :datetime # city :string(10485760) # codigo :string # collected_alteration_da...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/simplo_item_sale.rb
Ruby
mit
191
main
1,873
# frozen_string_literal: true # == Schema Information # # Table name: simplo_item_sales # # id :bigint not null, primary key # data_pedido :datetime # desconto :float # nome_produto :string # peso :float # quantidade :integer # sku :string # valor_total...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/balance.rb
Ruby
mit
191
main
823
# == Schema Information # # Table name: balances # # id :bigint not null, primary key # physical_balance :integer not null # virtual_balance :integer not null # created_at :datetime not null # updated_at :datetime not null # deposit_id :...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/group_product.rb
Ruby
mit
191
main
576
# frozen_string_literal: true # == Schema Information # # Table name: group_products # # id :bigint not null, primary key # created_at :datetime not null # updated_at :datetime not null # group_id :bigint # product_id :bigint # # Indexes # # index_group_products_on_group_id ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/account.rb
Ruby
mit
191
main
720
# frozen_string_literal: true # == Schema Information # # Table name: accounts # # id :bigint not null, primary key # company_name :string # created_at :datetime not null # updated_at :datetime not null # user_id :bigint not null # # Indexes # # index_accoun...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/user.rb
Ruby
mit
191
main
1,411
# frozen_string_literal: true # == Schema Information # # Table name: users # # id :bigint not null, primary key # company_name :string # cpf_cnpj :string # email :string default(""), not null # encrypted_password :string ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/production_product.rb
Ruby
mit
191
main
2,098
# == Schema Information # # Table name: production_products # # id :bigint not null, primary key # delivery_date :date # dirty :integer default(0) # discard :integer default(0) # error :integer default(0) # pieces_delivered :inte...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/simplo_client.rb
Ruby
mit
191
main
338
# frozen_string_literal: true # == Schema Information # # Table name: simplo_clients # # id :bigint not null, primary key # age :integer # name :string # order_date :datetime # created_at :datetime not null # updated_at :datetime not null # class SimploClient < Appl...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/sale_product.rb
Ruby
mit
191
main
890
# frozen_string_literal: true # == Schema Information # # Table name: sale_products # # id :bigint not null, primary key # quantity :integer # value :float # created_at :datetime not null # updated_at :datetime not null # account_id :integer # product_id :bigint # sale_...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/production.rb
Ruby
mit
191
main
3,629
# == Schema Information # # Table name: productions # # id :bigint not null, primary key # confirmed :boolean # consider :boolean default(FALSE) # cut_date :datetime # expected_delivery_date :date # fabric_cost :decimal(10,...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/simplo_item.rb
Ruby
mit
191
main
702
# frozen_string_literal: true # == Schema Information # # Table name: simplo_items # # id :bigint not null, primary key # quantity :integer # sku :string # created_at :datetime not null # updated_at :datetime not null # product_id :bigint #...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/feature.rb
Ruby
mit
191
main
520
# == Schema Information # # Table name: features # # id :bigint not null, primary key # feature_key :integer default(0), not null # is_enabled :boolean default(FALSE), not null # name :string not null # created_at :datetime not null # updated_at :da...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/bling_module_situation.rb
Ruby
mit
191
main
689
# frozen_string_literal: true # == Schema Information # # Table name: bling_module_situations # # id :bigint not null, primary key # color :string # name :string not null # created_at :datetime not null # updated_at :datetime not null # inherited_i...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/payment.rb
Ruby
mit
191
main
608
# == Schema Information # # Table name: payments # # id :bigint not null, primary key # amount :decimal(, ) # payment_date :date # created_at :datetime not null # updated_at :datetime not null # production_id :bigint not null # # Indexes # # index_paym...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/item.rb
Ruby
mit
191
main
1,026
# == Schema Information # # Table name: items # # id :bigint not null, primary key # description :string # discount :decimal(, ) # ipi_tax :decimal(, ) # long_description :string # pending :boolean default(FALSE) # quantity ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/group.rb
Ruby
mit
191
main
484
# frozen_string_literal: true # == Schema Information # # Table name: groups # # id :bigint not null, primary key # description :string # months :integer default(1) # created_at :datetime not null # updated_at :datetime not null # class Group < ApplicationRecord ...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/simplo_product.rb
Ruby
mit
191
main
616
# frozen_string_literal: true # == Schema Information # # Table name: simplo_products # # id :bigint not null, primary key # name :string # sku :string # created_at :datetime not null # updated_at :datetime not null # class SimploProduct < ApplicationRecord def sim...
github
Purple-Stock/open-erp
https://github.com/Purple-Stock/open-erp
app/models/category.rb
Ruby
mit
191
main
490
# frozen_string_literal: true # == Schema Information # # Table name: categories # # id :bigint not null, primary key # name :string # created_at :datetime not null # updated_at :datetime not null # account_id :integer # # Indexes # # index_categories_on_account_id (accou...