summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2025-09-15 11:02:08 +0000
committerIT Fixcomart <it@fixcomart.co.id>2025-09-15 11:02:08 +0000
commite432f70b5588c1ab86add20ee15df20d2f2a3876 (patch)
treedbbddf56c656a36bc658ceacd8a080df4918b36a
parentd7647af478bfe2c1b60f00ff2e13327c0ec09be2 (diff)
parent4c305c1ac192d5610dedbc90723281dd09bc0a97 (diff)
Merged in refund_system (pull request #415)
Refund system
-rw-r--r--indoteknik_custom/models/refund_sale_order.py17
-rw-r--r--indoteknik_custom/views/refund_sale_order.xml2
2 files changed, 17 insertions, 2 deletions
diff --git a/indoteknik_custom/models/refund_sale_order.py b/indoteknik_custom/models/refund_sale_order.py
index f511ed5d..55128080 100644
--- a/indoteknik_custom/models/refund_sale_order.py
+++ b/indoteknik_custom/models/refund_sale_order.py
@@ -77,7 +77,7 @@ class RefundSaleOrder(models.Model):
'account.move',
string="Journal Payment",
copy=False,
- help="Pilih transaksi salah transfer dari jurnal Uang Muka (journal_id=11) yang tidak terkait SO."
+ help="Pilih transaksi salah transfer dari jurnal Uang Muka yang tidak terkait SO."
)
tukar_guling_count = fields.Integer(
@@ -297,6 +297,14 @@ class RefundSaleOrder(models.Model):
total_invoice = sum(self.env['account.move'].browse(invoice_ids).mapped('amount_total_signed')) if invoice_ids else 0.0
vals['total_invoice'] = total_invoice
amount_refund = vals.get('amount_refund', 0.0)
+ can_refund = sisa_uang_masuk - total_invoice
+
+ if amount_refund > can_refund or can_refund == 0.0:
+ raise ValidationError(
+ _("Maksimal refund yang bisa dilakukan adalah sebesar %s. "
+ "Silakan sesuaikan jumlah refund.") % (can_refund)
+ )
+
if amount_refund <= 0.00:
raise ValidationError('Total Refund harus lebih dari 0 jika ingin mengajukan refund')
@@ -393,9 +401,16 @@ class RefundSaleOrder(models.Model):
total_invoice = sum(self.env['account.move'].browse(invoice_ids).mapped('amount_total_signed'))
vals['total_invoice'] = total_invoice
uang_masuk = rec.uang_masuk
+ can_refund = uang_masuk - total_invoice
amount_refund = vals.get('amount_refund', rec.amount_refund)
+ if amount_refund > can_refund:
+ raise ValidationError(
+ _("Maksimal refund yang bisa dilakukan adalah sebesar %s. "
+ "Silakan sesuaikan jumlah refund.") % (can_refund)
+ )
+
if amount_refund <= 0:
raise ValidationError("Total Refund harus lebih dari 0.")
diff --git a/indoteknik_custom/views/refund_sale_order.xml b/indoteknik_custom/views/refund_sale_order.xml
index 0c6cd371..51f3deab 100644
--- a/indoteknik_custom/views/refund_sale_order.xml
+++ b/indoteknik_custom/views/refund_sale_order.xml
@@ -92,7 +92,7 @@
</div>
<field name="show_approval_alert" invisible="1"/>
<div class="alert alert-info" role="alert"
- attrs="{'invisible': ['|', ('show_approval_alert', '=', False), ('status', 'in', ['reject', 'refund'])]}">
+ attrs="{'invisible': ['|', ('show_approval_alert', '=', False), '|', ('status', 'in', ['reject', 'refund']), ('refund_type', 'not in', ['retur_full', 'retur_sebagian'])]}">
⚠️ SO sudah melakukan retur barang. Silakan lanjutkan refund.
</div>
</xpath>