Affichage des articles dont le libellé est Balance. Afficher tous les articles
Affichage des articles dont le libellé est Balance. Afficher tous les articles

dimanche 2 octobre 2016

Balance fournisseur pas à jour - Mise à jour XLA

La balance fournisseurs du fournisseur MAJRECT n'est pas à jour sur l'unité opérationnelle 376 (org_id) pour la facture N003902.
La facture est validée, comptabilisée et payée.
Je retrouve bien les pièces dans GL.
La balance âgée est OK mais pas celle des fournisseurs.



 -- Vue du fournisseur
select * from ap_suppliers where vendor_id = 7775

-- Vue de la facture - récupération de l'identifiant
select * from AP_INVOICES_ALL
where invoice_num = 'N003902'

 -- lien facture-règlement
Select * from ap_invoice_payments_all
where invoice_id = 896650

-- lignes de facture
select * from ap_invoice_lines_all ail
where ail.invoice_id = 896650


-- lignes de ventilation de la facture
select * from AP_INVOICE_DISTRIBUTIONS_ALL aid
where aid.invoice_id = 896650

-- Evénements de comptabilisation de la facture dans XLA
SELECT ae.*
FROM XLA_EVENTS ae, AP_INVOICE_DISTRIBUTIONS_ALL aid
WHERE aid.accounting_event_id = ae.event_id
aND ae.application_id = 200
AND aid.invoice_id = 896650


-- Evénements de comptabilisation dans XLA
select * from xla_events where event_id in (1387951,1061875)


--Bug 6392789
select distinct aid.invoice_id,aid.ACCOUNTING_date aid_accounting_date,
XE.EVENT_DATE XE_ACCOUNTING_DATE,XE.EVENT_ID xe_accounting_event_id
from AP_INVOICE_DISTRIBUTIONS_ALL aid,XLA_EVENTS XE
where aid.ACCOUNTING_EVENT_ID = XE.EVENT_ID
and trunc(aid.ACCOUNTING_date) <> trunc(XE.EVENT_DATE)
and aid.invoice_id = 896650


SELECT *
FROM xla.XLA_transaction_entities
where entity_id = 1018835
--ou
entity_code = 'AP INVOICES'
AND source_id_int_1 = 896650

-- Données de la balance
select * from xla_trial_balances
where  source_entity_id = 1018835
and ledger_id = 2121

-- Journal XLA
select * from xla_ae_headers where ae_header_id in (1767014,2082540)

-- Lignes du journal XLA
SELECT * from xla_ae_lines where
application_id = 200
and ae_header_id in (1767014,2082540)

-- Lignes GL
select * from GL_JE_LINES
where ledger_id = 2121
and subledger_doc_sequence_value = 1175202
and subledger_doc_sequence_id =1964
and gl_sl_link_id = 8127845
and gl_sl_link_table = 'XLAJEL'

- Pièce GL
SELECT * from gl_je_headers where je_header_id = 3274834

-- Lien GL-XLA
SELECT * from xla_ae_lines
where ledger_id = 2121
--and doc_sequence_value = 1175202
--and doc_sequence_id =1964
and gl_sl_link_id = 8127845
and gl_sl_link_table = 'XLAJEL'

Après ce petit tour de visualisation des données, nous allons mettre à jour les tables XLA.

---------------------------------------------------
--- Mises à jour ------------- en 4 étapes --------

-- 1 --
select * from XLA_AE_HEADERS
WHERE event_id in (1061875,1387951)
AND ae_header_id = 1767014


UPDATE xla_ae_headers
SET accounting_date = to_date('01/05/2015','DD/MM/YYYY')
    ,period_name = 'MAY-15'
WHERE event_id = 1061875
AND ae_header_id = 1767014

-- 2 --
SELECT * from XLA_AE_LINES
WHERE ae_header_id = 1767014

UPDATE xla_ae_lines
SET accounting_date = to_date('01/05/2015','DD/MM/YYYY')
WHERE ae_header_id = 1767014


-- 3 --
SELECT * from xla_events
WHERE event_id = 1061875

UPDATE xla_events
SET event_date = to_date('01/05/2015','DD/MM/YYYY')
WHERE event_id = 1061875

-- 4 --
SELECT * from xla_trial_balances
WHERE source_entity_id = 1018835
and definition_code = 'OU_376'
AND ae_header_id = 1767014

-- Vue du règlement...
SELECT * from xla_trial_balances
WHERE applied_to_entity_id = 1018835

