Skip to content

add AgedReceivablesReport #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,24 @@ gem "rails"

gem "sinatra"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]

gem "puma"

group :development, :test do
gem "pry-byebug"
end

group :development do
end

gem "pg"
gem "activerecord"

gem 'outboxer', '1.0.0.pre.beta'

gem "sidekiq"

group :development do
end

group :test do
gem 'database_cleaner-active_record'
end

group :development, :test do
gem "pry-byebug"
gem 'rspec-rails'
gem 'factory_bot_rails'
end
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ GEM
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
crass (1.0.6)
database_cleaner-active_record (2.1.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.3.4)
diff-lcs (1.5.1)
drb (2.2.1)
Expand Down Expand Up @@ -258,6 +262,7 @@ PLATFORMS

DEPENDENCIES
activerecord
database_cleaner-active_record
factory_bot_rails
outboxer (= 1.0.0.pre.beta)
pg
Expand Down
12 changes: 12 additions & 0 deletions app/jobs/accountify/aged_receivables_report/generate_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Accountify
module AgedReceivablesReport
class GenerateJob
include Sidekiq::Job

def perform(args)
AgedReceivablesReport.generate({
'iam_tenant_id' => args['iam_tenant_id'] })
end
end
end
end
27 changes: 27 additions & 0 deletions app/jobs/event/created_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Event
class CreatedJob
include Sidekiq::Job

sidekiq_options queue: 'events', retry: false

def perform(args)
case args['type']
when 'Accountify::Invoice::IssuedEvent'
Accountify::AgedReceivablesReport::GenerateJob.perform_async({
'iam_tenant_id' => args['iam_tenant_id'] })
when 'Accountify::Invoice::UpdatedEvent'
Accountify::AgedReceivablesReport::GenerateJob.perform_async({
'iam_tenant_id' => args['iam_tenant_id'] })
when 'Accountify::Invoice::PaidEvent'
Accountify::AgedReceivablesReport::GenerateJob.perform_async({
'iam_tenant_id' => args['iam_tenant_id'] })
when 'Accountify::Invoice::VoidedEvent'
Accountify::AgedReceivablesReport::GenerateJob.perform_async({
'iam_tenant_id' => args['iam_tenant_id'] })
when 'Accountify::Invoice::DeletedEvent'
Accountify::AgedReceivablesReport::GenerateJob.perform_async({
'iam_tenant_id' => args['iam_tenant_id'] })
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class CreateAccountifyAgedReceivablesReports < ActiveRecord::Migration[7.1]
def change
create_table :accountify_aged_receivables_reports do |t|
t.bigint :iam_tenant_id, null: false, index: { unique: true }

t.date :as_at_date, null: false
t.string :currency_code, null: false
t.integer :num_periods, null: false
t.integer :period_amount, null: false
t.string :period_unit, null: false
t.string :ageing_by, null: false

t.timestamps
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class CreateAccountifyAgedReceivablesReportPeriods < ActiveRecord::Migration[7.1]
def change
create_table :accountify_aged_receivables_report_periods do |t|
t.references :aged_receivables_report,
null: false, index: true, foreign_key: { to_table: :accountify_aged_receivables_reports }

t.date :start_date, null: false
t.date :end_date, null: false
t.decimal :sub_total_amount, precision: 12, scale: 2, null: false
t.string :sub_total_currency_code, null: false

t.timestamps
end
end
end
27 changes: 26 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading