def test_gorr_royalty(self):

        pr = ProcessRoyalties()
        leaserm = DataStructure()
        calc = DataStructure()
        monthly = DataStructure()
        well_lease_link = DataStructure()
        rtp_info = DataStructure()

        monthly.ProdVol = 100.0
        monthly.ProdHours = 10.0
        monthly.TransRate = 0.1234
        leaserm.TransDeducted = "All"
        leaserm.Gorr = "fixed,0,.02"

        well_lease_link.PEFNInterest = 1.0

        rtp_info.Percent = 100.0

        calc.RoyaltyPrice = 200.0
        calc.TransGorralue = 0.0
        calc.GorrRoyaltyValue = 0.0
        calc.TransGorrValue = 0.0

        pr.calc_gorr(leaserm, calc, monthly, well_lease_link, rtp_info)
        self.assertEqual(400.0, calc.GorrRoyaltyValue)
        self.assertEqual(0.25, calc.TransGorrValue)

        monthly.ProdVol = 100.0
        rtp_info.Percent = 50.0
        calc.TransGorrValue = 0.0
        pr.calc_gorr(leaserm, calc, monthly, well_lease_link, rtp_info)
        self.assertEqual(200.0, calc.GorrRoyaltyValue)
        self.assertEqual(0.12, calc.TransGorrValue)
    def test_calc_sask_oil_prov_crown_deductions(self):

        pr = ProcessRoyalties()
        calc = DataStructure()
        calc.TransBaseValue = 0
        calc.BaseRoyaltyRate = 0.1

        m = DataStructure()
        m.TransRate = 0.123
        m.ProdVol = 150.0

        lease_royalty_master = DataStructure()
        lease_royalty_master.TransDeducted = "All"
        lease_royalty_master.CrownMultiplier = 1.0

        fn_interest = 1.0
        rp_interest = 100.0

        # Note: this is a round even situation... it's questionable
        self.assertEqual(
            1.84, pr.calc_sask_oil_prov_crown_deductions(m, fn_interest, rp_interest, lease_royalty_master, calc)
        )

        lease_royalty_master.CrownMultiplier = 0.9

        fn_interest = 0.8
        rp_interest = 90.0

        self.assertEqual(
            1.2, pr.calc_sask_oil_prov_crown_deductions(m, fn_interest, rp_interest, lease_royalty_master, calc)
        )
    def test_calc_royalties(self):
        dbu = DatabaseUtilities()
        dbu.delete_all_tables()
        dbu.create_some_test_econdata()

        pr = ProcessRoyalties()
        well = DataStructure()
        royalty = DataStructure()
        calc = DataStructure()
        monthly = DataStructure()
        well_lease_link = DataStructure()
        rtp_info = DataStructure()

        monthly.Product = "OIL"
        monthly.ProdMonth = 201501
        monthly.ProdVol = 100
        monthly.ProdHours = 744
        monthly.SalesPrice = 210.0
        royalty.RoyaltyScheme = "SKProvCrownVar"
        royalty.OverrideRoyaltyClassification = None
        royalty.ValuationMethod = "ActSales"
        royalty.CrownModifier = None
        royalty.MinRoyaltyRate = None
        royalty.CrownMultiplier = 1.0
        royalty.MinRoyaltyDollar = None
        royalty.TransDeducted = None
        well.CommencementDate = date(2015, 1, 22)
        well.RoyaltyClassification = "Old Oil"
        well.Classification = "Other"
        well.SRC = 0.0
        well_lease_link.PEFNInterest = 1.0
        rtp_info.Percent = 100.0
        calc.SuppRoyaltyValue = 0.0
        calc.GorrRoyaltyValue = 0.0
        calc.TransGorrValue = 0.0

        pr.calc_royalties(well, royalty, calc, monthly, well_lease_link, rtp_info)

        royalty.RoyaltyScheme = "IOGR1995"
        pr.calc_royalties(well, royalty, calc, monthly, well_lease_link, rtp_info)

        royalty.RoyaltyScheme = "IOGR1995,GORR"
        royalty.Gorr = "fixed,0,.02"
        pr.calc_royalties(well, royalty, calc, monthly, well_lease_link, rtp_info)