12_generate_custom_csv_file #58
11 changed files with 15 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
||||||
class ArticlesCsv < RenderCSV
|
class ArticlesCsv < RenderCsv
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def header
|
def header
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'csv'
|
require 'csv'
|
||||||
|
|
||||||
class BankTransactionsCsv < RenderCSV
|
class BankTransactionsCsv < RenderCsv
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def header
|
def header
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'csv'
|
require 'csv'
|
||||||
|
|
||||||
class FinancialTransactionsCsv < RenderCSV
|
class FinancialTransactionsCsv < RenderCsv
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def header
|
def header
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'csv'
|
require 'csv'
|
||||||
|
|
||||||
class InvoicesCsv < RenderCSV
|
class InvoicesCsv < RenderCsv
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def header
|
def header
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'csv'
|
require 'csv'
|
||||||
|
|
||||||
class OrderCsv < RenderCSV
|
class OrderCsv < RenderCsv
|
||||||
def header
|
def header
|
||||||
[
|
[
|
||||||
OrderArticle.human_attribute_name(:units_to_order),
|
OrderArticle.human_attribute_name(:units_to_order),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class OrderPDF < RenderPDF
|
class OrderPdf < RenderPdf
|
||||||
attr_reader :order
|
attr_reader :order
|
||||||
|
|
||||||
def initialize(order, options = {})
|
def initialize(order, options = {})
|
||||||
|
@ -55,7 +55,7 @@ class OrderPDF < RenderPDF
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_order_article_quantity_with_tolerance(goa)
|
def group_order_article_quantity_with_tolerance(goa)
|
||||||
goa.tolerance > 0 ? "#{goa.quantity} + #{goa.tolerance}" : goa.quantity.to_s
|
goa.tolerance > 0 ? "#{goa.quantity} + #{goa.tolerance}" : "#{goa.quantity}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def group_order_article_result(goa)
|
def group_order_article_result(goa)
|
||||||
|
@ -88,7 +88,7 @@ class OrderPDF < RenderPDF
|
||||||
.pluck('groups.name', 'SUM(group_orders.price)', 'ordergroup_id', 'SUM(group_orders.transport)')
|
.pluck('groups.name', 'SUM(group_orders.price)', 'ordergroup_id', 'SUM(group_orders.transport)')
|
||||||
|
|
||||||
result.map do |item|
|
result.map do |item|
|
||||||
[item.first || stock_ordergroup_name] + item[1..]
|
[item.first || stock_ordergroup_name] + item[1..-1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ class OrderPDF < RenderPDF
|
||||||
def each_ordergroup_batch(batch_size)
|
def each_ordergroup_batch(batch_size)
|
||||||
offset = 0
|
offset = 0
|
||||||
|
|
||||||
loop do
|
while true
|
||||||
go_records = ordergroups(offset, batch_size)
|
go_records = ordergroups(offset, batch_size)
|
||||||
|
|
||||||
break unless go_records.any?
|
break unless go_records.any?
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class OrdergroupsCsv < RenderCSV
|
class OrdergroupsCsv < RenderCsv
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def header
|
def header
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require 'csv'
|
require 'csv'
|
||||||
|
|
||||||
class RenderCSV
|
class RenderCsv
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
|
|
||||||
def initialize(object, options = {})
|
def initialize(object, options = {})
|
||||||
|
|
|
@ -52,7 +52,7 @@ class RotatedCell < Prawn::Table::Cell::Text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class RenderPDF < Prawn::Document
|
class RenderPdf < Prawn::Document
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class UsersCsv < RenderCSV
|
class UsersCsv < RenderCsv
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
def header
|
def header
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# config/initializers/zeitwerk.rb
|
||||||
ActiveSupport::Dependencies
|
ActiveSupport::Dependencies
|
||||||
.autoload_paths
|
.autoload_paths
|
||||||
.delete("#{Rails.root}/app/controllers/concerns")
|
.delete("#{Rails.root}/app/controllers/concerns")
|
||||||
|
|
Loading…
Reference in a new issue