diff options
| author | FIN-IT_AndriFP <it@fixcomart.co.id> | 2025-10-20 10:26:32 +0700 |
|---|---|---|
| committer | FIN-IT_AndriFP <it@fixcomart.co.id> | 2025-10-20 10:26:32 +0700 |
| commit | 06e514d5287d2a316787e80648a06b2d92dc0d47 (patch) | |
| tree | fde84b427a10471ecab4272c45e28cdf4737ea9b | |
| parent | a4363a5468a5a9d6a3815cb8ae304fe1da3aef30 (diff) | |
(andri) grandtotal reimburse
| -rw-r--r-- | indoteknik_custom/models/advance_payment_request.py | 40 | ||||
| -rw-r--r-- | indoteknik_custom/views/advance_payment_request.xml | 15 |
2 files changed, 37 insertions, 18 deletions
diff --git a/indoteknik_custom/models/advance_payment_request.py b/indoteknik_custom/models/advance_payment_request.py index ad97755a..56d4d24d 100644 --- a/indoteknik_custom/models/advance_payment_request.py +++ b/indoteknik_custom/models/advance_payment_request.py @@ -141,9 +141,10 @@ class AdvancePaymentRequest(models.Model): compute='_compute_settlement_name' ) - total_reimburse = fields.Monetary( + grand_total_reimburse = fields.Monetary( string='Total Reimburse', - compute='_compute_total_reimburse' + compute='_compute_grand_total_reimburse', + currency_field='currency_id' ) is_current_user_ap = fields.Boolean( @@ -158,9 +159,9 @@ class AdvancePaymentRequest(models.Model): line.is_current_user_ap = is_ap @api.depends('reimburse_line_ids.total') - def _compute_total_reimburse(self): + def _compute_grand_total_reimburse(self): for request in self: - request.total_reimburse = sum(request.reimburse_line_ids.mapped('total')) + request.grand_total_reimburse = sum(request.reimburse_line_ids.mapped('total')) def action_open_create_reimburse_cab(self): self.ensure_one() @@ -799,10 +800,12 @@ class ReimburseLine(models.Model): domain="[('id', 'in', [484, 486, 527, 529, 530, 471, 473, 492, 493, 488, 625, 528, 533, 534])]" ) description = fields.Char(string='Description', required=True, tracking=3) - distance = fields.Float(string='Jarak (km)', tracking=3) + distance_departure = fields.Float(string='Pergi (Km)', tracking=3) + distance_return = fields.Float(string='Pulang (Km)', tracking=3) quantity = fields.Float(string='Quantity', tracking=3) price = fields.Float(string='Price', tracking=3) - total = fields.Float(string='Total', tracking=3) + total = fields.Float(string='Total', tracking=3, compute='_compute_total') + # total = fields.Float(string='Total', tracking=3) currency_id = fields.Many2one(related='request_id.currency_id') is_vehicle = fields.Boolean(string='Berkendara?') @@ -834,25 +837,34 @@ class ReimburseLine(models.Model): for line in self: line.is_current_user_ap = is_ap + @api.depends('quantity', 'price', 'is_vehicle') + def _compute_total(self): + for line in self: + line.total = line.quantity * line.price - @api.onchange('is_vehicle', 'vehicle_type', 'distance') + @api.onchange('is_vehicle', 'vehicle_type', 'distance_departure', 'distance_return') def _onchange_vehicle_data(self): if not self.is_vehicle: self.vehicle_type = False - self.distance = 0 + self.distance_departure = 0 + self.distance_return = 0 self.price = 0 return + + total_distance = self.distance_departure + self.distance_return - if self.vehicle_type and self.distance > 0: + if self.vehicle_type and total_distance > 0: biaya_per_km = 0 if self.vehicle_type == 'car': biaya_per_km = 1000 # Rp 10.000 / 10 km + self.price = biaya_per_km elif self.vehicle_type == 'motor': biaya_per_km = 500 # Rp 10.000 / 20 km - self.price = self.distance * biaya_per_km - self.quantity = self.distance + self.price = biaya_per_km + self.total = total_distance * biaya_per_km + self.quantity = total_distance else: - self.price = 0 + self.total = 0 class AdvancePaymentSettlement(models.Model): _name = 'advance.payment.settlement' @@ -1218,7 +1230,7 @@ class AdvancePaymentSettlement(models.Model): # Cek sisa PUM if rec.remaining_value < 0: raise ValidationError( - "Sisa uang PUM tidak boleh kurang dari 0.\n" + "Sisa uang PUM tidak boleh kurang dari Rp 0.\n" "Jika ada penggunaan uang pribadi, maka ajukan dengan sistem reimburse." ) @@ -1317,7 +1329,7 @@ class CreateReimburseCabWizard(models.TransientModel): # Field untuk menampilkan total agar pengguna bisa konfirmasi total_reimburse = fields.Monetary( string='Total Reimburse', - related='request_id.total_reimburse', + related='request_id.grand_total_reimburse', readonly=True ) currency_id = fields.Many2one(related='request_id.currency_id', readonly=True) diff --git a/indoteknik_custom/views/advance_payment_request.xml b/indoteknik_custom/views/advance_payment_request.xml index 073fa815..b7db4e07 100644 --- a/indoteknik_custom/views/advance_payment_request.xml +++ b/indoteknik_custom/views/advance_payment_request.xml @@ -23,14 +23,14 @@ attrs="{'invisible': ['|', ('status', 'not in', ['approved']), ('status_pay_down_payment', '=', 'payment')]}"/> <button name="action_ap_only" type="object" - string="Make CAB" + string="Buat Jurnal PUM" class="btn-info" attrs="{'invisible': ['|', ('status', 'not in', ['approved']), ('is_cab_visible', '=', True)]}"/> <button name="action_open_create_reimburse_cab" type="object" string="Buat Jurnal Reimburse" class="btn-info" - /> + attrs="{'invisible': ['|', ('status', 'not in', ['approved']), ('is_cab_visible', '=', True)]}"/> <field name="status" widget="statusbar" statusbar_visible="draft,pengajuan1,pengajuan2,pengajuan3,approved" statusbar_colors='{"reject":"red"}' @@ -134,9 +134,10 @@ <field name="is_vehicle"/> <field name="vehicle_type" attrs="{'invisible': [('is_vehicle', '=', False)]}"/> <field name="description"/> - <field name="distance" attrs="{'invisible': [('is_vehicle', '=', False)]}"/> + <field name="distance_departure" attrs="{'invisible': [('is_vehicle', '=', False)]}"/> + <field name="distance_return" attrs="{'invisible': [('is_vehicle', '=', False)]}"/> <field name="quantity"/> - <field name="price"/> + <field name="price" attrs="{'readonly': [('is_vehicle', '=', True)]}" force_save ="1"/> <field name="total" readonly="1"/> <field name="currency_id" invisible="1"/> <field name="attachment_type"/> @@ -156,6 +157,12 @@ </group> </form> </field> + <group class="oe_subtotal_footer oe_right" name="reimburse_total"> + <field name="currency_id" invisible="1"/> + <field name="grand_total_reimburse" + widget="monetary" + options="{'currency_field': 'currency_id'}"/> + </group> </page> </notebook> </sheet> |
