# -*- coding: utf-8 -*-

import requests
import logging
import json
from odoo import models, fields, api, _
from datetime import datetime, timedelta


_logger = logging.getLogger(__name__)


class HmsPaymentTypes(models.Model):
    _name = 'hms.payment.types'
    _description = 'Hms Payment Types'
    _rec_name = 'name'
    
    name = fields.Char(string="Name")


class HmsPayments(models.Model):
    _name = 'hms.payments'
    _description = 'Hms Payments'
    _rec_name = 'booking_id'

    booking_id = fields.Many2one(comodel_name="hms.bookings", string="Booking ID")

    hms_service_id = fields.Many2one(comodel_name="hms.services", string="Service")

    hms_payment_type_id = fields.Many2one(comodel_name="hms.payment.types", string="Payment Type")

    pending_transcation = fields.Boolean(string="Pending Transaction")

    currency_id = fields.Many2one(comodel_name="res.currency", string="Currency")
    amount = fields.Monetary(string="Amount", currency_field='currency_id')
    exchange_rate = fields.Float(string="Exchange Rate")
    notes = fields.Text(string="Notes")

    pos_terminal_code = fields.Char(string="POS Terminal Code")
    wire_transfer_code = fields.Char(string="Wire Transfer Code")

    def open_payment_record(self):
        self.ensure_one()
        return {
            'name': _('Payment'),
            'view_mode': 'form',
            'res_model': 'hms.payments',
            'type': 'ir.actions.act_window',
            'view_id': self.env.ref('bross_hms.view_hms_payments_form').id,
            'res_id': self.id,
            'target': 'new',
            'context': {
                'create': False,
                'edit': False
            }
        }