| | |
| | | T1.payment_method, |
| | | T1.delivery_date, |
| | | DATEDIFF(T1.delivery_date, CURDATE()) AS delivery_days_diff, |
| | | COALESCE(stock_type_info.stock_type, 'qualified') AS stock_type, |
| | | COALESCE(T1.stock_type, 'qualified') AS stock_type, |
| | | IFNULL(shipping_status_counts.is_all_shipped, FALSE) AS is_fh |
| | | FROM sales_ledger T1 |
| | | LEFT JOIN sys_user T2 ON T1.entry_person = T2.user_id |
| | | LEFT JOIN ( |
| | | SELECT sales_ledger_id, MAX(stock_type) AS stock_type |
| | | FROM sales_ledger_product |
| | | WHERE type = 1 |
| | | GROUP BY sales_ledger_id |
| | | ) stock_type_info ON T1.id = stock_type_info.sales_ledger_id |
| | | LEFT JOIN ( |
| | | SELECT sales_ledger_id, |
| | | CASE |
| | |
| | | <if test="salesLedgerDto.entryDateEnd != null and salesLedgerDto.entryDateEnd != '' "> |
| | | AND T1.entry_date <= DATE_FORMAT(#{salesLedgerDto.entryDateEnd},'%Y-%m-%d') |
| | | </if> |
| | | |
| | | <if test="salesLedgerDto.stockType != null and salesLedgerDto.stockType != '' "> |
| | | AND COALESCE(T1.stock_type, 'qualified') = #{salesLedgerDto.stockType} |
| | | </if> |
| | | </where> |
| | | order by T1.entry_date desc |
| | | </select> |