pynomaina API Documentation
date_utils
Created on 2024-10-02
@author: wf
DateUtils
date utilities
Source code in nomina/date_utils.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
parse_date(date_str, date_formats=None)
classmethod
Parse the given date string using the provided formats.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date_str |
str
|
The date string to parse. |
required |
date_formats |
List[str]
|
List of date formats to try. If None, uses a default list of formats. |
None
|
Returns:
Type | Description |
---|---|
Optional[str]
|
Optional[str]: The parsed date in ISO format (YYYY-MM-DD) or None if parsing fails. |
Source code in nomina/date_utils.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
split_date_range(start_date, end_date, num_ranges)
classmethod
Splits a date range into a predefined number of sub-ranges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_date |
str
|
The start date in "YYYY-MM-DD" format. |
required |
end_date |
str
|
The end date in "YYYY-MM-DD" format. |
required |
num_ranges |
int
|
The number of ranges to split into. |
required |
Returns:
Type | Description |
---|---|
List[Tuple[str, str]]
|
List[Tuple[str, str]]: A list of tuples representing the sub-ranges. |
Source code in nomina/date_utils.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
gnucash
Created on 2024-10-02
@author: wf
GnuCashXml
GnuCash XML reader/writer
Source code in nomina/gnucash.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
|
__init__(indent=' ')
constructor using two space indentation
Source code in nomina/gnucash.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
|
write_gnucash_xml(gnucash_data, output_file)
Serialize the GnuCash data object to an XML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gnucash_data |
GnuCashXml
|
The GnuCash data object to serialize. |
required |
output_file |
str
|
The file path where the XML will be written. |
required |
Source code in nomina/gnucash.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
|
xml_format(xml_string)
adapt the format of the xml_string to gnu cash conventions
Source code in nomina/gnucash.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
|
TsDate
dataclass
Source code in nomina/gnucash.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
__post_init__()
format date to 1970-01-01 00:00:00 +0000
Source code in nomina/gnucash.py
64 65 66 67 68 69 |
|
ledger
Created on 04.10.2024
@author: wf
Account
Represents a ledger account.
Source code in nomina/ledger.py
15 16 17 18 19 20 21 22 23 24 25 26 |
|
Book
Represents a ledger book containing accounts and transactions.
Source code in nomina/ledger.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
__post_init__()
post construct actions
Source code in nomina/ledger.py
75 76 77 78 |
|
add_account(account)
add the given account
Source code in nomina/ledger.py
172 173 174 175 176 177 |
|
create_account(name, account_type='EXPENSE', parent_account_id=None)
Create a ledger account with the given parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the account. |
required |
account_type |
str
|
The type of the account. Defaults to "EXPENSE". |
'EXPENSE'
|
parent_account_id |
Optional[str]
|
The id of the parent account, if any. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Account |
Account
|
A new Account object. |
Source code in nomina/ledger.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
filter(start_date=None, end_date=None)
Filter the transactions based on the given date range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_date |
str
|
The start date in 'YYYY-MM-DD' format. |
None
|
end_date |
str
|
The end date in 'YYYY-MM-DD' format. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Book |
Book
|
A new Book object with filtered transactions. |
Source code in nomina/ledger.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
get_stats()
Get statistics about the Book.
Returns:
Name | Type | Description |
---|---|---|
Stats |
Stats
|
An object containing various statistics about the Book. |
Source code in nomina/ledger.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
lookup_account(account_id)
Get the account for the given account id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
account_id(str) |
The id of the account to look up. |
required |
Returns:
Type | Description |
---|---|
Optional[Account]
|
Optional[Account]: The found account or None if not found. |
Source code in nomina/ledger.py
179 180 181 182 183 184 185 186 187 188 189 |
|
Split
Represents a split in a transaction.
Source code in nomina/ledger.py
29 30 31 32 33 34 35 36 37 38 |
|
Transaction
Represents a transaction in the ledger.
Source code in nomina/ledger.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
total_amount()
Calculates the total amount of the transaction. Returns: float: The sum of all split amounts.
Source code in nomina/ledger.py
53 54 55 56 57 58 59 |
|
nomina_cmd
Created on 2024-10-06
@author: wf
NominaCmd
Bases: WebserverCmd
command line handling for nomina
Source code in nomina/nomina_cmd.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
__init__()
constructor
Source code in nomina/nomina_cmd.py
20 21 22 23 24 25 26 |
|
getArgParser(description, version_msg)
override the default argparser call
Source code in nomina/nomina_cmd.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
main(argv=None)
main call
Source code in nomina/nomina_cmd.py
48 49 50 51 52 53 54 |
|
qif
Created on 2024-10-01
Quicken Interchange Format (QIF) Parser see https://en.wikipedia.org/wiki/Quicken_Interchange_Format
@author: wf
Category
dataclass
Bases: ParseRecord
a QIF tag (Class or Category)
Source code in nomina/qif.py
71 72 73 74 75 76 77 78 |
|
QifClass
dataclass
Bases: ParseRecord
a QIF tag (Class or Category)
Source code in nomina/qif.py
81 82 83 84 85 86 87 88 |
|
SimpleQifParser
a QIF parser
Source code in nomina/qif.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 |
|
generate_error_report(max_errors_per_type=10)
Generate a detailed error report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
max_errors_per_type |
int
|
Maximum number of errors to show for each error type. |
10
|
Returns:
Name | Type | Description |
---|---|---|
str |
A formatted error report. |
Source code in nomina/qif.py
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
|
get_lod()
Get a list of dictionaries representing all transactions.
Returns:
Type | Description |
---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: A list of dictionaries, each representing a transaction. |
Source code in nomina/qif.py
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
parse(lines, verbose=False, debug=False)
parse the given list of lines
Source code in nomina/qif.py
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
|
parse_file(qif_file, encoding='iso-8859-1', verbose=False, debug=False)
parse a qif file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
qif_file |
str
|
Path to the input QIF file. |
required |
encoding |
str
|
File encoding. Defaults to 'iso-8859-1'. |
'iso-8859-1'
|
verbose |
bool
|
if True give verbose output |
False
|
debug |
bool
|
if True show debug output |
False
|
Source code in nomina/qif.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
|
transaction_summary(transaction)
Helper function to provide a summary of a transaction.
Source code in nomina/qif.py
544 545 546 547 548 549 550 |
|
tx_for_record(t)
convert the transaction record
Source code in nomina/qif.py
388 389 390 391 392 393 394 395 396 397 398 399 |
|
Transaction
dataclass
Bases: ParseRecord
a single transaction
Source code in nomina/qif.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
normalize()
Normalize the transaction data, converting string amounts to floats.
Source code in nomina/qif.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
total_split_amount()
Calculate the total amount for split transactions.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The sum of all split amounts. |
Source code in nomina/qif.py
164 165 166 167 168 169 170 171 |
|
stats
Created on 2024-10-06
@author: wf
Stats
Ledger statistics
Source code in nomina/stats.py
9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
version
Created on 2024-10-06 @author: wf
Version
dataclass
Bases: object
Version handling for MoneyBrowser
Source code in nomina/version.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
webserver
Created on 2024-10-06
@author: wf
NominaSolution
Bases: InputWebSolution
the Nomina solution
Source code in nomina/webserver.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
__init__(webserver, client)
Initialize the solution
Calls the constructor of the base solution Args: webserver (NiceScadWebServer): The webserver instance associated with this context. client (Client): The client instance this context is associated with.
Source code in nomina/webserver.py
58 59 60 61 62 63 64 65 66 67 |
|
NominaWebServer
Bases: InputWebserver
Nomina Webserver
Source code in nomina/webserver.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
__init__()
Constructs all the necessary attributes for the WebServer object.
Source code in nomina/webserver.py
30 31 32 |
|