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)
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)
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)
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)
def setUp(self): self.fy = FiscalYear(2020) self.start_date = self.fy.start.date() self.end_date = self.fy.end.date()
"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", "")
def test_next_fiscal_year(self, a: FiscalDateTime) -> None: assert a.next_fiscal_year == FiscalYear(2018)
def test_prev_fiscal_year(self, a: FiscalDateTime) -> None: assert a.prev_fiscal_year == FiscalYear(2016)
def test_out_of_range(self) -> None: with pytest.raises(ValueError): FiscalYear(0) with pytest.raises(ValueError): FiscalYear(-2017)
def e(self) -> FiscalYear: return FiscalYear(2015)
def b(self) -> FiscalYear: return FiscalYear(2017)
def a(self) -> FiscalYear: return FiscalYear(2016)