Ejemplo n.º 1
0
    def test_current(self, monkeypatch: MonkeyPatch) -> None:
        def today() -> FiscalDate:
            return FiscalDate(2016, 10, 1)

        monkeypatch.setattr(FiscalDate, "today", today)
        current = FiscalYear.current()
        assert current == FiscalYear(2017)
Ejemplo n.º 2
0
    def test_end(self, c: FiscalDay) -> None:
        assert c.end == FiscalYear(c.fiscal_year).end

        with fiscalyear.fiscal_calendar(*US_FEDERAL):
            assert c.end == datetime.datetime(2016, 9, 30, 23, 59, 59)

        with fiscalyear.fiscal_calendar(*UK_PERSONAL):
            assert c.end == datetime.datetime(2017, 4, 5, 23, 59, 59)
Ejemplo n.º 3
0
    def test_start(self, a: FiscalDay, c: FiscalDay) -> None:
        assert a.start == FiscalYear(a.fiscal_year).start
        assert c.start == FiscalDateTime(2016, 9, 30, 0, 0, 0)

        with fiscalyear.fiscal_calendar(*US_FEDERAL):
            assert a.start == datetime.datetime(2015, 10, 1, 0, 0, 0)

        with fiscalyear.fiscal_calendar(*UK_PERSONAL):
            assert a.start == datetime.datetime(2016, 4, 6, 0, 0, 0)
Ejemplo n.º 4
0
    def test_contains(self, a: FiscalDay, b: FiscalDay, d: FiscalDay) -> None:
        assert b in b
        assert a not in d

        assert FiscalDateTime(2015, 10, 1, 0, 0, 0) in a
        assert datetime.datetime(2015, 10, 1, 0, 0, 0) in a
        assert FiscalDate(2015, 10, 1) in a
        assert datetime.date(2015, 10, 1) in a

        assert b in FiscalMonth(2016, 1)
        assert b in FiscalQuarter(2016, 1)
        assert b in FiscalYear(2016)
Ejemplo n.º 5
0
 def setUp(self):
     self.fy = FiscalYear(2020)
     self.start_date = self.fy.start.date()
     self.end_date = self.fy.end.date()
Ejemplo n.º 6
0
                "ID": "<your PayPal client ID here>",
                "Secret": "<your PayPal secret here>"
            }))

    print(
        "No PayPal SDK credentials available. Please add credentials details to {cred_file}",
        file=sys.stderr)

else:
    # Creating an environment
    environment = LiveEnvironment(client_id=CREDS["ID"],
                                  client_secret=CREDS["Secret"])
    client = PayPalHttpClient(environment)

    setup_fiscal_calendar(start_month=7)
    dt_from = FiscalYear(FiscalDateTime.now().fiscal_year).start.astimezone(
        tz.tzlocal())
    dt_to = FiscalDateTime.now().astimezone(tz.tzlocal())

    request = TransactionRequest(dt_from, dt_to)

    transactions = request.execute(client)

    header = [
        "Date", "Transaction Commodity", "Deposit", "Price", "Quantity",
        "Balance", "Num", "Description", "Notes", "Partner", "Transfer Account"
    ]
    print(",".join(header))

    for t in transactions:  #response.result.transaction_details:
        id = t.transaction_info.transaction_id  # @ReservedAssignment
        note = getattr(t.transaction_info, "transaction_note", "")
Ejemplo n.º 7
0
 def test_next_fiscal_year(self, a: FiscalDateTime) -> None:
     assert a.next_fiscal_year == FiscalYear(2018)
Ejemplo n.º 8
0
 def test_prev_fiscal_year(self, a: FiscalDateTime) -> None:
     assert a.prev_fiscal_year == FiscalYear(2016)
Ejemplo n.º 9
0
    def test_out_of_range(self) -> None:
        with pytest.raises(ValueError):
            FiscalYear(0)

        with pytest.raises(ValueError):
            FiscalYear(-2017)
Ejemplo n.º 10
0
 def e(self) -> FiscalYear:
     return FiscalYear(2015)
Ejemplo n.º 11
0
 def b(self) -> FiscalYear:
     return FiscalYear(2017)
Ejemplo n.º 12
0
 def a(self) -> FiscalYear:
     return FiscalYear(2016)