summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
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 /indoteknik_custom/models
parentd7647af478bfe2c1b60f00ff2e13327c0ec09be2 (diff)
parent4c305c1ac192d5610dedbc90723281dd09bc0a97 (diff)
Merged in refund_system (pull request #415)
Refund system
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/refund_sale_order.py17
1 files changed, 16 insertions, 1 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.")