Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5903 Fix country code from de_metas_endcustomer_fresh_reports.Docs_Sales_Invoice_Root
- Loading branch information
1 parent
dc79597
commit 85a76f8
Showing
2 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...l/system/70-de.metas.fresh/5538650_sys_gh5903_FixCountryCodeInDocs_Sales_Invoice_Root.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
DROP FUNCTION IF EXISTS de_metas_endcustomer_fresh_reports.Docs_Sales_Invoice_Root ( IN Record_ID numeric, IN AD_Language Character Varying (6) ); | ||
CREATE OR REPLACE FUNCTION de_metas_endcustomer_fresh_reports.Docs_Sales_Invoice_Root ( IN Record_ID numeric, IN AD_Language Character Varying (6) ) | ||
RETURNS TABLE | ||
(AD_Org_ID numeric, | ||
DocStatus character(2), | ||
PrintName character varying(60), | ||
countrycode character(2), | ||
C_Currency_ID numeric, | ||
displayhu text | ||
) | ||
AS | ||
$$ | ||
SELECT | ||
i.AD_Org_ID, | ||
i.DocStatus, | ||
dt.PrintName, | ||
c.countrycode, | ||
i.C_Currency_ID, | ||
CASE | ||
WHEN | ||
EXISTS( | ||
SELECT 0 | ||
FROM C_InvoiceLine il | ||
INNER JOIN M_Product p ON il.M_Product_ID = p.M_Product_ID AND p.isActive = 'Y' | ||
INNER JOIN M_Product_Category pc ON p.M_Product_Category_ID = pc.M_Product_Category_ID AND pc.isActive = 'Y' | ||
WHERE pc.M_Product_Category_ID = getSysConfigAsNumeric('PackingMaterialProductCategoryID', il.AD_Client_ID, il.AD_Org_ID) | ||
AND il.C_Invoice_ID = i.C_Invoice_ID AND il.isActive = 'Y' | ||
) | ||
THEN 'Y' | ||
ELSE 'N' | ||
END as displayhu | ||
FROM | ||
C_Invoice i | ||
INNER JOIN C_DocType dt ON i.C_DocType_ID = dt.C_DocType_ID AND dt.isActive = 'Y' | ||
LEFT OUTER JOIN C_DocType_Trl dtt ON i.C_DocType_ID = dtt.C_DocType_ID AND dtt.AD_Language = $2 AND dtt.isActive = 'Y' | ||
|
||
LEFT OUTER JOIN C_BPartner_Location bpl ON bpl.C_BPartner_Location_id = i.C_BPartner_Location_ID | ||
LEFT OUTER JOIN C_Location l ON l.C_Location_ID = bpl.C_Location_ID | ||
LEFT OUTER JOIN C_Country c ON c.C_Country_ID = l.C_Country_ID | ||
WHERE | ||
i.C_Invoice_ID = $1 AND i.isActive = 'Y' | ||
$$ | ||
LANGUAGE sql STABLE | ||
; |