BB manual action

// ============================================================================ // SECTION 1: Approve Beginning Balance (Pay Full Amount) // Action Code: MAV_DIR_BB_ACTION_1006 // ============================================================================ if (BBActionManual_c == 'MAV_DIR_BB_ACTION_1006') { println("[BBAction Trigger] Action: Approve Beginning Balance (Pay Full Amount)") println("[BBAction Trigger] IncentiveType: ${IncentiveType_c}") // Verify the Incentive Type condition (COMMISSION or BONUS, not SPIFF) if (IncentiveType_c == 'COMMISSION' || IncentiveType_c == 'BONUS') { println("[BBAction Trigger] Clearing BBReasonCode and BBMPAComment") BBMPAComment_c = null BBReasonCode_c = null MPAReasonCode_c = null println("[BBAction Trigger] Section 1 completed successfully") } else { println("[BBAction Trigger] IncentiveType not COMMISSION or BONUS - skipping") } } // ============================================================================ // SECTION 2: Hold Beginning Balance (Full BB on Hold Until next month) // Action Code: MAV_DIR_BB_ACTION_1007 // ============================================================================ if (BBActionManual_c == 'MAV_DIR_BB_ACTION_1007') { println("[BBAction Trigger] Action: Hold Beginning Balance") println("[BBAction Trigger] IncentiveType: ${IncentiveType_c}") println("[BBAction Trigger] BeginningBalance: ${BeginningBalance_c}") // Verify the Incentive Type condition (COMMISSION or BONUS, not SPIFF) if (IncentiveType_c == 'COMMISSION' || IncentiveType_c == 'BONUS') { println("[BBAction Trigger] Clearing BBReasonCode and BBMPAComment") BBMPAComment_c = null BBReasonCode_c = null MPAReasonCode_c = null // Calculate reverse of CED: (-1) * CED_c def reverseCED_c = -1 * (CED_c ?: 0) // as par discussionwith Srini 1-December-25 println("[BBAction Trigger] Calculated reverseCED_c: ${reverseCED_c}") println("[BBAction Trigger] Setting ExpectedPaymentAmount to PTDEarnings: ${PTDEarnings_c}") ExpectedPaymentAmount_c = PTDEarnings_c // Set MPAGenerated only if value is different (avoid validation threshold) println("[BBAction Trigger] Setting MPAGenerated") MPAGenerated_c = ExpectedPaymentAmount_c + reverseCED_c // Set MPAStatus_c to 'Auto approved' if (MPAStatus_c != 'Auto approved') { println("[BBAction Trigger] Setting MPAStatus from '${MPAStatus_c}' to 'Auto approved'") MPAStatus_c = 'Auto approved' } else { println("[BBAction Trigger] MPAStatus already 'Auto approved' - no change needed") } // Set RecoverableFlagV1_c to 'Y' if (RecoverableFlagV1_c != 'Y') { println("[BBAction Trigger] Setting RecoverableFlagV1 from '${RecoverableFlagV1_c}' to 'Y'") RecoverableFlagV1_c = 'Y' } else { println("[BBAction Trigger] RecoverableFlagV1 already 'Y' - no change needed") } println("[BBAction Trigger] Section 2 completed successfully") } else { println("[BBAction Trigger] IncentiveType not COMMISSION or BONUS - skipping") } } // ============================================================================ // SECTION 3: REC Payout Adjustment (Analyst needs to fill in Expected Payout) // Action Code: MAV_DIR_BB_ACTION_1008 // ============================================================================ if (BBActionManual_c == 'MAV_DIR_BB_ACTION_1008') { println("[BBAction Trigger] Action: REC Payout Adjustment") println("[BBAction Trigger] IncentiveType: ${IncentiveType_c}") println("[BBAction Trigger] CED: ${CED_c}") // Verify the Incentive Type condition (COMMISSION or BONUS, not SPIFF) if (IncentiveType_c == 'COMMISSION' || IncentiveType_c == 'BONUS') { println("[BBAction Trigger] Clearing BBReasonCode and BBMPAComment") BBMPAComment_c = null BBReasonCode_c = null MPAReasonCode_c = null // Calculate reverse of CED: (-1) * CED_c def reverseCED = -1 * (CED_c ?: 0) println("[BBAction Trigger] Calculated reverseCED: ${reverseCED}") // Set MPAGenerated only if value is different (avoid validation threshold) if (MPAGenerated_c != reverseCED) { println("[BBAction Trigger] Setting MPAGenerated from ${MPAGenerated_c} to ${reverseCED}") MPAGenerated_c = reverseCED } else { println("[BBAction Trigger] MPAGenerated already equals ${reverseCED} - no change needed") } // Set ExpectedPaymentAmount to null (analyst to input) println("[BBAction Trigger] Setting ExpectedPaymentAmount to null (analyst input required)") ExpectedPaymentAmount_c = null // Set RecoverableFlagV1_c to 'Y' if (RecoverableFlagV1_c != 'Y') { println("[BBAction Trigger] Setting RecoverableFlagV1 from '${RecoverableFlagV1_c}' to 'Y'") RecoverableFlagV1_c = 'Y' } else { println("[BBAction Trigger] RecoverableFlagV1 already 'Y' - no change needed") } println("[BBAction Trigger] Section 3 completed successfully") } else { println("[BBAction Trigger] IncentiveType not COMMISSION or BONUS - skipping") } } // ============================================================================ // SECTION 4: NNREC Payout Adjustment (Analyst needs to fill in Expected Payout) // Action Code: MAV_DIR_BB_ACTION_1009 // ============================================================================ if (BBActionManual_c == 'MAV_DIR_BB_ACTION_1009') { println("[BBAction Trigger] Action: NNREC Payout Adjustment") println("[BBAction Trigger] IncentiveType: ${IncentiveType_c}") println("[BBAction Trigger] CED: ${CED_c}") // Verify the Incentive Type condition (COMMISSION or BONUS, not SPIFF) if (IncentiveType_c == 'COMMISSION' || IncentiveType_c == 'BONUS') { println("[BBAction Trigger] Clearing BBReasonCode and BBMPAComment") BBMPAComment_c = null BBReasonCode_c = null MPAReasonCode_c = null // Calculate reverse of CED: (-1) * CED_c def reverseCED = -1 * (CED_c ?: 0) println("[BBAction Trigger] Calculated reverseCED: ${reverseCED}") // Set MPAGenerated only if value is different (avoid validation threshold) if (MPAGenerated_c != reverseCED) { println("[BBAction Trigger] Setting MPAGenerated from ${MPAGenerated_c} to ${reverseCED}") MPAGenerated_c = reverseCED } else { println("[BBAction Trigger] MPAGenerated already equals ${reverseCED} - no change needed") } // Set ExpectedPaymentAmount to null (analyst to input) println("[BBAction Trigger] Setting ExpectedPaymentAmount to null (analyst input required)") ExpectedPaymentAmount_c = null // Set MPAStatus_c to 'Manual approval' if (MPAStatus_c != 'Manual approval') { println("[BBAction Trigger] Setting MPAStatus from '${MPAStatus_c}' to 'Manual approval'") MPAStatus_c = 'Manual approval' } else { println("[BBAction Trigger] MPAStatus already 'Manual approval' - no change needed") } // Set RecoverableFlagV1_c to 'N' if (RecoverableFlagV1_c != 'N') { println("[BBAction Trigger] Setting RecoverableFlagV1 from '${RecoverableFlagV1_c}' to 'N'") RecoverableFlagV1_c = 'N' } else { println("[BBAction Trigger] RecoverableFlagV1 already 'N' - no change needed") } println("[BBAction Trigger] Section 4 completed successfully") } else { println("[BBAction Trigger] IncentiveType not COMMISSION or BONUS - skipping") } } // ============================================================================ // SECTION 5: NNREC Payout Adjustment - COMMISSION Only // Action Code: MAV_DIR_BB_ACTION_1010 // ============================================================================ if (BBActionManual_c == 'MAV_DIR_BB_ACTION_1010') { println("[BBAction Trigger] Action: NNREC Payout Adjustment (COMMISSION/BONUS Mixed Logic)") println("[BBAction Trigger] IncentiveType: ${IncentiveType_c}") println("[BBAction Trigger] CED: ${CED_c}") // Verify the Incentive Type condition (COMMISSION only) if (IncentiveType_c == 'COMMISSION') { println("[BBAction Trigger] Clearing BBReasonCode and BBMPAComment") BBMPAComment_c = null BBReasonCode_c = null MPAReasonCode_c = null // Calculate reverse of CED: (-1) * CED_c def reverseCED = -1 * (CED_c ?: 0) println("[BBAction Trigger] Calculated reverseCED: ${reverseCED}") // Set MPAGenerated only if value is different (avoid validation threshold) if (MPAGenerated_c != reverseCED) { println("[BBAction Trigger] Setting MPAGenerated from ${MPAGenerated_c} to ${reverseCED}") MPAGenerated_c = reverseCED } else { println("[BBAction Trigger] MPAGenerated already equals ${reverseCED} - no change needed") } // Set ExpectedPaymentAmount to null (analyst to input) println("[BBAction Trigger] Setting ExpectedPaymentAmount to null (analyst input required)") ExpectedPaymentAmount_c = null // Set MPAStatus_c to 'Manual approval' if (MPAStatus_c != 'Manual approval') { println("[BBAction Trigger] Setting MPAStatus from '${MPAStatus_c}' to 'Manual approval'") MPAStatus_c = 'Manual approval' } else { println("[BBAction Trigger] MPAStatus already 'Manual approval' - no change needed") } // Set RecoverableFlagV1_c to 'N' if (RecoverableFlagV1_c != 'N') { println("[BBAction Trigger] Setting RecoverableFlagV1 from '${RecoverableFlagV1_c}' to 'N'") RecoverableFlagV1_c = 'N' } else { println("[BBAction Trigger] RecoverableFlagV1 already 'N' - no change needed") } println("[BBAction Trigger] Section 5 completed successfully") } else { println("[BBAction Trigger] IncentiveType not COMMISSION - skipping") } } // ============================================================================ // SECTION 6 & 7: NNREC Payout Adjustment - BONUS with HR Status Conditions // Action Code: MAV_DIR_BB_ACTION_1010 (BONUS scenarios) // ============================================================================ if (BBActionManual_c == 'MAV_DIR_BB_ACTION_1010') { println("[BBAction Trigger] Action: NNREC Payout Adjustment (BONUS)") println("[BBAction Trigger] IncentiveType: ${IncentiveType_c}") println("[BBAction Trigger] HRStatus: ${HRStatus_c}") println("[BBAction Trigger] CED: ${CED_c}") // Verify the Incentive Type condition (BONUS only) if (IncentiveType_c == 'BONUS') { // SECTION 6: HR Status = 'T' and CED > 0 if (HRStatus_c == 'T' && (CED_c ?: 0) > 0) { println("[BBAction Trigger] Section 6: HRStatus='T' and CED>0") println("[BBAction Trigger] Clearing BBReasonCode and BBMPAComment") BBMPAComment_c = null BBReasonCode_c = null MPAReasonCode_c = null // Calculate reverse of CED: (-1) * CED_c def reverseCED = -1 * (CED_c ?: 0) println("[BBAction Trigger] Calculated reverseCED: ${reverseCED}") // Set MPAGenerated only if value is different (avoid validation threshold) if (MPAGenerated_c != reverseCED) { println("[BBAction Trigger] Setting MPAGenerated from ${MPAGenerated_c} to ${reverseCED}") MPAGenerated_c = reverseCED } else { println("[BBAction Trigger] MPAGenerated already equals ${reverseCED} - no change needed") } // Set ExpectedPaymentAmount to 0 println("[BBAction Trigger] Setting ExpectedPaymentAmount to 0") ExpectedPaymentAmount_c = 0 // Set MPAStatus_c to 'Auto approved' if (MPAStatus_c != 'Auto approved') { println("[BBAction Trigger] Setting MPAStatus from '${MPAStatus_c}' to 'Auto approved'") MPAStatus_c = 'Auto approved' } else { println("[BBAction Trigger] MPAStatus already 'Auto approved' - no change needed") } // Set RecoverableFlagV1_c to 'N' if (RecoverableFlagV1_c != 'N') { println("[BBAction Trigger] Setting RecoverableFlagV1 from '${RecoverableFlagV1_c}' to 'N'") RecoverableFlagV1_c = 'N' } else { println("[BBAction Trigger] RecoverableFlagV1 already 'N' - no change needed") } println("[BBAction Trigger] Section 6 completed successfully") } // SECTION 7: HR Status != 'T' and CED < 0 if (HRStatus_c != 'T' && (CED_c ?: 0) < 0) { println("[BBAction Trigger] Section 7: HRStatus!='T' and CED<0") println("[BBAction Trigger] Clearing BBReasonCode and BBMPAComment") BBMPAComment_c = null BBReasonCode_c = null MPAReasonCode_c = null // Calculate reverse of CED: (-1) * CED_c def reverseCED = -1 * (CED_c ?: 0) println("[BBAction Trigger] Calculated reverseCED: ${reverseCED}") // Set MPAGenerated only if value is different (avoid validation threshold) if (MPAGenerated_c != reverseCED) { println("[BBAction Trigger] Setting MPAGenerated from ${MPAGenerated_c} to ${reverseCED}") MPAGenerated_c = reverseCED } else { println("[BBAction Trigger] MPAGenerated already equals ${reverseCED} - no change needed") } // Set ExpectedPaymentAmount to null (analyst to input) println("[BBAction Trigger] Setting ExpectedPaymentAmount to null (analyst input required)") ExpectedPaymentAmount_c = null // Set MPAStatus_c to 'Manual approval' if (MPAStatus_c != 'Manual approval') { println("[BBAction Trigger] Setting MPAStatus from '${MPAStatus_c}' to 'Manual approval'") MPAStatus_c = 'Manual approval' } else { println("[BBAction Trigger] MPAStatus already 'Manual approval' - no change needed") } // Set RecoverableFlagV1_c to 'N' if (RecoverableFlagV1_c != 'N') { println("[BBAction Trigger] Setting RecoverableFlagV1 from '${RecoverableFlagV1_c}' to 'N'") RecoverableFlagV1_c = 'N' } else { println("[BBAction Trigger] RecoverableFlagV1 already 'N' - no change needed") } println("[BBAction Trigger] Section 7 completed successfully") } } else { println("[BBAction Trigger] IncentiveType not BONUS - skipping sections 6 & 7") } } // ============================================================================ // SECTION 8 & 9: REC Payout Adjustment with Complex Conditions // Action Code: MAV_DIR_BB_ACTION_1011 // ============================================================================ if (BBActionManual_c == 'MAV_DIR_BB_ACTION_1011') { println("[BBAction Trigger] Action: REC Payout Adjustment (Complex)") println("[BBAction Trigger] IncentiveType: ${IncentiveType_c}") println("[BBAction Trigger] HRStatus: ${HRStatus_c}") println("[BBAction Trigger] EmploymentCountry: ${EmploymentCountry_c}") println("[BBAction Trigger] SalesRP: ${SalesRP_c}") println("[BBAction Trigger] CED: ${CED_c}") // Verify the Incentive Type condition (COMMISSION or BONUS) if (IncentiveType_c == 'COMMISSION' || IncentiveType_c == 'BONUS') { // SECTION 8: HRStatus='T', Country!='RO', SalesRP='Y', CED<0 if (HRStatus_c == 'T' && EmploymentCountry_c != 'RO' && SalesRP_c == 'Y' && (CED_c ?: 0) < 0) { println("[BBAction Trigger] Section 8: HRStatus='T', Country!='RO', SalesRP='Y', CED<0") println("[BBAction Trigger] Clearing BBReasonCode and BBMPAComment") BBMPAComment_c = null BBReasonCode_c = null MPAReasonCode_c = null // Calculate reverse of CED: (-1) * CED_c def reverseCED = -1 * (CED_c ?: 0) println("[BBAction Trigger] Calculated reverseCED: ${reverseCED}") // Set MPAGenerated only if value is different (avoid validation threshold) if (MPAGenerated_c != reverseCED) { println("[BBAction Trigger] Setting MPAGenerated from ${MPAGenerated_c} to ${reverseCED}") MPAGenerated_c = reverseCED } else { println("[BBAction Trigger] MPAGenerated already equals ${reverseCED} - no change needed") } // Set ExpectedPaymentAmount to CED_c println("[BBAction Trigger] Setting ExpectedPaymentAmount to CED: ${CED_c}") ExpectedPaymentAmount_c = CED_c // Set MPAStatus_c to 'Manual approval' if (MPAStatus_c != 'Manual approval') { println("[BBAction Trigger] Setting MPAStatus from '${MPAStatus_c}' to 'Manual approval'") MPAStatus_c = 'Manual approval' } else { println("[BBAction Trigger] MPAStatus already 'Manual approval' - no change needed") } // Set RecoverableFlagV1_c to 'Y' if (RecoverableFlagV1_c != 'Y') { println("[BBAction Trigger] Setting RecoverableFlagV1 from '${RecoverableFlagV1_c}' to 'Y'") RecoverableFlagV1_c = 'Y' } else { println("[BBAction Trigger] RecoverableFlagV1 already 'Y' - no change needed") } println("[BBAction Trigger] Section 8 completed successfully") } // SECTION 9: HRStatus='A', Country!='RO', SalesRP='N', CED<0 if (HRStatus_c == 'A' && EmploymentCountry_c != 'RO' && SalesRP_c == 'N' && (CED_c ?: 0) < 0) { println("[BBAction Trigger] Section 9: HRStatus='A', Country!='RO', SalesRP='N', CED<0") println("[BBAction Trigger] Clearing BBReasonCode and BBMPAComment") BBMPAComment_c = null BBReasonCode_c = null MPAReasonCode_c = null // Calculate reverse of CED: (-1) * CED_c def reverseCED = -1 * (CED_c ?: 0) println("[BBAction Trigger] Calculated reverseCED: ${reverseCED}") // Set MPAGenerated only if value is different (avoid validation threshold) if (MPAGenerated_c != reverseCED) { println("[BBAction Trigger] Setting MPAGenerated from ${MPAGenerated_c} to ${reverseCED}") MPAGenerated_c = reverseCED } else { println("[BBAction Trigger] MPAGenerated already equals ${reverseCED} - no change needed") } // Set ExpectedPaymentAmount to CED_c println("[BBAction Trigger] Setting ExpectedPaymentAmount to CED: ${CED_c}") ExpectedPaymentAmount_c = CED_c // Set MPAStatus_c to 'Manual approval' if (MPAStatus_c != 'Manual approval') { println("[BBAction Trigger] Setting MPAStatus from '${MPAStatus_c}' to 'Manual approval'") MPAStatus_c = 'Manual approval' } else { println("[BBAction Trigger] MPAStatus already 'Manual approval' - no change needed") } // Set RecoverableFlagV1_c to 'Y' if (RecoverableFlagV1_c != 'Y') { println("[BBAction Trigger] Setting RecoverableFlagV1 from '${RecoverableFlagV1_c}' to 'Y'") RecoverableFlagV1_c = 'Y' } else { println("[BBAction Trigger] RecoverableFlagV1 already 'Y' - no change needed") } println("[BBAction Trigger] Section 9 completed successfully") } } else { println("[BBAction Trigger] IncentiveType not COMMISSION or BONUS - skipping sections 8 & 9") } } // ============================================================================ // SECTION 10 & 11: BONUS with Country-Specific Rules & Lookup Validation // Action Code: MAV_DIR_BB_ACTION_1012 // ============================================================================ if (BBActionManual_c == 'MAV_DIR_BB_ACTION_1012') { println("[BBAction Trigger] Action: BONUS Country-Specific Rules") println("[BBAction Trigger] IncentiveType: ${IncentiveType_c}") println("[BBAction Trigger] HRStatus: ${HRStatus_c}") println("[BBAction Trigger] EmploymentCountry: ${EmploymentCountry_c}") println("[BBAction Trigger] SalesRP: ${SalesRP_c}") println("[BBAction Trigger] BeginningBalance: ${BeginningBalance_c}") // --- START: LOOKUP SCD VALIDATION --- String lookupDesc = null // Initialize (Assumed: '1' for enabled, '0' for disabled) def lookupType = 'MTQ_ICM_BB_COUNTRY_LKP' def lookupCode = EmploymentCountry_c // Only proceed if we have a country code if (lookupCode != null) { println("[BBAction Trigger] Lookup Attempt: VO='CommonLookup', Type=${lookupType}, Code=${lookupCode}") def voLookUp = newView("CommonLookup") def str1SearchExpression = "LookupType = '${lookupType}' AND LookupCode = '${lookupCode}'" voLookUp.appendViewCriteria(str1SearchExpression) voLookUp.executeQuery() if (voLookUp.getEstimatedRowCount() > 0) { def rowLookup = voLookUp.first() // Retrieve Description (assuming this is the SCD status: '0' or '1') lookupDesc = nvl(rowLookup?.Description, "") // Per user request, check Description against string '0' if (lookupDesc == '0') { println("[BBAction Trigger] VALIDATION FAILED: SCD not enabled.") throw new oracle.jbo.ValidationException("SCD not enabled for employment country " + EmploymentCountry_c); } println("[BBAction Trigger] Lookup Successful. SCD Status (Description): ${lookupDesc}") } else { println("[BBAction Trigger] Lookup Failed: No matching row found. Assuming SCD is enabled by default.") // If no lookup found, the validation will not be triggered. } // Clean up the VO (good practice) voLookUp.reset() } else { println("[BBAction Trigger] EmploymentCountry is null. Skipping SCD check.") } // --- END: LOOKUP SCD VALIDATION --- // Verify the Incentive Type condition (BONUS only) if (IncentiveType_c == 'BONUS') { // SECTION 10: HRStatus='A', SalesRP='Y', BB<0 (Country exclusion logic removed as per user's source code modification) if (HRStatus_c == 'A' && SalesRP_c == 'Y' && (BeginningBalance_c ?: 0) < 0) { println("[BBAction Trigger] Section 10: HRStatus='A', SalesRP='Y', BB<0") println("[BBAction Trigger] Clearing BBReasonCode and BBMPAComment") BBMPAComment_c = null BBReasonCode_c = null MPAReasonCode_c = null //changes as par latest discussion with Anne - 4-December ExpectedPaymentAmount_c = CED_c MPAGenerated_c = (-1)*ExpectedPaymentAmount_c // Set MPAStatus_c to 'Manual approval' if (MPAStatus_c != 'Manual approval') { println("[BBAction Trigger] Setting MPAStatus from '${MPAStatus_c}' to 'Manual approval'") MPAStatus_c = 'Manual approval' } else { println("[BBAction Trigger] MPAStatus already 'Manual approval' - no change needed") } // Set RecoverableFlagV1_c to 'Y' if (RecoverableFlagV1_c != 'Y') { println("[BBAction Trigger] Setting RecoverableFlagV1 from '${RecoverableFlagV1_c}' to 'Y'") RecoverableFlagV1_c = 'Y' } else { println("[BBAction Trigger] RecoverableFlagV1 already 'Y' - no change needed") } println("[BBAction Trigger] Section 10 completed successfully") } /* SECTION 11 LOGIC WAS COMMENTED OUT IN SOURCE, REMAINS COMMENTED HERE def specificCountries = ['KR', 'KZ'] if (HRStatus_c == 'A' && (EmploymentCountry_c in specificCountries) && SalesRP_c == 'Y' && BeginningBalance_c < 0) { // ... logic ... } */ } else { println("[BBAction Trigger] IncentiveType not BONUS - skipping sections 10 & 11") } } println("[BBAction Trigger] ========== Trigger execution completed ==========")

Comments

Popular posts from this blog

dev7 from eror

EPA

Unified Currency Report- Krithika