-- Mise à jour
UPDATE xla_trial_balances
set GL_DATE = to_date('01/05/2015','DD/MM/YYYY')
WHERE source_entity_id = 1018835
and definition_code = 'OU_376'
AND ae_header_id = 1767014



jeudi 19 mai 2016

R12 - Insertion de pièces GL - rééquilibrages des livres primaires/secondaires

R12 - Insertion de pièces GL - rééquilibrages des livres primaires/secondaires

Des pièces GL sont présentes dans le livre PRIMAIRE mais sont absentes dans le livre SECONDAIRE. Il faudrait récupérer ces pièces manquantes et les intégrer dans le second livre. Certaines pièces sont partiellement manquantes.

Méthode :
1 – Sélection des lots du mois considéré
SELECT distinct gjb.je_batch_id,gll.name, gjh.period_name, gjb.name, gjb.RUNNING_TOTAL_CR, gjb.RUNNING_TOTAL_DR, gjb.RUNNING_TOTAL_ACCOUNTED_CR, gjb.RUNNING_TOTAL_ACCOUNTED_DR
FROM gl_je_batches gjb, gl_je_headers gjh,gl_ledgers gll
WHERE gjb.je_batch_id = gjh.je_batch_id
AND gjh.ledger_id = gll.ledger_id
AND gjh.ledger_id IN (2259, 2596)
AND gjh.currency_code != 'STAT'
AND gjb.status = 'P' -- lot imputé
AND gjh.period_name IN ('APR-15')--, 'JUN-15')
ORDER BY gjb.name,gjh.period_name, gjb.RUNNING_TOTAL_CR

  
2 – Export Excel des données
Contrôler les lots (lots manquants, lots partiels, lots présents) entre les deux livres. Bien marquer ces catégories.

 
3 – Passer la requête d’INSERT (option : en excluant les lots partiels) dans GL_INTERFACE
Paramètres : mois
En dur :
gjh.ledger_id = 2259 -- LIVRE_PRIMAIRE
gll.name='_LIVRE_PRIMAIRE'
AND gll2.name='LIVRE_SECONDAIRE'


INSERT INTO GL_INTERFACE (status, ledger_id, accounting_date, currency_code, date_created, created_by, actual_flag, user_je_category_name,user_je_source_name
,segment1,segment2,segment3,segment4,segment5,segment6,segment7,segment8,segment9
,entered_dr,entered_cr,accounted_dr,accounted_cr
,period_name
,reference1 --batch name
,reference4 --Journal entry name
,reference5 --Journal entry description gjh.desciption
,reference10 -- Journal entry line description gjl.description
,reference25 -- gjl.refrence5
,reference26 -- gjl.refrence6
,reference27 -- gjl.refrence7
,reference28 -- gjl.refrence8
,reference29 -- gjl.refrence9
,reference30 -- gjl.refrence10
,GL_SL_LINK_ID --Renseigné par Oracle Subledger Accounting (SLA) pour indiquer le lien de la tansaction d'origine
,GL_SL_LINK_TABLE --Renseigné par Oracle Subledger Accounting (SLA) pour indiquer la table de la transaction d'origine
,subledger_doc_sequence_value
,subledger_doc_sequence_id
)
SELECT 'NEW'
,2596 -- LIVRE_SECONDAIRE
,gjl.effective_date, gjh.currency_code, sysdate, gjl.created_by, 'A' ,gjc.user_je_category_name, gjs.user_je_source_name
-- éléments de la clef comptables :
 ,gcc.segment1 
 ,'000000' 
 ,'00'
 ,'000'
 ,'0000'
 ,'0000'
 ,gcc.Segment7
 ,gcc.segment8 
