138: l_legal_entity_id ra_customer_trx.legal_entity_id%TYPE;
139:
140: BEGIN
141: IF PG_DEBUG in ('Y', 'C') THEN
142: arp_standard.debug('arp_chargeback_cover.create_chargeback()+');
143: END IF;
144:
145: -- Standard Start of API savepoint
146: SAVEPOINT Create_Chargeback;
141: IF PG_DEBUG in ('Y', 'C') THEN
142: arp_standard.debug('arp_chargeback_cover.create_chargeback()+');
143: END IF;
144:
145: -- Standard Start of API savepoint
146: SAVEPOINT Create_Chargeback;
147: -- Initialize message list if p_init_msg_list is set to TRUE.
148: IF FND_API.to_Boolean( p_init_msg_list )
149: THEN
153: x_return_status := FND_API.G_RET_STS_SUCCESS;
154:
155: /* Bug 3022077 - initialize global variables in case SOB or org changed */
156: arp_global.init_global;
157: arp_standard.init_standard;
158:
159: /*---------------------------------------------------------------------+
160: | A) Validate and Default parameters |
161: +---------------------------------------------------------------------*/
159: /*---------------------------------------------------------------------+
160: | A) Validate and Default parameters |
161: +---------------------------------------------------------------------*/
162: IF PG_DEBUG in ('Y', 'C') THEN
163: arp_standard.debug('create_chargeback: ' || 'PARAMETER VALUES: ');
164: arp_standard.debug('create_chargeback: ' || 'amount = '||p_chargeback_rec.amount);
165: arp_standard.debug('create_chargeback: ' || 'cust_trx_type_id = '||p_chargeback_rec.cust_trx_type_id);
166: arp_standard.debug('create_chargeback: ' || 'code_combination_id = '||p_chargeback_rec.code_combination_id);
167: arp_standard.debug('create_chargeback: ' || 'reason_code = '||p_chargeback_rec.reason_code);
160: | A) Validate and Default parameters |
161: +---------------------------------------------------------------------*/
162: IF PG_DEBUG in ('Y', 'C') THEN
163: arp_standard.debug('create_chargeback: ' || 'PARAMETER VALUES: ');
164: arp_standard.debug('create_chargeback: ' || 'amount = '||p_chargeback_rec.amount);
165: arp_standard.debug('create_chargeback: ' || 'cust_trx_type_id = '||p_chargeback_rec.cust_trx_type_id);
166: arp_standard.debug('create_chargeback: ' || 'code_combination_id = '||p_chargeback_rec.code_combination_id);
167: arp_standard.debug('create_chargeback: ' || 'reason_code = '||p_chargeback_rec.reason_code);
168: arp_standard.debug('create_chargeback: ' || 'gl_date = '||p_chargeback_rec.gl_date);
161: +---------------------------------------------------------------------*/
162: IF PG_DEBUG in ('Y', 'C') THEN
163: arp_standard.debug('create_chargeback: ' || 'PARAMETER VALUES: ');
164: arp_standard.debug('create_chargeback: ' || 'amount = '||p_chargeback_rec.amount);
165: arp_standard.debug('create_chargeback: ' || 'cust_trx_type_id = '||p_chargeback_rec.cust_trx_type_id);
166: arp_standard.debug('create_chargeback: ' || 'code_combination_id = '||p_chargeback_rec.code_combination_id);
167: arp_standard.debug('create_chargeback: ' || 'reason_code = '||p_chargeback_rec.reason_code);
168: arp_standard.debug('create_chargeback: ' || 'gl_date = '||p_chargeback_rec.gl_date);
169: arp_standard.debug('create_chargeback: ' || 'due_date = '||p_chargeback_rec.due_date);
162: IF PG_DEBUG in ('Y', 'C') THEN
163: arp_standard.debug('create_chargeback: ' || 'PARAMETER VALUES: ');
164: arp_standard.debug('create_chargeback: ' || 'amount = '||p_chargeback_rec.amount);
165: arp_standard.debug('create_chargeback: ' || 'cust_trx_type_id = '||p_chargeback_rec.cust_trx_type_id);
166: arp_standard.debug('create_chargeback: ' || 'code_combination_id = '||p_chargeback_rec.code_combination_id);
167: arp_standard.debug('create_chargeback: ' || 'reason_code = '||p_chargeback_rec.reason_code);
168: arp_standard.debug('create_chargeback: ' || 'gl_date = '||p_chargeback_rec.gl_date);
169: arp_standard.debug('create_chargeback: ' || 'due_date = '||p_chargeback_rec.due_date);
170: arp_standard.debug('create_chargeback: ' || 'cash_receipt_id = '||p_chargeback_rec.cash_receipt_id);
163: arp_standard.debug('create_chargeback: ' || 'PARAMETER VALUES: ');
164: arp_standard.debug('create_chargeback: ' || 'amount = '||p_chargeback_rec.amount);
165: arp_standard.debug('create_chargeback: ' || 'cust_trx_type_id = '||p_chargeback_rec.cust_trx_type_id);
166: arp_standard.debug('create_chargeback: ' || 'code_combination_id = '||p_chargeback_rec.code_combination_id);
167: arp_standard.debug('create_chargeback: ' || 'reason_code = '||p_chargeback_rec.reason_code);
168: arp_standard.debug('create_chargeback: ' || 'gl_date = '||p_chargeback_rec.gl_date);
169: arp_standard.debug('create_chargeback: ' || 'due_date = '||p_chargeback_rec.due_date);
170: arp_standard.debug('create_chargeback: ' || 'cash_receipt_id = '||p_chargeback_rec.cash_receipt_id);
171: arp_standard.debug('create_chargeback: ' || 'secondary_application_ref_id = '||p_chargeback_rec.secondary_application_ref_id);
164: arp_standard.debug('create_chargeback: ' || 'amount = '||p_chargeback_rec.amount);
165: arp_standard.debug('create_chargeback: ' || 'cust_trx_type_id = '||p_chargeback_rec.cust_trx_type_id);
166: arp_standard.debug('create_chargeback: ' || 'code_combination_id = '||p_chargeback_rec.code_combination_id);
167: arp_standard.debug('create_chargeback: ' || 'reason_code = '||p_chargeback_rec.reason_code);
168: arp_standard.debug('create_chargeback: ' || 'gl_date = '||p_chargeback_rec.gl_date);
169: arp_standard.debug('create_chargeback: ' || 'due_date = '||p_chargeback_rec.due_date);
170: arp_standard.debug('create_chargeback: ' || 'cash_receipt_id = '||p_chargeback_rec.cash_receipt_id);
171: arp_standard.debug('create_chargeback: ' || 'secondary_application_ref_id = '||p_chargeback_rec.secondary_application_ref_id);
172: arp_standard.debug('create_chargeback: ' || 'new_second_application_ref_id = '||p_chargeback_rec.new_second_application_ref_id);
165: arp_standard.debug('create_chargeback: ' || 'cust_trx_type_id = '||p_chargeback_rec.cust_trx_type_id);
166: arp_standard.debug('create_chargeback: ' || 'code_combination_id = '||p_chargeback_rec.code_combination_id);
167: arp_standard.debug('create_chargeback: ' || 'reason_code = '||p_chargeback_rec.reason_code);
168: arp_standard.debug('create_chargeback: ' || 'gl_date = '||p_chargeback_rec.gl_date);
169: arp_standard.debug('create_chargeback: ' || 'due_date = '||p_chargeback_rec.due_date);
170: arp_standard.debug('create_chargeback: ' || 'cash_receipt_id = '||p_chargeback_rec.cash_receipt_id);
171: arp_standard.debug('create_chargeback: ' || 'secondary_application_ref_id = '||p_chargeback_rec.secondary_application_ref_id);
172: arp_standard.debug('create_chargeback: ' || 'new_second_application_ref_id = '||p_chargeback_rec.new_second_application_ref_id);
173: arp_standard.debug('create_chargeback: ' || 'application_ref_type = '||p_chargeback_rec.application_ref_type);
166: arp_standard.debug('create_chargeback: ' || 'code_combination_id = '||p_chargeback_rec.code_combination_id);
167: arp_standard.debug('create_chargeback: ' || 'reason_code = '||p_chargeback_rec.reason_code);
168: arp_standard.debug('create_chargeback: ' || 'gl_date = '||p_chargeback_rec.gl_date);
169: arp_standard.debug('create_chargeback: ' || 'due_date = '||p_chargeback_rec.due_date);
170: arp_standard.debug('create_chargeback: ' || 'cash_receipt_id = '||p_chargeback_rec.cash_receipt_id);
171: arp_standard.debug('create_chargeback: ' || 'secondary_application_ref_id = '||p_chargeback_rec.secondary_application_ref_id);
172: arp_standard.debug('create_chargeback: ' || 'new_second_application_ref_id = '||p_chargeback_rec.new_second_application_ref_id);
173: arp_standard.debug('create_chargeback: ' || 'application_ref_type = '||p_chargeback_rec.application_ref_type);
174: arp_standard.debug('create_chargeback: ' || 'Bill to site use id Passed = '||p_chargeback_rec.bill_to_site_use_id);
167: arp_standard.debug('create_chargeback: ' || 'reason_code = '||p_chargeback_rec.reason_code);
168: arp_standard.debug('create_chargeback: ' || 'gl_date = '||p_chargeback_rec.gl_date);
169: arp_standard.debug('create_chargeback: ' || 'due_date = '||p_chargeback_rec.due_date);
170: arp_standard.debug('create_chargeback: ' || 'cash_receipt_id = '||p_chargeback_rec.cash_receipt_id);
171: arp_standard.debug('create_chargeback: ' || 'secondary_application_ref_id = '||p_chargeback_rec.secondary_application_ref_id);
172: arp_standard.debug('create_chargeback: ' || 'new_second_application_ref_id = '||p_chargeback_rec.new_second_application_ref_id);
173: arp_standard.debug('create_chargeback: ' || 'application_ref_type = '||p_chargeback_rec.application_ref_type);
174: arp_standard.debug('create_chargeback: ' || 'Bill to site use id Passed = '||p_chargeback_rec.bill_to_site_use_id);
175: END IF;
168: arp_standard.debug('create_chargeback: ' || 'gl_date = '||p_chargeback_rec.gl_date);
169: arp_standard.debug('create_chargeback: ' || 'due_date = '||p_chargeback_rec.due_date);
170: arp_standard.debug('create_chargeback: ' || 'cash_receipt_id = '||p_chargeback_rec.cash_receipt_id);
171: arp_standard.debug('create_chargeback: ' || 'secondary_application_ref_id = '||p_chargeback_rec.secondary_application_ref_id);
172: arp_standard.debug('create_chargeback: ' || 'new_second_application_ref_id = '||p_chargeback_rec.new_second_application_ref_id);
173: arp_standard.debug('create_chargeback: ' || 'application_ref_type = '||p_chargeback_rec.application_ref_type);
174: arp_standard.debug('create_chargeback: ' || 'Bill to site use id Passed = '||p_chargeback_rec.bill_to_site_use_id);
175: END IF;
176:
169: arp_standard.debug('create_chargeback: ' || 'due_date = '||p_chargeback_rec.due_date);
170: arp_standard.debug('create_chargeback: ' || 'cash_receipt_id = '||p_chargeback_rec.cash_receipt_id);
171: arp_standard.debug('create_chargeback: ' || 'secondary_application_ref_id = '||p_chargeback_rec.secondary_application_ref_id);
172: arp_standard.debug('create_chargeback: ' || 'new_second_application_ref_id = '||p_chargeback_rec.new_second_application_ref_id);
173: arp_standard.debug('create_chargeback: ' || 'application_ref_type = '||p_chargeback_rec.application_ref_type);
174: arp_standard.debug('create_chargeback: ' || 'Bill to site use id Passed = '||p_chargeback_rec.bill_to_site_use_id);
175: END IF;
176:
177: /*---------------------------------------------------------------------+
170: arp_standard.debug('create_chargeback: ' || 'cash_receipt_id = '||p_chargeback_rec.cash_receipt_id);
171: arp_standard.debug('create_chargeback: ' || 'secondary_application_ref_id = '||p_chargeback_rec.secondary_application_ref_id);
172: arp_standard.debug('create_chargeback: ' || 'new_second_application_ref_id = '||p_chargeback_rec.new_second_application_ref_id);
173: arp_standard.debug('create_chargeback: ' || 'application_ref_type = '||p_chargeback_rec.application_ref_type);
174: arp_standard.debug('create_chargeback: ' || 'Bill to site use id Passed = '||p_chargeback_rec.bill_to_site_use_id);
175: END IF;
176:
177: /*---------------------------------------------------------------------+
178: | 1) Check receipt valid / get receipt details |
177: /*---------------------------------------------------------------------+
178: | 1) Check receipt valid / get receipt details |
179: +---------------------------------------------------------------------*/
180: IF PG_DEBUG in ('Y', 'C') THEN
181: arp_standard.debug('create_chargeback: ' || 'Checking cash receipt ...');
182: END IF;
183: IF (p_chargeback_rec.cash_receipt_id IS NULL)
184: THEN
185: FND_MESSAGE.SET_NAME('AR','AR_RAPI_CASH_RCPT_ID_NULL');
229: /*---------------------------------------------------------------------+
230: | 2) Get required system parameters |
231: +---------------------------------------------------------------------*/
232: IF PG_DEBUG in ('Y', 'C') THEN
233: arp_standard.debug('create_chargeback: ' || 'Getting system parameters... ');
234: END IF;
235: SELECT set_of_books_id
236: , default_cb_due_date
237: , nvl(site_required_flag,'N')
244: /*---------------------------------------------------------------------+
245: | 4) Check secondary app ref id valid / get application details |
246: +---------------------------------------------------------------------*/
247: IF PG_DEBUG in ('Y', 'C') THEN
248: arp_standard.debug('create_chargeback: ' || 'Checking application ...');
249: END IF;
250: IF (p_chargeback_rec.secondary_application_ref_id IS NULL)
251: THEN
252: FND_MESSAGE.SET_NAME('AR','AR_RW_NULL_SECOND_APP_REF_ID');
479: /*---------------------------------------------------------------------+
480: | 6) Check trx type is valid |
481: +---------------------------------------------------------------------*/
482: IF PG_DEBUG in ('Y', 'C') THEN
483: arp_standard.debug('create_chargeback: ' || 'Checking trx type... ');
484: END IF;
485: IF p_chargeback_rec.cust_trx_type_id IS NULL
486: THEN
487: FND_MESSAGE.SET_NAME('AR','AR_BR_TRX_TYPE_NULL');
520: | the applied amount differs from the amount to be written off |
521: | check the new claim is valid |
522: +---------------------------------------------------------------------*/
523: IF PG_DEBUG in ('Y', 'C') THEN
524: arp_standard.debug('create_chargeback: ' || 'Checking new claim... ');
525: END IF;
526: IF (p_chargeback_rec.application_ref_type = 'CLAIM' AND
527: l_customer_trx_id = -4 AND
528: l_amount <> p_chargeback_rec.amount)
550: /*---------------------------------------------------------------------+
551: | 8) Get GL date if null |
552: +---------------------------------------------------------------------*/
553: IF PG_DEBUG in ('Y', 'C') THEN
554: arp_standard.debug('create_chargeback: ' || 'Validating/defaulting GL date ... ');
555: END IF;
556:
557: /* Bug 2621114 - get GL date from Profile Option AR: Application GL Date
558: Default if null */
606: /*---------------------------------------------------------------------+
607: | 9) Default due date if null |
608: +---------------------------------------------------------------------*/
609: IF PG_DEBUG in ('Y', 'C') THEN
610: arp_standard.debug('create_chargeback: ' || 'Defaulting due date... ');
611: END IF;
612:
613: --
614: -- Bug 3404131 - Due date defaulted for receipt chargeback in the same way
727: /*---------------------------------------------------------------------+
728: | 1) Chargeback against a transaction so update amount in dispute |
729: +---------------------------------------------------------------------*/
730: IF PG_DEBUG in ('Y', 'C') THEN
731: arp_standard.debug('create_chargeback: ' || 'Updating amount in dispute... ');
732: END IF;
733:
734:
735: arp_deduction_cover.update_amount_in_dispute(
748: BEGIN
749:
750: l_doc_sequence_value :=
751: FND_SEQNUM.GET_NEXT_SEQUENCE(
752: appid => arp_standard.application_id,
753: cat_code => l_cb_trx_type,
754: sobid => arp_global.set_of_books_id,
755: met_code => 'A',
756: trx_date => SYSDATE,
757: dbseqnm => l_sequence_name,
758: dbseqid => l_doc_sequence_id);
759:
760: IF PG_DEBUG in ('Y', 'C') THEN
761: arp_standard.debug('ARXCBCVB.create_chargeback: ' || 'doc sequence name = ' || l_sequence_name);
762: arp_standard.debug('ARXCBCVB.create_chargeback: ' || 'doc sequence id = ' || l_doc_sequence_id);
763: arp_standard.debug('ARXCBCVB.create_chargeback: ' || 'doc sequence value = ' || l_doc_sequence_value);
764: END IF;
765: EXCEPTION
758: dbseqid => l_doc_sequence_id);
759:
760: IF PG_DEBUG in ('Y', 'C') THEN
761: arp_standard.debug('ARXCBCVB.create_chargeback: ' || 'doc sequence name = ' || l_sequence_name);
762: arp_standard.debug('ARXCBCVB.create_chargeback: ' || 'doc sequence id = ' || l_doc_sequence_id);
763: arp_standard.debug('ARXCBCVB.create_chargeback: ' || 'doc sequence value = ' || l_doc_sequence_value);
764: END IF;
765: EXCEPTION
766: WHEN OTHERS THEN
759:
760: IF PG_DEBUG in ('Y', 'C') THEN
761: arp_standard.debug('ARXCBCVB.create_chargeback: ' || 'doc sequence name = ' || l_sequence_name);
762: arp_standard.debug('ARXCBCVB.create_chargeback: ' || 'doc sequence id = ' || l_doc_sequence_id);
763: arp_standard.debug('ARXCBCVB.create_chargeback: ' || 'doc sequence value = ' || l_doc_sequence_value);
764: END IF;
765: EXCEPTION
766: WHEN OTHERS THEN
767: IF NVL(fnd_profile.value('UNIQUE:SEQ_NUMBERS'),'N') = 'A' THEN
789: NULL, NULL )
790: * SIGN(l_customer_trx_id));
791:
792: IF PG_DEBUG in ('Y', 'C') THEN
793: arp_standard.debug('create_chargeback: ' || 'Creating chargeback ... ');
794: END IF;
795:
796: -- Enh 4103090: pass the reason code sent by TM or if null, pass
797: -- INVALID_CLAIM
886: --
887: -- Unapply the application
888: --
889: IF PG_DEBUG in ('Y', 'C') THEN
890: arp_standard.debug('create_chargeback: ' || 'Unapplying OTHER ACC application ... ');
891: END IF;
892: arp_process_application.reverse(
893: p_ra_id => l_application_id
894: , p_reversal_gl_date => l_default_gl_date
904: -- We can't use the receipt API here because it can't handle negative
905: -- amounts. For claims, the amount_applied is normally negative
906: --
907: IF PG_DEBUG in ('Y', 'C') THEN
908: arp_standard.debug('create_chargeback: ' || 'Applying chargeback amount to dummy activity ... ');
909: END IF;
910:
911: l_application_ref_type := 'CHARGEBACK';
912: l_application_ref_id := l_new_customer_trx_id;
980: l_customer_trx_id = -4 AND
981: l_amount <> p_chargeback_rec.amount)
982: THEN
983: IF PG_DEBUG in ('Y', 'C') THEN
984: arp_standard.debug('create_chargeback: ' || 'Before Inserting Claim Application (+)');
985: END IF;
986:
987: /* Bug 2821139 - under no circumstances should AR update claims when
988: they are settled from TM */
1060: THEN
1061: RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1062: END IF;
1063: IF PG_DEBUG in ('Y', 'C') THEN
1064: arp_standard.debug('create_chargeback: ' || 'After Inserting Claim Application (-)');
1065: END IF;
1066: END IF;
1067:
1068: IF PG_DEBUG in ('Y', 'C') THEN
1065: END IF;
1066: END IF;
1067:
1068: IF PG_DEBUG in ('Y', 'C') THEN
1069: arp_standard.debug ('arp_chargeback_cover.create_chargeback()-');
1070: END IF;
1071:
1072: EXCEPTION
1073: WHEN FND_API.G_EXC_ERROR THEN
1078: p_count => x_msg_count,
1079: p_data => x_msg_data);
1080: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1081: IF PG_DEBUG in ('Y', 'C') THEN
1082: arp_standard.debug('create_chargeback: ' || 'Unexpected error '||sqlerrm||
1083: ' at arp_chargeback_cover.create_chargeback()+');
1084: END IF;
1085: ROLLBACK TO Create_Chargeback;
1086: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1091: WHEN OTHERS THEN
1092: IF (SQLCODE = -20001)
1093: THEN
1094: IF PG_DEBUG in ('Y', 'C') THEN
1095: arp_standard.debug('create_chargeback: ' || '20001 error '||
1096: ' at arp_chargeback_cover.create_chargeback()+');
1097: END IF;
1098: x_return_status := FND_API.G_RET_STS_ERROR ;
1099: ELSE
1097: END IF;
1098: x_return_status := FND_API.G_RET_STS_ERROR ;
1099: ELSE
1100: IF PG_DEBUG in ('Y', 'C') THEN
1101: arp_standard.debug('create_chargeback: ' || 'Unexpected error '||sqlerrm||
1102: ' at arp_chargeback_cover.create_chargeback()+');
1103: END IF;
1104: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1105: IF FND_MSG_PUB.Check_Msg_Level