[Home] [Help]
370: P_BaseCurrencyCode VARCHAR2,
371: P_ExchangeRateType VARCHAR2
372: ) IS
373: SELECT sum(decode(aerl.currency_code, P_BaseCurrencyCode, aerl.amount,
374: gl_currency_api.CONVERT_AMOUNT_SQL( aerl.currency_code,
375: P_BaseCurrencyCode,
376: sysdate,
377: P_ExchangeRateType,
378: aerl.amount
396: SELECT SUM(line_amount) AS violation_line_amount
397: FROM
398: (
399: SELECT decode(aerl.currency_code, P_BaseCurrencyCode, aerl.amount,
400: gl_currency_api.CONVERT_AMOUNT_SQL( aerl.currency_code,
401: P_BaseCurrencyCode,
402: sysdate,
403: P_ExchangeRateType,
404: aerl.amount
429: SELECT sum(violation_amount) as violation_amount,
430: sum(number_of_violations) as number_of_violations
431: FROM
432: ( SELECT sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.violation_amount,
433: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
434: P_BaseCurrencyCode,
435: sysdate,
436: P_ExchangeRateType,
437: aerv.violation_amount
445: AND aerv.violation_type NOT IN ( 'RECEIPT_MISSING', 'DAILY_SUM_LIMIT')
446: UNION ALL
447: /* The below query is to fetch the daily sum limit violations for MEALS category */
448: SELECT decode(aerh.default_currency_code, P_BaseCurrencyCode, apv.exceeded_amount,
449: GL_CURRENCY_API.convert_amount_sql( aerh.default_currency_code,
450: P_BaseCurrencyCode,
451: SYSDATE,
452: P_ExchangeRateType,
453: apv.exceeded_amount
472: AND aerh.week_end_date BETWEEN P_StartDate AND P_EndDate
473: UNION ALL
474: /* The below query is to bundle up RECEIPT_MISSING violations per line */
475: SELECT sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.violation_amount,
476: GL_CURRENCY_API.convert_amount_sql( aerv.currency_code,
477: P_BaseCurrencyCode,
478: SYSDATE,
479: P_ExchangeRateType,
480: aerv.violation_amount
743:
744: -- If amount needs to be converted to user preference currency
745: -- convert the amounts
746: IF ( L_Convert ) THEN
747: L_ByManagerTab( L_TabIndex ).total_expenses := gl_currency_api.CONVERT_AMOUNT_SQL(
748: L_BaseCurrencyCode,
749: P_UserCurrencyCode,
750: sysdate,
751: L_ExchangeRateType,
751: L_ExchangeRateType,
752: L_ExpenseAmount
753: );
754:
755: L_ByManagerTab( L_TabIndex ).violation_line_amount := gl_currency_api.CONVERT_AMOUNT_SQL(
756: L_BaseCurrencyCode,
757: P_UserCurrencyCode,
758: sysdate,
759: L_ExchangeRateType,
758: sysdate,
759: L_ExchangeRateType,
760: L_ViolationLineAmount
761: );
762: L_ByManagerTab( L_TabIndex ).violation_amount := gl_currency_api.CONVERT_AMOUNT_SQL(
763: L_BaseCurrencyCode,
764: P_UserCurrencyCode,
765: sysdate,
766: L_ExchangeRateType,
931: ) IS
932: SELECT sum(NVL(expense_amount,0)) as expense_amount
933: FROM
934: ( SELECT decode(aerl.currency_code, P_BaseCurrencyCode, aerl.amount,
935: gl_currency_api.CONVERT_AMOUNT_SQL( aerl.currency_code,
936: P_BaseCurrencyCode,
937: sysdate,
938: P_ExchangeRateType,
939: aerl.amount
943: AND aerl.week_end_date BETWEEN P_StartDate AND P_EndDate
944: AND nvl(aerl.category_code, 'ALL') = decode (P_ExpenseCategory, 'ALL', nvl(aerl.category_code, 'ALL'), P_ExpenseCategory)
945: UNION ALL
946: SELECT decode(aerl.currency_code, P_BaseCurrencyCode, aerl.amount,
947: gl_currency_api.CONVERT_AMOUNT_SQL( aerl.currency_code,
948: P_BaseCurrencyCode,
949: sysdate,
950: P_ExchangeRateType,
951: aerl.amount
976: SELECT SUM(line_amount) AS violation_line_amount
977: FROM
978: (
979: SELECT decode(aerl.currency_code, P_BaseCurrencyCode, aerl.amount,
980: gl_currency_api.CONVERT_AMOUNT_SQL( aerl.currency_code,
981: P_BaseCurrencyCode,
982: sysdate,
983: P_ExchangeRateType,
984: aerl.amount
993: AND aerl.week_end_date BETWEEN P_StartDate AND P_EndDate
994: AND nvl(aerl.category_code, 'ALL') = decode (P_ExpenseCategory, 'ALL', nvl(aerl.category_code, 'ALL'), P_ExpenseCategory)
995: UNION ALL
996: SELECT decode(aerl.currency_code, P_BaseCurrencyCode, aerl.amount,
997: gl_currency_api.CONVERT_AMOUNT_SQL( aerl.currency_code,
998: P_BaseCurrencyCode,
999: sysdate,
1000: P_ExchangeRateType,
1001: aerl.amount
1033: sum(nvl(number_of_violations,0)) as number_of_violations
1034: FROM
1035: (
1036: SELECT sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.violation_amount,
1037: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1038: P_BaseCurrencyCode,
1039: sysdate,
1040: P_ExchangeRateType,
1041: aerv.violation_amount
1040: P_ExchangeRateType,
1041: aerv.violation_amount
1042: ))) as violation_amount,
1043: sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.allowable_amount,
1044: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1045: P_BaseCurrencyCode,
1046: sysdate,
1047: P_ExchangeRateType,
1048: aerv.allowable_amount
1055: AND aerv.violation_type = decode(P_ViolationType, 'ALL', aerv.violation_type, P_ViolationType)
1056: AND aerv.violation_type NOT IN ( 'RECEIPT_MISSING', 'DAILY_SUM_LIMIT')
1057: UNION ALL
1058: SELECT sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.violation_amount,
1059: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1060: P_BaseCurrencyCode,
1061: sysdate,
1062: P_ExchangeRateType,
1063: aerv.violation_amount
1062: P_ExchangeRateType,
1063: aerv.violation_amount
1064: ))) as violation_amount,
1065: sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.allowable_amount,
1066: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1067: P_BaseCurrencyCode,
1068: sysdate,
1069: P_ExchangeRateType,
1070: aerv.allowable_amount
1084: AND aerv.violation_type NOT IN ( 'RECEIPT_MISSING', 'DAILY_SUM_LIMIT')
1085: UNION ALL
1086: /* The below two queries are to fetch the daily sum limit violations for MEALS category */
1087: SELECT decode(aerh.default_currency_code, P_BaseCurrencyCode, apv.exceeded_amount,
1088: GL_CURRENCY_API.convert_amount_sql( aerh.default_currency_code,
1089: P_BaseCurrencyCode,
1090: SYSDATE,
1091: P_ExchangeRateType,
1092: apv.exceeded_amount
1091: P_ExchangeRateType,
1092: apv.exceeded_amount
1093: )) as violation_amount,
1094: decode(aerh.default_currency_code, P_BaseCurrencyCode, apv.allowable_amount,
1095: GL_CURRENCY_API.convert_amount_sql( aerh.default_currency_code,
1096: P_BaseCurrencyCode,
1097: SYSDATE,
1098: P_ExchangeRateType,
1099: apv.allowable_amount
1118: AND (aerh.employee_id = P_EmployeeId OR aerh.paid_on_behalf_employee_id = P_EmployeeId)
1119: AND aerh.week_end_date BETWEEN P_StartDate AND P_EndDate
1120: UNION ALL
1121: SELECT decode(aerh.default_currency_code, P_BaseCurrencyCode, apv.exceeded_amount,
1122: GL_CURRENCY_API.convert_amount_sql( aerh.default_currency_code,
1123: P_BaseCurrencyCode,
1124: SYSDATE,
1125: P_ExchangeRateType,
1126: apv.exceeded_amount
1125: P_ExchangeRateType,
1126: apv.exceeded_amount
1127: )) as violation_amount,
1128: decode(aerh.default_currency_code, P_BaseCurrencyCode, apv.allowable_amount,
1129: GL_CURRENCY_API.convert_amount_sql( aerh.default_currency_code,
1130: P_BaseCurrencyCode,
1131: SYSDATE,
1132: P_ExchangeRateType,
1133: apv.allowable_amount
1159: AND 'MANAGER' = P_QryType
1160: /* The below query is to bundle up RECEIPT_MISSING violations per line */
1161: UNION ALL
1162: SELECT sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.violation_amount,
1163: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1164: P_BaseCurrencyCode,
1165: sysdate,
1166: P_ExchangeRateType,
1167: aerv.violation_amount
1166: P_ExchangeRateType,
1167: aerv.violation_amount
1168: ))) as violation_amount,
1169: sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.allowable_amount,
1170: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1171: P_BaseCurrencyCode,
1172: sysdate,
1173: P_ExchangeRateType,
1174: aerv.allowable_amount
1181: AND ((P_ViolationType = 'ALL') or (P_ViolationType = 'RECEIPT_MISSING')) AND aerv.violation_type = 'RECEIPT_MISSING'
1182: group by nvl(aerv.itemization_parent_id, aerv.report_line_id)
1183: UNION ALL
1184: SELECT sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.violation_amount,
1185: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1186: P_BaseCurrencyCode,
1187: sysdate,
1188: P_ExchangeRateType,
1189: aerv.violation_amount
1188: P_ExchangeRateType,
1189: aerv.violation_amount
1190: ))) as violation_amount,
1191: sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.allowable_amount,
1192: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1193: P_BaseCurrencyCode,
1194: sysdate,
1195: P_ExchangeRateType,
1196: aerv.allowable_amount
1326:
1327: -- If amount needs to be converted to user preference currency
1328: -- convert the amounts
1329: IF ( L_Convert ) THEN
1330: L_ByExpCatTab( L_TabIndex ).total_expenses := gl_currency_api.CONVERT_AMOUNT_SQL(
1331: L_BaseCurrencyCode,
1332: P_UserCurrencyCode,
1333: sysdate,
1334: L_ExchangeRateType,
1333: sysdate,
1334: L_ExchangeRateType,
1335: L_ExpenseAmount
1336: );
1337: L_ByExpCatTab( L_TabIndex ).violation_line_amount := gl_currency_api.CONVERT_AMOUNT_SQL(
1338: L_BaseCurrencyCode,
1339: P_UserCurrencyCode,
1340: sysdate,
1341: L_ExchangeRateType,
1340: sysdate,
1341: L_ExchangeRateType,
1342: L_ViolationLineAmount
1343: );
1344: L_ByExpCatTab( L_TabIndex ).violation_amount := gl_currency_api.CONVERT_AMOUNT_SQL(
1345: L_BaseCurrencyCode,
1346: P_UserCurrencyCode,
1347: sysdate,
1348: L_ExchangeRateType,
1347: sysdate,
1348: L_ExchangeRateType,
1349: L_ViolationAmount
1350: );
1351: L_ByExpCatTab( L_TabIndex ).allowable_amount := gl_currency_api.CONVERT_AMOUNT_SQL(
1352: L_BaseCurrencyCode,
1353: P_UserCurrencyCode,
1354: sysdate,
1355: L_ExchangeRateType,
1502: SELECT SUM(line_amount) AS violation_line_amount
1503: FROM
1504: (
1505: SELECT decode(aerl.currency_code, P_BaseCurrencyCode, aerl.amount,
1506: gl_currency_api.CONVERT_AMOUNT_SQL( aerl.currency_code,
1507: P_BaseCurrencyCode,
1508: sysdate,
1509: P_ExchangeRateType,
1510: aerl.amount
1519: AND aerl.week_end_date BETWEEN P_StartDate AND P_EndDate
1520: AND nvl(aerl.category_code, 'ALL') = decode (P_ExpenseCategory, 'ALL', nvl(aerl.category_code, 'ALL'), P_ExpenseCategory)
1521: UNION ALL
1522: SELECT decode(aerl.currency_code, P_BaseCurrencyCode, aerl.amount,
1523: gl_currency_api.CONVERT_AMOUNT_SQL( aerl.currency_code,
1524: P_BaseCurrencyCode,
1525: sysdate,
1526: P_ExchangeRateType,
1527: aerl.amount
1560: sum(nvl(number_of_violations,0)) as number_of_violations
1561: FROM
1562: (
1563: SELECT sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.violation_amount,
1564: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1565: P_BaseCurrencyCode,
1566: sysdate,
1567: P_ExchangeRateType,
1568: aerv.violation_amount
1567: P_ExchangeRateType,
1568: aerv.violation_amount
1569: ))) as violation_amount,
1570: sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.allowable_amount,
1571: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1572: P_BaseCurrencyCode,
1573: sysdate,
1574: P_ExchangeRateType,
1575: aerv.allowable_amount
1582: AND aerv.violation_type = decode(P_ViolationType, 'ALL', aerv.violation_type, P_ViolationType)
1583: AND aerv.violation_type NOT IN ( 'RECEIPT_MISSING', 'DAILY_SUM_LIMIT')
1584: UNION ALL
1585: SELECT sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.violation_amount,
1586: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1587: P_BaseCurrencyCode,
1588: sysdate,
1589: P_ExchangeRateType,
1590: aerv.violation_amount
1589: P_ExchangeRateType,
1590: aerv.violation_amount
1591: ))) as violation_amount,
1592: sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.allowable_amount,
1593: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1594: P_BaseCurrencyCode,
1595: sysdate,
1596: P_ExchangeRateType,
1597: aerv.allowable_amount
1611: AND aerv.violation_type NOT IN ( 'RECEIPT_MISSING', 'DAILY_SUM_LIMIT')
1612: UNION ALL
1613: /* The below two queries are to fetch the daily sum limit violations for MEALS category */
1614: SELECT decode(aerh.default_currency_code, P_BaseCurrencyCode, apv.exceeded_amount,
1615: GL_CURRENCY_API.convert_amount_sql( aerh.default_currency_code,
1616: P_BaseCurrencyCode,
1617: SYSDATE,
1618: P_ExchangeRateType,
1619: apv.exceeded_amount
1618: P_ExchangeRateType,
1619: apv.exceeded_amount
1620: )) as violation_amount,
1621: decode(aerh.default_currency_code, P_BaseCurrencyCode, apv.allowable_amount,
1622: GL_CURRENCY_API.convert_amount_sql( aerh.default_currency_code,
1623: P_BaseCurrencyCode,
1624: SYSDATE,
1625: P_ExchangeRateType,
1626: apv.allowable_amount
1645: AND (aerh.employee_id = P_EmployeeId OR aerh.paid_on_behalf_employee_id = P_EmployeeId)
1646: AND aerh.week_end_date BETWEEN P_StartDate AND P_EndDate
1647: UNION ALL
1648: SELECT decode(aerh.default_currency_code, P_BaseCurrencyCode, apv.exceeded_amount,
1649: GL_CURRENCY_API.convert_amount_sql( aerh.default_currency_code,
1650: P_BaseCurrencyCode,
1651: SYSDATE,
1652: P_ExchangeRateType,
1653: apv.exceeded_amount
1652: P_ExchangeRateType,
1653: apv.exceeded_amount
1654: )) as violation_amount,
1655: decode(aerh.default_currency_code, P_BaseCurrencyCode, apv.allowable_amount,
1656: GL_CURRENCY_API.convert_amount_sql( aerh.default_currency_code,
1657: P_BaseCurrencyCode,
1658: SYSDATE,
1659: P_ExchangeRateType,
1660: apv.allowable_amount
1686: AND 'MANAGER' = P_QryType
1687: /* The below query is to bundle up RECEIPT_MISSING violations per line */
1688: UNION ALL
1689: SELECT sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.violation_amount,
1690: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1691: P_BaseCurrencyCode,
1692: sysdate,
1693: P_ExchangeRateType,
1694: aerv.violation_amount
1693: P_ExchangeRateType,
1694: aerv.violation_amount
1695: ))) as violation_amount,
1696: sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.allowable_amount,
1697: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1698: P_BaseCurrencyCode,
1699: sysdate,
1700: P_ExchangeRateType,
1701: aerv.allowable_amount
1708: AND ((P_ViolationType = 'ALL') or (P_ViolationType = 'RECEIPT_MISSING')) AND aerv.violation_type = 'RECEIPT_MISSING'
1709: group by nvl(aerv.itemization_parent_id, aerv.report_line_id)
1710: UNION ALL
1711: SELECT sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.violation_amount,
1712: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1713: P_BaseCurrencyCode,
1714: sysdate,
1715: P_ExchangeRateType,
1716: aerv.violation_amount
1715: P_ExchangeRateType,
1716: aerv.violation_amount
1717: ))) as violation_amount,
1718: sum(decode(aerv.currency_code, P_BaseCurrencyCode, aerv.allowable_amount,
1719: gl_currency_api.CONVERT_AMOUNT_SQL( aerv.currency_code,
1720: P_BaseCurrencyCode,
1721: sysdate,
1722: P_ExchangeRateType,
1723: aerv.allowable_amount
1834:
1835: -- If amount needs to be converted to user preference currency
1836: -- convert the amounts
1837: IF ( L_Convert ) THEN
1838: L_ByViolTypeTab( L_TabIndex ).violation_line_amount := gl_currency_api.CONVERT_AMOUNT_SQL(
1839: L_BaseCurrencyCode,
1840: P_UserCurrencyCode,
1841: sysdate,
1842: L_ExchangeRateType,
1841: sysdate,
1842: L_ExchangeRateType,
1843: L_ViolationLineAmount
1844: );
1845: L_ByViolTypeTab( L_TabIndex ).violation_amount := gl_currency_api.CONVERT_AMOUNT_SQL(
1846: L_BaseCurrencyCode,
1847: P_UserCurrencyCode,
1848: sysdate,
1849: L_ExchangeRateType,
1848: sysdate,
1849: L_ExchangeRateType,
1850: L_ViolationAmount
1851: );
1852: L_ByViolTypeTab( L_TabIndex ).allowable_amount := gl_currency_api.CONVERT_AMOUNT_SQL(
1853: L_BaseCurrencyCode,
1854: P_UserCurrencyCode,
1855: sysdate,
1856: L_ExchangeRateType,