Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def execute(filters=None):
{"label": "Date", "fieldname": "transaction_date", "fieldtype": "Date", "width": 110},
{"label": "Customer", "fieldname": "customer_name", "fieldtype": "Data", "width": 140},
{"label": "Sales Order", "fieldname": "sales_order", "fieldtype": "Link", "options": "Sales Order", "width": 200},
{"label": "Order Value", "fieldname": "grand_total", "fieldtype": "Currency", "width": 110},
{"label": "Advance Date", "fieldname": "posting_date", "fieldtype": "Date", "width": 110}, {"label": "Order Value", "fieldname": "grand_total", "fieldtype": "Currency", "width": 110},
{"label": "Advance Paid", "fieldname": "advance_paid", "fieldtype": "Currency", "width": 110},
]

Expand All @@ -25,6 +25,7 @@ def execute(filters=None):
columns.extend([
{"label": "Delivery Status", "fieldname": "delivery_status", "fieldtype": "Data", "width": 130},
{"label": "Sales Invoice", "fieldname": "sales_invoice", "fieldtype": "Link", "options": "Sales Invoice", "width": 160},
{"label": "Sales Invoice Date", "fieldname": "invoice_date", "fieldtype": "Date", "width": 110},
{"label": "Invoice Value", "fieldname": "invoice_value", "fieldtype": "Currency", "width": 110},
{"label": "Paid On Invoice", "fieldname": "paid_on_invoice", "fieldtype": "Currency", "width": 120},
])
Expand Down Expand Up @@ -55,9 +56,11 @@ def execute(filters=None):
so.grand_total,
so.advance_paid,
so.delivery_status,
si_summary.name AS sales_invoice,
si_summary.name AS sales_invoice,
si_summary.posting_date AS invoice_date,
si_summary.grand_total AS invoice_value,
si_summary.outstanding_amount AS outstanding_amount,

adv_pe.adv_date AS posting_date,

CASE
WHEN si_summary.name IS NOT NULL THEN si_summary.outstanding_amount
Expand All @@ -78,7 +81,7 @@ def execute(filters=None):
JOIN `tabCustomer` c ON so.customer = c.name

LEFT JOIN (
SELECT DISTINCT sii.sales_order, si.name, si.grand_total, si.outstanding_amount
SELECT DISTINCT sii.sales_order, si.name, si.grand_total, si.outstanding_amount,si.posting_date
FROM `tabSales Invoice Item` sii
JOIN `tabSales Invoice` si ON si.name = sii.parent
WHERE si.docstatus = 1
Expand All @@ -88,6 +91,8 @@ def execute(filters=None):
SELECT
so_name AS sales_order,

MAX(payment_date) AS adv_date,

SUM(CASE WHEN source = 'SO' AND mode_of_payment = 'Cash' THEN allocated ELSE 0 END) +
SUM(CASE WHEN source = 'SI' AND mode_of_payment = 'Cash'
AND so_has_advance = 0 THEN allocated ELSE 0 END) AS cash_adv,
Expand All @@ -103,6 +108,7 @@ def execute(filters=None):
FROM (
SELECT
per.reference_name AS so_name,
pe.posting_date AS payment_date,
pe.mode_of_payment,
per.allocated_amount AS allocated,
'SO' AS source,
Expand All @@ -117,6 +123,7 @@ def execute(filters=None):

SELECT
sii.sales_order AS so_name,
pe.posting_date AS payment_date,
pe.mode_of_payment,
sia.allocated_amount AS allocated,
'SI' AS source,
Expand Down
Loading