,gcc.Segment9
,gjl.entered_dr,gjl.entered_cr,gjl.accounted_dr,gjl.accounted_cr
,gjh.period_name
,SUBSTR('R '||gjb.je_batch_id||' '||gjb.name,1,100) --- batch name
,gjh.name
,gjh.DESCRIPTION
,gjl.description
,gjl.reference_5
,gjl.reference_6
,gjl.reference_7
,gjl.reference_8
,gjl.reference_9
,gjl.reference_10
,gjl.GL_SL_LINK_ID
,gjl.GL_SL_LINK_TABLE
,gjl.subledger_doc_sequence_value
,gjl.subledger_doc_sequence_id
FROM GL_JE_BATCHES gjb
,GL_JE_HEADERS gjh
,GL_JE_LINES gjl
,GL_JE_CATEGORIES_TL gjc
,GL_JE_SOURCES_TL gjs
,GL_CODE_COMBINATIONS gcc
WHERE gcc.code_combination_id = gjl.code_combination_id
AND gjs.language = 'F'
AND gjs.JE_SOURCE_NAME = gjh.JE_SOURCE
AND gjc.language = 'F'
AND gjc.JE_CATEGORY_NAME = gjh.JE_CATEGORY
AND gjl.je_header_id = gjh.je_header_id
AND gjb.je_batch_id = gjh.je_batch_id
and gjh.ledger_id = 2259 -- LIVRE_PRIMAIRE
AND gjh.currency_code != 'STAT'
AND gjb.status = 'P' -- lot imputé
AND gjb.name IN (-- SELECTION DES LOTS --
SELECT --distinct gll.name, gjh.period_name, gjb.name, gjb.RUNNING_TOTAL_CR, gjb.RUNNING_TOTAL_DR
distinct gjb.name
FROM gl_je_batches gjb, gl_je_headers gjh, gl_ledgers gll
WHERE gjb.je_batch_id = gjh.je_batch_id
AND gjh.ledger_id = gll.ledger_id
AND gjh.period_name IN ('APR-15') --, 'MAY-15', 'JUN-15')
AND gll.name='LIVRE_PRIMAIRE'
AND NOT EXISTS (SELECT 'X' -- On enlève les lots déjà intégrés (même montant ici sinon trouver un caractère discriminatoire)
FROM gl_je_batches gjb2,gl_ledgers gll2,gl_je_headers gjh2
WHERE gjh2.ledger_id = gll2.ledger_id
AND gjb2.je_batch_id = gjh2.je_batch_id
AND gll2.name='LIVRE_SECONDAIRE'
AND gjh2.period_name = gjh.period_name
AND gjb.RUNNING_TOTAL_CR = gjb2.RUNNING_TOTAL_CR
AND gjb.RUNNING_TOTAL_DR = gjb2.RUNNING_TOTAL_DR
))

 
-- partie optionnelle s'il faut enlever les lots partiellements intégrés de la liste (identification manuelle) --
-- et/ou intégration dans un second temps après contrepassation des lots
AND gjb.name NOT IN
('Comptes fournisseurs A 833344 5471103'
,'Comptes fournisseurs A 837351 5495545'
,'Comptes fournisseurs A 844348 5522463'
,'Comptes fournisseurs A 844450 5530738'
,'Comptes fournisseurs A 845357 5538580'
,'Comptes fournisseurs A 850428 5571373'
,'Comptes fournisseurs A 850687 5587094'
,'Comptes fournisseurs A 850794 5594447'
,'Comptes fournisseurs A 851349 5601954'
,'Comptes fournisseurs A 853447 5628990'
,'Comptes fournisseurs A 855446 5638900'
)


 
Valider la transaction (COMMIT)

4) Lancer l’Easylink

Aller dans la responsabilité GL du livre secondaire (M)Pièces/importer/Lancer

Pour visionner ce qu'il y a dans GL_INTERFACE :
SELECT distinct(user_je_source_name) from gl_interface where ledger_id IN (2596) -- => Comptes fournisseurs ; Manuelle

 

 
A ce stade, si on veut repasser l’insert celui-ci ne devrait pas fonctionner car il trouve les lots existants avec les mêmes montants (ou le même caractère discriminatoire).

 
5) Rechercher les nouveaux lots créés puis contrôler les montants

-- Liste des lots importés
SELECT *
FROM gl_je_batches gjb
WHERE name like 'R %'
AND gjb.status = 'U'
-- Liste des pièces importées
select gjh.* from gl_je_headers gjh,gl_je_batches gjb
WHERE gjh.ledger_id = 2596
AND gjb.je_batch_id = gjh.je_batch_id
and gjb.name like 'R %'
AND gjb.status = 'U'

select gjl.* from gl_je_headers gjh, gl_je_lines gjl,gl_je_batches gjb
WHERE gjh.ledger_id = 2596
AND gjb.je_batch_id = gjh.je_batch_id
and gjb.name like 'R %'
AND gjb.status = 'U'
and gjh.je_header_id = gjl.je_header_id
select sum(gjh.running_total_dr),sum(gjh.running_total_cr),sum(gjh.running_total_accounted_dr),sum(gjh.running_total_accounted_cr)
from gl_je_headers gjh,gl_je_batches gjb
WHERE gjh.ledger_id = 2596
AND gjb.je_batch_id = gjh.je_batch_id
and gjb.name like 'R %'
AND gjb.status = 'U'

La somme correspond à la somme des lots dans le fichier extrait (préalablement repérées par un code couleur)

6) Demander la contrepassation des lots ‘partiels’, puis intégrer ces lots si ce n'est déjà fait.