İçereği Atla
Menü
Bu soru işaretlendi
905 Görünümler

The query I am using for fetching sales invoice details is as follows SELECT 


    am.id as x_invoice_id,


    am.name AS x_invoice_number,                    -- Order number (Sale order name)


    'InternalUniqueNumber' AS x_order_id,           -- Internal Unique number


    so.name AS x_order_number,                      -- Order title


    am.invoice_date AS x_invoice_date,              -- Order date


    am.amount_untaxed AS x_amount_without_tax,      -- Total excluding tax


    am.amount_total AS x_total_amount,              -- Total including tax


    am.amount_tax AS x_total_tax,                   -- Total VAT (tax amount)


    CASE


        WHEN am.payment_state = 'paid' THEN 'Paid'


        ELSE 'Not Paid'


    END AS x_paid_status,                           -- Paid status


    am.payment_reference AS x_payment_reference,    -- Payment reference


    am.company_id AS x_company_id,                  -- Company ID


    ap.write_date


FROM


    account_move am


JOIN


    sale_order so ON substring(am.invoice_origin FROM 1 FOR 12) = so.name


LEFT JOIN


   account_payment ap on am.id=ap.move_id


WHERE


    am.write_date >= NOW() - INTERVAL '365 days'     -- Check if write_date is within the last 30 days


ORDER BY


    am.id DESC;




Here in this case, I am getting null ap.write_date even if the invoice is paid.




What could be the issue ? Or The way I am fetching the data is wrong? 




Any suggestion will be appreciated.

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Oca 25
5102
2
Haz 25
2335
2
Haz 25
6337
0
Kas 23
1640
0
Mar 23
1768