1# pylint: disable=all
2# flake8: noqa
3import datetime
4import enum
5from typing import Any
6from typing import Dict
7from typing import FrozenSet
8from typing import List
9from typing import NamedTuple
10from typing import Optional
11from typing import Set
12from typing import Tuple
13from typing import Type
14from typing import Union
15
16from beancount.core.amount import Amount
17from beancount.core.number import Decimal
18from beancount.core.number import MISSING
19from beancount.core.position import Cost
20from beancount.core.position import CostSpec
21
22Account = str
23Currency = str
24Flag = str
25Meta = Dict[str, Any]
26Tags = Union[Set[str], FrozenSet[str]]
27Links = Tags
28
29EMPTY_SET: Any
30
31class Booking(enum.Enum):
32    STRICT: str = ...
33    NONE: str = ...
34    AVERAGE: str = ...
35    FIFO: str = ...
36    LIFO: str = ...
37
38class Close(NamedTuple):
39    meta: Meta
40    date: datetime.date
41    account: Account
42
43class Commodity(NamedTuple):
44    meta: Meta
45    date: datetime.date
46    currency: Currency
47
48class Open(NamedTuple):
49    meta: Meta
50    date: datetime.date
51    account: Account
52    currencies: List[Currency]
53    booking: Booking
54
55class Pad(NamedTuple):
56    meta: Meta
57    date: datetime.date
58    account: Account
59    source_account: Account
60
61class Balance(NamedTuple):
62    meta: Meta
63    date: datetime.date
64    account: Account
65    amount: Amount
66    tolerance: Optional[Decimal]
67    diff_amount: Optional[Decimal]
68
69class Posting(NamedTuple):
70    account: Account
71    units: Union[Amount, Type[MISSING]]
72    cost: Optional[Union[Cost, CostSpec]]
73    price: Optional[Amount]
74    flag: Optional[Flag]
75    meta: Optional[Meta]
76
77class Transaction(NamedTuple):
78    meta: Meta
79    date: datetime.date
80    flag: Flag
81    payee: Optional[str]
82    narration: str
83    tags: Tags
84    links: Links
85    postings: List[Posting]
86
87class TxnPosting(NamedTuple):
88    txn: Transaction
89    posting: Posting
90
91class Note(NamedTuple):
92    meta: Meta
93    date: datetime.date
94    account: Account
95    comment: str
96
97class Event(NamedTuple):
98    meta: Meta
99    date: datetime.date
100    type: str
101    description: str
102
103class Query(NamedTuple):
104    meta: Meta
105    date: datetime.date
106    name: str
107    query_string: str
108
109class Price(NamedTuple):
110    meta: Meta
111    date: datetime.date
112    currency: Currency
113    amount: Amount
114
115class Document(NamedTuple):
116    meta: Meta
117    date: datetime.date
118    account: Account
119    filename: str
120    tags: Optional[Tags]
121    links: Optional[Links]
122
123class Custom(NamedTuple):
124    meta: Meta
125    date: datetime.date
126    type: str
127    values: List
128
129# ALL_DIRECTIVES: Any
130Directive = Union[
131    Open,
132    Close,
133    Commodity,
134    Pad,
135    Balance,
136    Transaction,
137    Note,
138    Event,
139    Query,
140    Price,
141    Document,
142    Custom,
143]
144Entries = List[Directive]
145
146def new_metadata(filename: Any, lineno: Any, kvlist: Optional[Any] = ...): ...
147def create_simple_posting(
148    entry: Any, account: Any, number: Any, currency: Any
149): ...
150def create_simple_posting_with_cost(
151    entry: Any,
152    account: Any,
153    number: Any,
154    currency: Any,
155    cost_number: Any,
156    cost_currency: Any,
157): ...
158
159NoneType: Any
160
161def sanity_check_types(
162    entry: Any, allow_none_for_tags_and_links: bool = ...
163) -> None: ...
164def posting_has_conversion(posting: Any): ...
165def transaction_has_conversion(transaction: Any): ...
166def get_entry(posting_or_entry: Any): ...
167
168SORT_ORDER: Any
169
170def entry_sortkey(entry: Any): ...
171def sorted(entries: Any): ...
172def posting_sortkey(entry: Any): ...
173def filter_txns(entries: Any) -> None: ...
174def has_entry_account_component(entry: Any, component: Any): ...
175def find_closest(entries: Any, filename: Any, lineno: Any): ...
176def remove_account_postings(account: Any, entries: Any): ...
177def iter_entry_dates(entries: Any, date_begin: Any, date_end: Any): ...
178