From d32684d5d69a76c97ac962e898f3bb58f708fca4 Mon Sep 17 00:00:00 2001 From: FIN-IT_AndriFP Date: Thu, 25 Sep 2025 11:06:24 +0700 Subject: (andri) penambahan perihal penutupan tempo pada surat piutang --- indoteknik_custom/models/letter_receivable.py | 20 +- .../report/report_surat_piutang copy.xml | 149 ------------- indoteknik_custom/report/report_tutup_tempo.xml | 241 +++++++++++++++++++++ .../views/close_tempo_mail_template.xml | 77 +++++++ indoteknik_custom/views/letter_receivable.xml | 1 + 5 files changed, 336 insertions(+), 152 deletions(-) delete mode 100644 indoteknik_custom/report/report_surat_piutang copy.xml create mode 100644 indoteknik_custom/report/report_tutup_tempo.xml create mode 100644 indoteknik_custom/views/close_tempo_mail_template.xml diff --git a/indoteknik_custom/models/letter_receivable.py b/indoteknik_custom/models/letter_receivable.py index 16034938..6f95e5e7 100644 --- a/indoteknik_custom/models/letter_receivable.py +++ b/indoteknik_custom/models/letter_receivable.py @@ -23,6 +23,7 @@ class SuratPiutang(models.Model): tujuan_nama = fields.Char(string="Nama Tujuan", tracking=True) tujuan_email = fields.Char(string="Email Tujuan", tracking=True) perihal = fields.Selection([ + ('tutup_tempo', 'Surat Penutupan Pembayaran Tempo'), ('penagihan', 'Surat Resmi Penagihan'), ('sp1', 'Surat Peringatan Piutang ke-1'), ('sp2', 'Surat Peringatan Piutang ke-2'), @@ -36,6 +37,7 @@ class SuratPiutang(models.Model): ("sent", "Approved & Sent") ], default="draft", tracking=True) send_date = fields.Datetime(string="Tanggal Kirim", tracking=True) + due_date = fields.Date(string="Tanggal Jatuh Tempo", tracking=True, default= fields.Date.today) seven_days_after_sent_date = fields.Char(string="7 Hari Setelah Tanggal Kirim") periode_invoices_terpilih = fields.Char( string="Periode Invoices Terpilih", @@ -228,14 +230,14 @@ class SuratPiutang(models.Model): continue # === Surat penagihan biasa (langsung Pimpinan approve) === - if rec.perihal == "penagihan": + if rec.perihal in ("tutup_tempo", "penagihan"): # if self.env.user.id not in pimpinan_user_ids: # raise UserError("Hanya Pimpinan yang boleh menyetujui surat penagihan.") rec.state = "sent" now_utc = now_wib.astimezone(pytz.UTC).replace(tzinfo=None) rec.send_date = now_utc rec.action_send_letter() - rec.message_post(body="Surat Penagihan disetujui dan berhasil dikirim.") + rec.message_post(body=f"{rec.perihal_label} disetujui dan berhasil dikirim.") self.env.user.notify_info( message=f"Surat piutang {rec.name} berhasil dikirim ke {rec.partner_id.name} ({rec.tujuan_email})", @@ -453,6 +455,18 @@ class SuratPiutang(models.Model): body=f"Line Invoices diperbarui. Total line saat ini: {len(rec.line_ids)}" ) + @api.onchange('perihal', 'partner_id') + def _onchange_perihal_tutup_tempo(self): + if self.perihal == 'tutup_tempo': + for line in self.line_ids: + if line.new_invoice_day_to_due < -30: + line.selected = True + else: + line.selected = False + else: + for line in self.line_ids: + line.selected = False + @api.model def create(self, vals): # Generate nomor surat otomatis @@ -462,7 +476,7 @@ class SuratPiutang(models.Model): bulan_romawi = ["I","II","III","IV","V","VI","VII","VIII","IX","X","XI","XII"][today.month-1] tahun = today.strftime("%y") vals["name"] = f"{seq}/LO/FAT/IDG/{bulan_romawi}/{tahun}" - if vals.get("perihal") == "penagihan": + if vals.get("perihal") in ("tutup_tempo", "penagihan"): vals["state"] = "waiting_approval_pimpinan" else: vals["state"] = "waiting_approval_sales" diff --git a/indoteknik_custom/report/report_surat_piutang copy.xml b/indoteknik_custom/report/report_surat_piutang copy.xml deleted file mode 100644 index cb5762f3..00000000 --- a/indoteknik_custom/report/report_surat_piutang copy.xml +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - - Surat Peringatan Piutang - surat.piutang - qweb-pdf - indoteknik_custom.report_surat_piutang_formal_custom - indoteknik_custom.report_surat_piutang_formal_custom - - report - - - - - - - diff --git a/indoteknik_custom/report/report_tutup_tempo.xml b/indoteknik_custom/report/report_tutup_tempo.xml new file mode 100644 index 00000000..e4647119 --- /dev/null +++ b/indoteknik_custom/report/report_tutup_tempo.xml @@ -0,0 +1,241 @@ + + + + + + + Surat Penutupan Tempo + surat.piutang + qweb-pdf + indoteknik_custom.report_surat_piutang + indoteknik_custom.report_surat_piutang + '%s - %s' % (object.perihal_label or '', object.partner_id.name or '') + + report + + + + + + + + + + + + + + diff --git a/indoteknik_custom/views/close_tempo_mail_template.xml b/indoteknik_custom/views/close_tempo_mail_template.xml new file mode 100644 index 00000000..f1e66d40 --- /dev/null +++ b/indoteknik_custom/views/close_tempo_mail_template.xml @@ -0,0 +1,77 @@ + + + + + Surat Penutupan Tempo + + + finance@indoteknik.co.id + + +
+
Dengan hormat,
+
+
Kepada Yth.
+
Manajemen ${object.partner_id.name}
+
+
+ Melalui email ini, kami ingin mengingatkan kembali terkait kewajiban pembayaran + ${object.partner_id.name} atas transaksi dengan rincian sebagai berikut: +
+
+ + + + + + + + + + + + + + + + + +
Invoice NumberCustomerInvoice DateDue DateDays To DueReferenceAmount Due SignedPayment Terms
+ +

+ Hingga saat ini, kami belum menerima pembayaran atas tagihan tersebut. + Mohon konfirmasi dan tindak lanjut dari pihak saudara paling lambat pada + tanggal ${object.seven_days_after_sent_date} (7 hari setelah email ini dikirimkan). +

+ +

+ Sebagai informasi, kami lampirkan ${object.perihal} untuk menjadi perhatian. + Jika tidak ada tanggapan atau penyelesaian dalam batas waktu tersebut, kami akan + melanjutkan dengan pengiriman surat peringatan berikutnya dan mengambil langkah-langkah + penyelesaian sesuai ketentuan yang berlaku. +

+ +

+ Demikian kami sampaikan. Atas perhatian dan kerja samanya, kami ucapkan terima kasih. +

+ +

+

+ + Best Regards,

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

+
+
+ +
+
+
diff --git a/indoteknik_custom/views/letter_receivable.xml b/indoteknik_custom/views/letter_receivable.xml index 98ea7768..4810909f 100644 --- a/indoteknik_custom/views/letter_receivable.xml +++ b/indoteknik_custom/views/letter_receivable.xml @@ -81,6 +81,7 @@ + -- cgit v1.2.3