diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-09-12 15:00:12 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-09-12 15:00:12 +0700 |
| commit | bb49da69c2af4d32c6bbc99cbc74e86e1f695424 (patch) | |
| tree | def59116d071d38a712b925480ee1ab94d7e21c5 /fixco_custom/models/sale.py | |
| parent | f1b119641b64b77427caa5199d9ce04e5c965c52 (diff) | |
schema sisa uang muka
Diffstat (limited to 'fixco_custom/models/sale.py')
| -rwxr-xr-x | fixco_custom/models/sale.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/fixco_custom/models/sale.py b/fixco_custom/models/sale.py index 9943376..c6e9ccb 100755 --- a/fixco_custom/models/sale.py +++ b/fixco_custom/models/sale.py @@ -15,6 +15,37 @@ class SaleOrder(models.Model): count_journals = fields.Integer('Count Payment', compute='_compute_count_journals') + remaining_down_payment = fields.Float('Remaining Down Payment', compute='_compute_remaining_down_payment') + + def _compute_remaining_down_payment(self): + for order in self: + down_payments = self.env['account.move'].search([ + ('sale_id', '=', order.id), + ('move_type', '=', 'entry'), + ('state', '=', 'posted'), + ('uangmuka', '=', True) + ]) + + reklas = self.env['account.move'].search([ + ('sale_id', '=', order.id), + ('move_type', '=', 'entry'), + ('state', '=', 'posted'), + ('reklas', '=', True) + ]) + + def check_reklas_used(reklas): + for line in reklas.line_ids: + if line.reconciled and line.matching_number: + return True + return False + + reklas = reklas.filtered(check_reklas_used) + + nominal_down_payment = sum(down_payments.mapped('amount_total_signed')) if down_payments else 0 + nominal_reklas = sum(reklas.mapped('amount_total_signed')) if reklas else 0 + + order.remaining_down_payment = nominal_down_payment - nominal_reklas + def _compute_count_journals(self): for order in self: journals = self.env['account.move'].search([ |
