Class: SAFT::V2::HTML::LinesTable
- Inherits:
-
Object
- Object
- SAFT::V2::HTML::LinesTable
- Defined in:
- lib/saft/v2/html.rb
Instance Method Summary collapse
-
#initialize(lines) ⇒ LinesTable
constructor
A new instance of LinesTable.
- #to_tubby ⇒ Object
Constructor Details
#initialize(lines) ⇒ LinesTable
Returns a new instance of LinesTable.
411 412 413 |
# File 'lib/saft/v2/html.rb', line 411 def initialize(lines) @lines = lines end |
Instance Method Details
#to_tubby ⇒ Object
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/saft/v2/html.rb', line 415 def to_tubby Tubby.new { |t| t.table { t.thead { t.tr { t.th("RecordID") t.th("AccountID") t.th("Analysis") t.th("ValueDate") t.th("Description") t.th("Dedit Amount", class: "text-right") t.th("Credit Amount", class: "text-right") t.th("Rest") } } t.tbody { @lines.each { |line| t.tr { t.td(line.record_id) t.td { account = t.get_account(line.account_id) t.div(title: account.title) { t << line.account_id } } t.td { line.analyses&.each do |line_analysis| analysis = t.get_analysis( line_analysis.analysis_id, line_analysis.analysis_type, ) t.div(title: analysis.title) { t << analysis.link { t << "#{line_analysis.analysis_type} #{line_analysis.analysis_id}" } } end } t.td(line.value_date) t.td(line.description) t.td(line.debit_amount&.amount, class: "text-right") t.td(line.credit_amount&.amount, class: "text-right") t.td { t.div(class: "mb-2 pl-2 border-l-2") { if line.customer_id customer = t.get_customer(line.customer_id) t.div(title: customer.title) { t.strong("Customer ") t << line.customer_id t << " #{customer.name}" } end if line.supplier_id supplier = t.get_supplier(line.supplier_id) t.div(title: supplier.title) { t.strong("Supplier ") t << line.supplier_id t << " #{supplier.name}" } end t << RenderHash.new( line .attributes .except( :record_id, :account_id, :customer_id, :supplier_id, :analyses, :value_date, :description, :debit_amount, :credit_amount, ), ) } } } } } } } end |