From 43049cea86883ffcfb6ae988dc46b74ad38def85 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Tue, 26 Aug 2025 17:05:58 +0700 Subject: (andri) fix layout mail reminder & add limit, sisa limit, limit terpakai, & jatuh tempo seperti pada tempo di webite --- indoteknik_custom/models/account_move.py | 66 ++++++++++++++++++---- .../views/mail_template_invoice_reminder.xml | 54 ++++++++++-------- 2 files changed, 85 insertions(+), 35 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 49bfe762..f5dd5a39 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -179,8 +179,9 @@ class AccountMove(models.Model): ('state', '=', 'posted'), ('payment_state', 'not in', ['paid', 'in_payment', 'reversed']), ('invoice_date_due', 'in', target_dates), - ('date_terima_tukar_faktur', '!=', False) - ], limit=5) + ('date_terima_tukar_faktur', '!=', False), + ('partner_id', 'in', [88813, 80163]) + ]) _logger.info(f"Invoices: {invoices}") invoices = invoices.filtered( @@ -275,23 +276,68 @@ class AccountMove(models.Model): blocking_limit = partner.blocking_stage or 0.0 + # semua invoice tempo yang masih open outstanding_invoices = self.env['account.move'].search([ ('move_type', '=', 'out_invoice'), ('state', '=', 'posted'), ('payment_state', 'not in', ['paid', 'in_payment', 'reversed']), ('partner_id', '=', partner.id), ('invoice_payment_term_id.name', 'ilike', 'tempo') - ]) - _logger.info(f"Outstanding invoices for {partner.name}: {outstanding_invoices}") + outstanding_amount = sum(outstanding_invoices.mapped('amount_total')) + + # invoice tempo yang sudah jatuh tempo + overdue_invoices = outstanding_invoices.filtered( + lambda inv: inv.invoice_date_due and inv.invoice_date_due < fields.Date.today() + ) + + overdue_amount = sum(overdue_invoices.mapped('amount_total')) + currency = invs[0].currency_id if invs else partner.company_id.currency_id limit_info_html = f""" -

Informasi Tambahan:

- + + + + + + + + + + + + + + + +
+ Pembayaran Tempo +
+

Kredit Limit Anda
+ {formatLang(self.env, blocking_limit, currency_obj=currency)} +

+

Status Detail Tempo Pembayaran Anda
+ {partner.property_payment_term_id.name or 'Review'} +

+
+
+ {formatLang(self.env, blocking_limit - outstanding_amount, currency_obj=currency)} +
+
Sisa Kredit Limit
+
+
+ {formatLang(self.env, outstanding_amount, currency_obj=currency)} +
+
Kredit Limit Terpakai
+
{len(outstanding_invoices)} Transaksi
+
+
+ {formatLang(self.env, overdue_amount, currency_obj=currency)} +
+
Jatuh Tempo
+
{len(overdue_invoices)} Invoice
+
""" days_to_due_message = "" @@ -340,7 +386,7 @@ class AccountMove(models.Model): ).replace('${object.name}', partner.name) \ .replace('${object.partner_id.name}', partner.name) \ .replace('${days_to_due_message}', days_to_due_message) \ - .replace('${closing_message}', closing_message + limit_info_html) + .replace('${closing_message}', limit_info_html + closing_message) cc_list = [ 'finance@indoteknik.co.id', diff --git a/indoteknik_custom/views/mail_template_invoice_reminder.xml b/indoteknik_custom/views/mail_template_invoice_reminder.xml index 8450be28..3a02fa2e 100644 --- a/indoteknik_custom/views/mail_template_invoice_reminder.xml +++ b/indoteknik_custom/views/mail_template_invoice_reminder.xml @@ -8,45 +8,49 @@ finance@indoteknik.co.id -
+

Dear ${object.name},

${days_to_due_message}

- +
- - - - - - - - - + + + + + + + + + +
CustomerNo. POInvoice NumberInvoice DateDue DateAmountTermDays To Due
CustomerNo. POInvoice NumberInvoice DateDue DateAmountTermDays To Due

${closing_message}


Terima Kasih.

-
-
-

Best Regards, -
-
- Widya R.
- Dept. Finance
- PT. INDOTEKNIK DOTCOM GEMILANG
- Indoteknik
- +62-857-1697-0374 | - finance@indoteknik.co.id -

-

Email ini dikirim secara otomatis. Abaikan jika pembayaran telah dilakukan.

- +

+

+ + Best Regards,

+ Widya R.
+ Dept. Finance
+ PT. INDOTEKNIK DOTCOM GEMILANG
+ Indoteknik
+ +62-857-1697-0374 | + finance@indoteknik.co.id +
+

+

+ Email ini dikirim secara otomatis. Abaikan jika pembayaran telah dilakukan. +

-- cgit v1.2.3