Class: SAFT::V2::HTML::RenderGeneralLedgerTable

Inherits:
Object
  • Object
show all
Defined in:
lib/saft/v2/html.rb

Instance Method Summary collapse

Constructor Details

#initialize(accounts) ⇒ RenderGeneralLedgerTable

Returns a new instance of RenderGeneralLedgerTable.



192
193
194
# File 'lib/saft/v2/html.rb', line 192

def initialize(accounts)
  @accounts = accounts
end

Instance Method Details

#to_tubbyObject



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/saft/v2/html.rb', line 196

def to_tubby
  Tubby.new { |t|
    t.table {
      t.thead {
        t.tr {
          t.th("Id")
          t.th("Description")
          t.th("Std account")
          t.th("Opening balance")
          t.th("Closing balance")
          t.th("Rest")
        }
      }
      t.tbody {
        @accounts.each do ||
           = SAFT::V2::Norway.(.)
           = "Not found"
          if 
             = <<~TEXT
              Account no #{.number}
              #{.description_en}
              #{.description_no}
            TEXT
          end

          t.tr {
            t.td(.)
            t.td(.)
            t.td(., title: )
            t.td {
              t.div(class: "flex justify-between") {
                if .opening_debit_balance
                  t.span("Debit")
                  t.span(.opening_debit_balance)
                end

                if .opening_credit_balance
                  t.span("Credit")
                  t.span(-.opening_credit_balance)
                end
              }
            }
            t.td {
              t.div(class: "flex justify-between") {
                if .closing_debit_balance
                  t.span("Debit")
                  t.span(.closing_debit_balance)
                end

                if .closing_credit_balance
                  t.span("Credit")
                  t.span(-.closing_credit_balance)
                end
              }
            }
            t.td(class: "pl-2") {
              t.div(class: "pl-2 border-l-2") {
                t <<
                  RenderHash.new(
                    
                      .attributes
                      .except(
                        :account_id,
                        :account_description,
                        :standard_account_id,
                        :opening_debit_balance,
                        :opening_credit_balance,
                        :closing_debit_balance,
                        :closing_credit_balance,
                      ),
                  )
              }
            }
          }
        end
      }
    }
  }
end