| 504 | } |
| 505 | |
| 506 | static void cointrack_entry(const tal_t *ctx, FILE *csvf, struct income_event *ev) |
| 507 | { |
| 508 | /* Date mm/dd/yyyy HH:MM:SS UTC */ |
| 509 | time_t tv; |
| 510 | tv = ev->timestamp; |
| 511 | char timebuf[sizeof("mm/dd/yyyy HH:MM:SS")]; |
| 512 | |
| 513 | /* Cointrack counts invoice fee events inline */ |
| 514 | if (streq(ev->tag, account_entry_tag_str(INVOICEFEE))) |
| 515 | return; |
| 516 | |
| 517 | fprintf(csvf, "\n"); |
| 518 | |
| 519 | strftime(timebuf, sizeof(timebuf), "%m/%d/%Y %T", gmtime(&tv)); |
| 520 | fprintf(csvf, "%s", timebuf); |
| 521 | fprintf(csvf, ","); |
| 522 | |
| 523 | /* Received Quantity + Received Currency */ |
| 524 | if (!amount_msat_zero(ev->credit)) { |
| 525 | fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->credit, false)); |
| 526 | fprintf(csvf, ","); |
| 527 | fprintf(csvf, "%s", convert_asset_type(ev)); |
| 528 | } else |
| 529 | fprintf(csvf, ","); |
| 530 | |
| 531 | fprintf(csvf, ","); |
| 532 | |
| 533 | /* "Sent Quantity,Sent Currency," */ |
| 534 | if (!amount_msat_zero(ev->debit)) { |
| 535 | fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->debit, false)); |
| 536 | fprintf(csvf, ","); |
| 537 | fprintf(csvf, "%s", convert_asset_type(ev)); |
| 538 | } else |
| 539 | fprintf(csvf, ","); |
| 540 | |
| 541 | fprintf(csvf, ","); |
| 542 | |
| 543 | /* "Fee Amount,Fee Currency," */ |
| 544 | if (!amount_msat_zero(ev->fees) |
| 545 | && streq(ev->tag, mvt_tag_str(INVOICE))) { |
| 546 | fprintf(csvf, "%s", fmt_amount_msat_btc(ctx, ev->fees, false)); |
| 547 | fprintf(csvf, ","); |
| 548 | fprintf(csvf, "%s", convert_asset_type(ev)); |
| 549 | } else |
| 550 | fprintf(csvf, ","); |
| 551 | |
| 552 | fprintf(csvf, ","); |
| 553 | |
| 554 | /* Tag */ |
| 555 | fprintf(csvf, "%s", income_event_cointrack_type(ev)); |
| 556 | fprintf(csvf, ","); |
| 557 | |
| 558 | /* Account */ |
| 559 | fprintf(csvf, "%s", ev->acct_name); |
| 560 | } |
| 561 | |
| 562 | static void koinly_header(FILE *csvf) |
| 563 | { |
nothing calls this directly
no test coverage detected