diff options
| author | HafidBuroiroh <hafidburoiroh09@gmail.com> | 2025-09-24 16:46:18 +0700 |
|---|---|---|
| committer | HafidBuroiroh <hafidburoiroh09@gmail.com> | 2025-09-24 16:46:18 +0700 |
| commit | fa4d124243688f4a74dd605a21b7b402ee632191 (patch) | |
| tree | 4cec5c490d1035ea3ebe5a747cf752c3b0d13628 | |
| parent | 5abefd1181a148c4caf9b5dd2082ee3b3e884751 (diff) | |
<hafid> refund
| -rw-r--r-- | indoteknik_custom/models/refund_sale_order.py | 28 | ||||
| -rw-r--r-- | indoteknik_custom/views/account_move_line.xml | 3 | ||||
| -rw-r--r-- | indoteknik_custom/views/refund_sale_order.xml | 1 |
3 files changed, 27 insertions, 5 deletions
diff --git a/indoteknik_custom/models/refund_sale_order.py b/indoteknik_custom/models/refund_sale_order.py index eab25452..6a6d10ea 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([ @@ -906,9 +910,10 @@ class RefundSaleOrder(models.Model): ('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 rec.amount_refund != sum(is_journal.mapped('amount_total_signed')): + 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' @@ -966,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({ @@ -976,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, @@ -991,17 +997,29 @@ 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 'partner_id': partner.id, 'currency_id': 12, 'debit': 0.0, - 'credit': amount, + 'credit': amount + admintf, 'name': ref_text, } - self.env['account.move.line'].create([debit_line, credit_line]) + journal_line = [debit_line, adminline, credit_line] if admintf > 0 else [debit_line, credit_line] + + self.env['account.move.line'].create(journal_line) return { 'name': _('Journal Entries'), diff --git a/indoteknik_custom/views/account_move_line.xml b/indoteknik_custom/views/account_move_line.xml index 02b936f1..017a9eda 100644 --- a/indoteknik_custom/views/account_move_line.xml +++ b/indoteknik_custom/views/account_move_line.xml @@ -6,6 +6,9 @@ <field name="model">account.move</field> <field name="inherit_id" ref="account.view_move_form"/> <field name="arch" type="xml"> + <xpath expr="//page[@id='aml_tab']/field[@name='line_ids']" position="attributes"> + <attribute name="attrs">{'readonly': [('refund_id','!=',False)]}</attribute> + </xpath> <xpath expr="//page[@id='aml_tab']/field[@name='line_ids']/tree/field[@name='currency_id']" position="before"> <field name="is_required" invisible="1"/> </xpath> diff --git a/indoteknik_custom/views/refund_sale_order.xml b/indoteknik_custom/views/refund_sale_order.xml index 51f3deab..afa7c1cb 100644 --- a/indoteknik_custom/views/refund_sale_order.xml +++ b/indoteknik_custom/views/refund_sale_order.xml @@ -217,6 +217,7 @@ <field name="finance_note"/> </group> <group> + <field name="biaya_admin"/> <field name="bukti_refund_type" reqiured="1"/> <field name="bukti_transfer_refund_pdf" widget="pdf_viewer" attrs="{'invisible': [('bukti_refund_type', '=', 'image')]}"/> <field name="bukti_transfer_refund_image" widget="image" attrs="{'invisible': [('bukti_refund_type', '=', 'pdf')]}"/> |
