summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/refund_sale_order.py
diff options
context:
space:
mode:
authorFIN-IT_AndriFP <it@fixcomart.co.id>2025-09-25 09:04:32 +0700
committerFIN-IT_AndriFP <it@fixcomart.co.id>2025-09-25 09:04:32 +0700
commit65c0ccd8b6befa65e912e9a0126cf2ef8bdd78d7 (patch)
tree3ce6d9106c644f84f2a908f1642846a689075fe1 /indoteknik_custom/models/refund_sale_order.py
parent8b179c22149366ecf4dd9de6e5e7b5be612e355b (diff)
parentcd0592f7b7248d25d1b7de728af87117ae0b5876 (diff)
Merge branch 'odoo-backup' of https://bitbucket.org/altafixco/indoteknik-addons into closing-apt
Diffstat (limited to 'indoteknik_custom/models/refund_sale_order.py')
-rw-r--r--indoteknik_custom/models/refund_sale_order.py42
1 files changed, 39 insertions, 3 deletions
diff --git a/indoteknik_custom/models/refund_sale_order.py b/indoteknik_custom/models/refund_sale_order.py
index 687acd6d..96082447 100644
--- a/indoteknik_custom/models/refund_sale_order.py
+++ b/indoteknik_custom/models/refund_sale_order.py
@@ -51,6 +51,7 @@ class RefundSaleOrder(models.Model):
account_no = fields.Char(string='Account No', required=True)
kcp = fields.Char(string='Alamat KCP')
finance_note = fields.Text(string='Finance Note')
+ biaya_admin = fields.Float(string='Biaya Admin Transfer')
invoice_names = fields.Html(string="Group Invoice Number", compute="_compute_invoice_names")
so_names = fields.Html(string="Group SO Number", compute="_compute_so_names")
@@ -280,8 +281,11 @@ class RefundSaleOrder(models.Model):
if refund_type == 'salah_transfer' and vals.get('transfer_move_id'):
move = self.env['account.move'].browse(vals['transfer_move_id'])
if move:
+ sisa_uang_masuk = move.amount_total_signed # ← set dengan nilai move
vals['uang_masuk'] = move.amount_total_signed
vals['remaining_refundable'] = 0
+ else:
+ sisa_uang_masuk = 0.0
else:
# ==== perhitungan normal ====
moves = self.env['account.move'].search([
@@ -902,6 +906,15 @@ class RefundSaleOrder(models.Model):
for rec in self:
if not is_fat:
raise UserError("Hanya Finance yang dapat mengkonfirmasi pembayaran refund.")
+ is_journal = self.env['account.move'].search([
+ ('refund_id', '=', rec.id),
+ ('state', '=', 'posted')
+ ])
+ amount = rec.amount_refund + rec.biaya_admin
+ if not is_journal:
+ raise UserError("Journal Payment Refund belum dibuat, buat Journal Payment Refund sebelum confirm refund.")
+ if is_journal and amount != sum(is_journal.mapped('amount_total_signed')):
+ raise UserError("Total Refund dengan Total Journal Harus Sama.")
if rec.status_payment == 'pending':
rec.status_payment = 'done'
rec.refund_date = fields.Date.context_today(self)
@@ -958,6 +971,7 @@ class RefundSaleOrder(models.Model):
# Ref format
ref_text = f"{refund_type_label} {refund.name or ''} {partner.display_name}".upper()
+ admintex = f"BIAYA ADMIN BANK {refund_type_label} {refund.name or ''} {partner.display_name}".upper()
# Buat Account Move (Journal Entry)
account_move = self.env['account.move'].create({
@@ -968,10 +982,10 @@ class RefundSaleOrder(models.Model):
'refund_so_ids': [(6, 0, refund.sale_order_ids.ids)],
'partner_id': partner.id,
})
-
+ admintf = refund.biaya_admin
amount = refund.amount_refund
# 450 Penerimaan Belum Teridentifikasi, 668 Penerimaan Belum Alokasi
- second_account_id = 450 if refund.refund_type not in ['barang_kosong', 'barang_kosong_sebagian'] else 668
+ second_account_id = 450 if refund.refund_type not in ['barang_kosong', 'barang_kosong_sebagian', 'barang_kosong_indent'] else 668
debit_line = {
'move_id': account_move.id,
@@ -983,6 +997,16 @@ class RefundSaleOrder(models.Model):
'name': ref_text,
}
+ adminline = {
+ 'move_id': account_move.id,
+ 'account_id': 555,
+ 'partner_id': partner.id,
+ 'currency_id': 12,
+ 'debit': admintf,
+ 'credit': 0.0,
+ 'name': admintex,
+ }
+
credit_line = {
'move_id': account_move.id,
'account_id': 389, # Intransit BCA
@@ -993,7 +1017,19 @@ class RefundSaleOrder(models.Model):
'name': ref_text,
}
- self.env['account.move.line'].create([debit_line, credit_line])
+ credit_admin_line = {
+ 'move_id': account_move.id,
+ 'account_id': 389, # Intransit BCA
+ 'partner_id': partner.id,
+ 'currency_id': 12,
+ 'debit': 0.0,
+ 'credit': admintf,
+ 'name': admintex,
+ }
+
+ journal_line = [debit_line, credit_line, adminline, credit_admin_line] if admintf > 0 else [debit_line, credit_line]
+
+ self.env['account.move.line'].create(journal_line)
return {
'name': _('Journal Entries'),