Class: PayrollTransactionHeader
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- PayrollTransactionHeader
- Defined in:
- app/models/payroll_transaction_header.rb
Defined Under Namespace
Classes: View
Constant Summary collapse
- STAGES =
{ IN_PROGRESS: '01', SENT_FOR_APPROVAL: '02', APPROVED_FOR_DEPOSIT: '03', REJECTED: '04', PAYROLL_DEPOSITED_TO_BANK: '05', REQUEST_TO_FUND_VIRTUAL_WALLET_COMPLETED: '06', REQUEST_TO_FUND_VIRTUAL_WALLET_FAILED: '07', REQUEST_TO_DEPOSIT_SENT: '08', REQUEST_TO_DEPOSIT_COMPLETED: '09' }
Class Method Summary collapse
- .all_procedure(company_id:, payroll_year: 2024, limit: 10, offset: 0, query: '', column_name: '') ⇒ Object
- .employee_transactions(payroll_transaction_header_id:, employee_id: 0, applies_to: nil, limit: 100, query: '', allow_modification: nil, tag_type: nil, grouping: ' ', offset: 0, view: 'detailed') ⇒ Object
- .generate_payroll(payroll_transaction_header_id:, user_name:, payroll_transaction_detail_id: 0, reset_prior_to_generate: false) ⇒ Object
- .transaction_details(transaction_header_id:, user_name:) ⇒ Object
- .transaction_report_procedure(company_id:, payroll_year:) ⇒ Object
- .years_for_company(company_id:) ⇒ Object
Instance Method Summary collapse
- #approved_for_deposit? ⇒ Boolean
- #in_progress? ⇒ Boolean
- #locked? ⇒ Boolean
- #payroll_deposited_to_bank? ⇒ Boolean
- #rejected? ⇒ Boolean
- #sent_for_approval? ⇒ Boolean
- #stage_description ⇒ Object
- #url ⇒ Object
Methods inherited from ApplicationRecord
define_decrypted_attribute, define_decrypted_attributes, #errors_in_bullet_points, primary_connection, special_connection
Class Method Details
.all_procedure(company_id:, payroll_year: 2024, limit: 10, offset: 0, query: '', column_name: '') ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'app/models/payroll_transaction_header.rb', line 91 def all_procedure( company_id:, payroll_year: 2024, limit: 10, offset: 0, query: '', column_name: '' ) page_count = (offset / limit) + 1 data = ActiveRecord::Base.execute_procedure( :pr_get_payroll_transaction_header_list_by_page, company_id, payroll_year, limit, query, page_count, column_name ) data.each do |row| row['remit_to_cra'] = row['remit_to_cra'].abs if row['remit_to_cra'].present? row['remit_to_mrq'] = row['remit_to_mrq'].abs if row['remit_to_mrq'].present? if row['stage'] == STAGES[:IN_PROGRESS] row['stage_name'] = 'in_progress' elsif row['stage'] == STAGES[:SENT_FOR_APPROVAL] row['stage_name'] = 'sent_for_approval' elsif row['stage'] == STAGES[:APPROVED_FOR_DEPOSIT] row['stage_name'] = 'approved_for_deposit' elsif row['stage'] == STAGES[:REJECTED] row['stage_name'] = 'rejected' elsif row['stage'] == STAGES[:PAYROLL_DEPOSITED_TO_BANK] row['stage_name'] = 'payroll_deposited_to_bank' end end { data: data, metadata: { total: data.length > 0 ? data.first['TotalRecords'] : 0, limit: limit, offset: offset } } end |
.employee_transactions(payroll_transaction_header_id:, employee_id: 0, applies_to: nil, limit: 100, query: '', allow_modification: nil, tag_type: nil, grouping: ' ', offset: 0, view: 'detailed') ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'app/models/payroll_transaction_header.rb', line 148 def employee_transactions( payroll_transaction_header_id:, employee_id: 0, applies_to: nil, limit: 100, query: '', allow_modification: nil, tag_type: nil, grouping: ' ', offset: 0, view: 'detailed' ) if view == 'detailed' all_employee_transactions( payroll_transaction_header_id: payroll_transaction_header_id, employee_id: employee_id, applies_to: applies_to, limit: limit, query: query, allow_modification: allow_modification, tag_type: tag_type, grouping: grouping, offset: offset ) elsif view == 'general' employee_transactions_summary( payroll_transaction_header_id: payroll_transaction_header_id, employee_id: employee_id ) end end |
.generate_payroll(payroll_transaction_header_id:, user_name:, payroll_transaction_detail_id: 0, reset_prior_to_generate: false) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'app/models/payroll_transaction_header.rb', line 180 def generate_payroll( payroll_transaction_header_id:, user_name:, payroll_transaction_detail_id: 0, reset_prior_to_generate: false ) ActiveRecord::Base.execute_procedure( 'pr_generate_payroll', payroll_transaction_header_id, payroll_transaction_detail_id, # 0 for the first time reset_prior_to_generate, # for the first time user_name )[0] end |
.transaction_details(transaction_header_id:, user_name:) ⇒ Object
194 195 196 197 198 199 200 |
# File 'app/models/payroll_transaction_header.rb', line 194 def transaction_details(transaction_header_id:, user_name:) ActiveRecord::Base.execute_procedure( 'pr_get_payroll_transaction_details', transaction_header_id, user_name )[0] end |
.transaction_report_procedure(company_id:, payroll_year:) ⇒ Object
137 138 139 140 141 142 143 144 145 146 |
# File 'app/models/payroll_transaction_header.rb', line 137 def transaction_report_procedure( company_id:, payroll_year: ) ActiveRecord::Base.execute_procedure( 'pr_get_payroll_transaction_header_report', company_id, payroll_year ) end |
.years_for_company(company_id:) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'app/models/payroll_transaction_header.rb', line 82 def years_for_company(company_id:) where(company_id: company_id) .joins(:payroll_period) .select('payroll_periods.year') .order('payroll_periods.year') .distinct .map(&:year) end |
Instance Method Details
#approved_for_deposit? ⇒ Boolean
51 52 53 |
# File 'app/models/payroll_transaction_header.rb', line 51 def approved_for_deposit? stage == STAGES[:APPROVED_FOR_DEPOSIT] end |
#in_progress? ⇒ Boolean
43 44 45 |
# File 'app/models/payroll_transaction_header.rb', line 43 def in_progress? stage == STAGES[:IN_PROGRESS] end |
#locked? ⇒ Boolean
39 40 41 |
# File 'app/models/payroll_transaction_header.rb', line 39 def locked? !in_progress? end |
#payroll_deposited_to_bank? ⇒ Boolean
59 60 61 |
# File 'app/models/payroll_transaction_header.rb', line 59 def payroll_deposited_to_bank? stage == STAGES[:PAYROLL_DEPOSITED_TO_BANK] end |
#rejected? ⇒ Boolean
55 56 57 |
# File 'app/models/payroll_transaction_header.rb', line 55 def rejected? stage == STAGES[:REJECTED] end |
#sent_for_approval? ⇒ Boolean
47 48 49 |
# File 'app/models/payroll_transaction_header.rb', line 47 def sent_for_approval? stage == STAGES[:SENT_FOR_APPROVAL] end |
#stage_description ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/models/payroll_transaction_header.rb', line 63 def stage_description if in_progress? I18n.t('payroll.transactions.stages.in_progress') elsif sent_for_approval? I18n.t('payroll.transactions.stages.sent_for_approval') elsif approved_for_deposit? I18n.t('payroll.transactions.stages.approved_for_deposit') elsif rejected? I18n.t('payroll.transactions.stages.rejected') elsif payroll_deposited_to_bank? I18n.t('payroll.transactions.stages.deposited') end end |