-- Invoices that have files attached
-- This report lets you view invoices that have files attached but have not been processed
-- FILTER: {
--   filter: "link",
--   column: "link"
-- }
-- FILTER: {
--   filter: "date",
--   column: "create_date",
--   params: {
--     "format": "m/d/y"
--   }
-- }


SELECT (SELECT bl.name FROM simplebrsprod.business_location bl WHERE bl.id = dc.location_id) as name,
       dc.create_date,
       concat('https://simple123.com/business/locations/', dc.location_id, '/invoices/', dc.id) as link
FROM simplebrsprod.deal_cart dc
WHERE dc.files is not null and dc.invoice_total is null and dc.has_items = false and dc.update_date > (NOW() - interval '1 year')
ORDER BY dc.create_date desc;