Skip to content

Commit

Permalink
[MIG] l10n_ar_account_reports: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
docker-odoo authored and mem-adhoc committed Oct 29, 2024
1 parent 56de75c commit f120547
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 39 deletions.
4 changes: 2 additions & 2 deletions l10n_ar_account_reports/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Accounting Reports Customized for Argentina',
'version': "17.0.1.1.0",
'version': "18.0.1.0.0",
'category': 'Accounting',
'sequence': 14,
'summary': '',
Expand All @@ -42,7 +42,7 @@
],
'test': [
],
'installable': False,
'installable': True,
'auto_install': True,
'application': False,
}
86 changes: 49 additions & 37 deletions l10n_ar_account_reports/wizards/checks_to_date_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,22 @@ def _get_checks_handed(self, journal_id, to_date):
query = """
SELECT DISTINCT ON (t.check_id) t.check_id AS cheque FROM
(
SELECT ap.id as check_id, ap_move.date as operation_date, apm.code as operation_code
FROM account_payment ap
LEFT JOIN account_payment_method AS apm ON apm.id = ap.payment_method_id
LEFT JOIN account_move AS ap_move ON ap.move_id = ap_move.id
SELECT lc.id as check_id, ap_move.date as operation_date, apm.code as operation_code
FROM l10n_latam_check lc
LEFT JOIN account_payment AS acp ON lc.payment_id = acp.id
LEFT JOIN account_payment_method AS apm ON apm.id = lc.payment_method_line_id
LEFT JOIN account_move AS ap_move ON acp.move_id = ap_move.id
LEFT JOIN account_journal AS journal ON ap_move.journal_id = journal.id
WHERE
apm.code = 'check_printing' AND ap_move.date <= '%s' order by ap.id, ap_move.date desc, ap.id desc
WHERE apm.code = 'check_printing' AND ap_move.date <= '%s'
ORDER BY lc.id, ap_move.date DESC, lc.id DESC
) t
LEFT JOIN
(
SELECT ap.id as check_id, aml_2.date as operation_date, aml.id as aml_1, aml_2.id as aml_2
FROM account_payment ap
JOIN account_payment_method AS apm ON apm.id = ap.payment_method_id
JOIN account_move_line as aml ON ap.move_id = aml.move_id
SELECT lc.id as check_id, aml_2.date as operation_date, aml.id as aml_1, aml_2.id as aml_2
FROM l10n_latam_check lc
JOIN account_payment AS acp ON acp.id = lc.payment_id
JOIN account_payment_method AS apm ON apm.id = lc.payment_method_line_id
JOIN account_move_line AS aml ON acp.move_id = aml.move_id
JOIN account_full_reconcile AS afr_full ON afr_full.id = aml.full_reconcile_id
JOIN account_move_line AS aml_2 ON aml_2.full_reconcile_id = afr_full.id
WHERE apm.code = 'check_printing' AND aml.id <> aml_2.id
Expand Down Expand Up @@ -95,51 +97,61 @@ def _get_checks_on_hand(self, journal_id, to_date):
SELECT DISTINCT ON (t.check_id) t.check_id AS cheque
FROM
(
SELECT ap.id as check_id, ap_move.date as operation_date, apm.code as operation_code
FROM account_payment ap
LEFT JOIN account_payment_method AS apm ON apm.id = ap.payment_method_id
LEFT JOIN account_move AS ap_move ON ap.move_id = ap_move.id
SELECT lc.id as check_id, ap_move.date as operation_date, apm.code as operation_code
FROM l10n_latam_check lc
LEFT JOIN account_payment AS acp ON acp.id = lc.payment_id
LEFT JOIN account_payment_method AS apm ON apm.id = lc.payment_method_line_id
LEFT JOIN account_move AS ap_move ON acp.move_id = ap_move.id
LEFT JOIN account_journal AS journal ON ap_move.journal_id = journal.id
WHERE
apm.code = 'new_third_party_checks' AND ap_move.date <= '%s' AND ap.l10n_latam_check_current_journal_id IS NOT NULL
WHERE apm.code = 'new_third_party_checks'
AND ap_move.date <= '%s'
AND lc.current_journal_id IS NOT NULL
) t
LEFT JOIN
(
SELECT DISTINCT ON (ap_check_op.l10n_latam_check_id) ap_check_op.l10n_latam_check_id as check_id, ap_check_op.id as payment_id, ap_check_op_move.date as operation_date, apm.code as operation_code, pair_apm.code as paired_code, ap_check_op.l10n_latam_check_current_journal_id as journal
FROM account_payment ap_check_op
LEFT JOIN account_move AS ap_check_op_move ON ap_check_op.move_id = ap_check_op_move.id
LEFT JOIN account_payment_method AS apm ON apm.id = ap_check_op.payment_method_id
LEFT JOIN account_payment AS pair_ap ON pair_ap.id = ap_check_op.paired_internal_transfer_payment_id
LEFT JOIN account_payment_method as pair_apm ON pair_apm.id = pair_ap.payment_method_id
SELECT DISTINCT ON (ap_check_op.id)
ap_check_op.id as check_id,
ap_check_op.payment_id as payment_id,
ap_check_op_move.date as operation_date,
apm.code as operation_code,
ap_check_op.current_journal_id as journal
FROM l10n_latam_check ap_check_op
LEFT JOIN account_payment AS acp ON acp.id = ap_check_op.payment_id
LEFT JOIN account_move AS ap_check_op_move ON acp.move_id = ap_check_op_move.id
LEFT JOIN account_payment_method AS apm ON apm.id = ap_check_op.payment_method_line_id
WHERE
ap_check_op.l10n_latam_check_id IS NOT NULL AND ap_check_op_move.date <= '%s'
ORDER BY check_id, operation_date desc, payment_id desc
ap_check_op_move.date <= '%s'
ORDER BY
check_id, operation_date DESC, payment_id DESC
) t2
ON t.check_id = t2.check_id
WHERE t2.operation_date IS NULL OR (t2.operation_code != 'out_third_party_checks' AND paired_code != 'out_third_party_checks')
WHERE t2.operation_date IS NULL OR (t2.operation_code != 'out_third_party_checks')
UNION ALL
SELECT DISTINCT ON (t4.check_id) t4.check_id as cheque
FROM
(
SELECT ap.l10n_latam_check_id as check_id
FROM account_payment ap
LEFT JOIN account_payment_method AS apm ON apm.id = ap.payment_method_id
LEFT JOIN account_move AS ap_move ON ap.move_id = ap_move.id
SELECT lc.id as check_id
FROM l10n_latam_check lc
LEFT JOIN account_payment AS acp ON acp.id = lc.payment_id
LEFT JOIN account_payment_method AS apm ON apm.id = lc.payment_method_line_id
LEFT JOIN account_move AS ap_move ON acp.move_id = ap_move.id -- Usa el move_id del pago
LEFT JOIN account_journal AS journal ON ap_move.journal_id = journal.id
WHERE
apm.code = 'out_third_party_checks' AND ap_move.date > '%s'
AND
ap.l10n_latam_check_current_journal_id IS NULL
apm.code = 'out_third_party_checks'
AND ap_move.date > '%s'
AND lc.current_journal_id IS NULL
) t3
JOIN
(
SELECT ap.id as check_id, ap.l10n_latam_check_current_journal_id as journal
FROM account_payment ap
LEFT JOIN account_payment_method AS apm ON apm.id = ap.payment_method_id
LEFT JOIN account_move AS ap_move ON ap.move_id = ap_move.id
SELECT lc.id AS check_id, lc.current_journal_id AS journal
FROM l10n_latam_check lc
LEFT JOIN account_payment AS acp ON acp.id = lc.payment_id
LEFT JOIN account_payment_method AS apm ON apm.id = lc.payment_method_line_id
LEFT JOIN account_move AS ap_move ON acp.move_id = ap_move.id
LEFT JOIN account_journal AS journal ON ap_move.journal_id = journal.id
WHERE
apm.code = 'new_third_party_checks' AND ap_move.date <= '%s'
apm.code = 'new_third_party_checks'
AND (ap_move.date <= '%s' OR ap_move.date IS NULL)
) t4
ON t3.check_id = t4.check_id
WHERE t4.journal IS NULL
Expand Down

0 comments on commit f120547

Please sign in to comment.