Class: EdiPaymentTermsTranslation

Inherits:
ApplicationRecord show all
Defined in:
app/models/edi_payment_terms_translation.rb

Class Method Summary collapse

Methods inherited from ApplicationRecord

define_decrypted_attribute, define_decrypted_attributes, #errors_in_bullet_points, primary_connection, special_connection

Class Method Details

.table_data(edi_partner_id:, offset:, limit:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/edi_payment_terms_translation.rb', line 9

def table_data(edi_partner_id:, offset:, limit:)
  query = <<-SQL
    SELECT
      ep.edi_partner_id AS edi_partner_id,
      ep.head_office_id AS head_office_id,
      pt.payment_term_id AS payment_term_id,
      pt.code AS payment_term_code,
      pt.description AS payment_term_description,
      eptt.edi_payment_term_translation_id AS edi_payment_term_translation_id,
      eptt.edi_payment_term_code AS edi_payment_term_code,
      eptt.active AS active
    FROM
        EDI_PARTNERS ep
    LEFT JOIN
        PAYMENT_TERMS pt
        ON 1=1
    LEFT JOIN
        EDI_PAYMENT_TERMS_TRANSLATION eptt
        ON eptt.edi_partner_id = ep.edi_partner_id
        AND eptt.payment_term_id = pt.payment_term_id
    WHERE
        ep.edi_partner_id = ?
    ORDER BY
        pt.description
    OFFSET ? ROWS
    FETCH NEXT ? ROWS ONLY;
  SQL

  EdiPaymentTermsTranslation.find_by_sql([query, edi_partner_id, offset, limit]).as_json
end