summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2026-01-02 02:47:25 +0000
committerIT Fixcomart <it@fixcomart.co.id>2026-01-02 02:47:25 +0000
commit449e19edc55b2b64b218e56b8216ba56a04c5d3f (patch)
treea6ead845dbcbe5136da036d3b2b43fdd60661edd
parentb1cec830168ab113627bd10383f80d0e33c5b680 (diff)
parentbd1654bf8ffb0289492515900756df23e9e18586 (diff)
Merged in refund_system (pull request #475)
<hafid> fix journal ongkir
-rw-r--r--indoteknik_custom/models/refund_sale_order.py81
1 files changed, 80 insertions, 1 deletions
diff --git a/indoteknik_custom/models/refund_sale_order.py b/indoteknik_custom/models/refund_sale_order.py
index 0ff0a2f0..c22e84ab 100644
--- a/indoteknik_custom/models/refund_sale_order.py
+++ b/indoteknik_custom/models/refund_sale_order.py
@@ -348,12 +348,38 @@ class RefundSaleOrder(models.Model):
domain.append(('ref', 'ilike', n))
moves3 = self.env['account.move'].search(domain)
+ moves_ongkir = self.env['account.move']
+ if so_ids:
+ so_records = self.env['sale.order'].browse(so_ids)
+ so_names = so_records.mapped('name')
+
+ domain = [
+ ('journal_id', '=', 11),
+ ('state', '=', 'posted'),
+ ('sale_id', '=', False),
+ '|',
+ ('ref', 'ilike', 'pendapatan ongkos kirim'),
+ ('ref', 'ilike', 'ongkir'),
+ '|',
+ ('line_ids.account_id', '=', 450),
+ ('line_ids.account_id', '=', 668),
+ ]
+
+ if so_names:
+ domain += ['|'] * (len(so_names) - 1)
+ for name in so_names:
+ domain.append(('ref', 'ilike', name))
+
+ moves_ongkir = self.env['account.move'].search(domain)
+
+
has_moves = bool(moves)
has_moves2 = bool(moves2)
has_moves3 = bool(moves3)
has_piutangmdr = bool(piutangmdr)
has_piutangbca = bool(piutangbca)
has_misc = bool(misc)
+ has_ongkir = bool(moves_ongkir)
ssos = self.env['sale.order'].browse(so_ids)
has_settlement = any(so.payment_status == 'settlement' for so in ssos)
@@ -363,6 +389,8 @@ class RefundSaleOrder(models.Model):
if has_moves:
sisa_uang_masuk += sum(moves.mapped('amount_total_signed'))
+ if has_ongkir:
+ sisa_uang_masuk += sum(moves_ongkir.mapped('amount_total_signed'))
if has_moves2:
sisa_uang_masuk += sum(moves2.mapped('amount_total_signed'))
if has_moves3:
@@ -615,7 +643,31 @@ class RefundSaleOrder(models.Model):
('state', '=', 'posted'),
])
- all_moves = moves | piutangbca | piutangmdr | misc | moves2
+ moves_ongkir = self.env['account.move']
+ if rec.sale_order_ids:
+ so_records = rec.sale_order_ids
+ so_names = so_records.mapped('name')
+
+ domain = [
+ ('journal_id', '=', 11),
+ ('state', '=', 'posted'),
+ ('sale_id', '=', False),
+ '|',
+ ('ref', 'ilike', 'pendapatan ongkos kirim'),
+ ('ref', 'ilike', 'ongkir'),
+ '|',
+ ('line_ids.account_id', '=', 450),
+ ('line_ids.account_id', '=', 668),
+ ]
+
+ if so_names:
+ domain += ['|'] * (len(so_names) - 1)
+ for name in so_names:
+ domain.append(('ref', 'ilike', name))
+
+ moves_ongkir = self.env['account.move'].search(domain)
+
+ all_moves = moves | piutangbca | piutangmdr | misc | moves2 | moves_ongkir
for move in all_moves:
url = f"/web#id={move.id}&model=account.move&view_type=form"
@@ -683,6 +735,30 @@ class RefundSaleOrder(models.Model):
('state', '=', 'posted'),
])
+ moves_ongkir = self.env['account.move']
+ if so_ids:
+ so_records = self.env['sale.order'].browse(so_ids)
+ so_names = so_records.mapped('name')
+
+ domain = [
+ ('journal_id', '=', 11),
+ ('state', '=', 'posted'),
+ ('sale_id', '=', False),
+ '|',
+ ('ref', 'ilike', 'pendapatan ongkos kirim'),
+ ('ref', 'ilike', 'ongkir'),
+ '|',
+ ('line_ids.account_id', '=', 450),
+ ('line_ids.account_id', '=', 668),
+ ]
+
+ if so_names:
+ domain += ['|'] * (len(so_names) - 1)
+ for name in so_names:
+ domain.append(('ref', 'ilike', name))
+
+ moves_ongkir = self.env['account.move'].search(domain)
+
moves2 = self.env['account.move']
if so_ids:
so_records = self.env['sale.order'].browse(so_ids)
@@ -724,6 +800,7 @@ class RefundSaleOrder(models.Model):
has_piutangmdr = bool(piutangmdr)
has_piutangbca = bool(piutangbca)
has_misc = bool(misc)
+ has_ongkir = bool(moves_ongkir)
ssos = self.env['sale.order'].browse(so_ids)
has_settlement = any(so.payment_status == 'settlement' for so in ssos)
@@ -743,6 +820,8 @@ class RefundSaleOrder(models.Model):
sisa_uang_masuk += sum(piutangmdr.mapped('amount_total_signed'))
if has_misc:
sisa_uang_masuk += sum(misc.mapped('amount_total_signed'))
+ if has_ongkir:
+ sisa_uang_masuk += sum(moves_ongkir.mapped('amount_total_signed'))
if has_settlement and not has_journal:
sisa_uang_masuk += sum(ssos.mapped('gross_amount'))