Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 1 | syntax = "proto3"; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 2 | package invoice; |
Sergiusz Bazanski | 1446e98 | 2019-07-21 16:04:23 +0200 | [diff] [blame] | 3 | option go_package = "code.hackerspace.pl/hscloud/bgpwtf/invoice/proto"; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 4 | |
| 5 | message Item { |
| 6 | string title = 1; |
| 7 | uint64 count = 2; |
| 8 | uint64 unit_price = 3; |
| 9 | // in thousands of percent points |
| 10 | // (ie 23% == 23000) |
| 11 | uint64 vat = 4; |
Sergiusz Bazanski | 3976e3c | 2019-05-01 15:27:49 +0200 | [diff] [blame] | 12 | // Denormalized fields follow. |
| 13 | uint64 total_net = 5; |
| 14 | uint64 total = 6; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | message ContactPoint { |
| 18 | string medium = 1; |
| 19 | string contact = 2; |
| 20 | } |
| 21 | |
Sergiusz Bazanski | 3976e3c | 2019-05-01 15:27:49 +0200 | [diff] [blame] | 22 | message InvoiceData { |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 23 | repeated Item item = 1; |
| 24 | repeated string invoicer_billing = 2; |
| 25 | repeated ContactPoint invoicer_contact = 3; |
| 26 | repeated string customer_billing = 4; |
| 27 | string invoicer_vat_id = 5; |
| 28 | string invoicer_company_number = 12; |
| 29 | string customer_vat_id = 6; |
| 30 | bool reverse_vat = 7; |
| 31 | bool us_customer = 11; |
Sergiusz Bazanski | a818ef2 | 2019-06-07 10:37:22 +0200 | [diff] [blame] | 32 | // Optional, if not given the proforma will be created with the current time. |
| 33 | int64 date = 14; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 34 | int64 days_due = 8; |
| 35 | string iban = 9; |
| 36 | string swift = 10; |
Sergiusz Bazanski | c2d322c | 2019-05-01 13:14:32 +0200 | [diff] [blame] | 37 | string unit = 13; |
Sergiusz Bazanski | a818ef2 | 2019-06-07 10:37:22 +0200 | [diff] [blame] | 38 | // Next tag: 15 |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 39 | } |
| 40 | |
Sergiusz Bazanski | 3976e3c | 2019-05-01 15:27:49 +0200 | [diff] [blame] | 41 | message Invoice { |
| 42 | // Original invoice parameters/data. |
| 43 | InvoiceData data = 1; |
| 44 | enum State { |
| 45 | STATE_INVALID = 0; |
| 46 | STATE_PROFORMA = 1; |
| 47 | STATE_SEALED = 2; |
| 48 | }; |
| 49 | State state = 2; |
| 50 | string uid = 9; |
| 51 | // If sealed, otherwise 'proforma'. |
| 52 | string final_uid = 3; |
| 53 | int64 date = 4; |
| 54 | int64 due_date = 5; |
| 55 | // Denormalized fields follow. |
| 56 | uint64 total_net = 6; |
| 57 | uint64 total = 7; |
| 58 | string unit = 8; |
| 59 | } |
| 60 | |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 61 | message CreateInvoiceRequest { |
Sergiusz Bazanski | 3976e3c | 2019-05-01 15:27:49 +0200 | [diff] [blame] | 62 | InvoiceData invoice_data = 1; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | message CreateInvoiceResponse { |
| 66 | // Unique invoice ID |
| 67 | string uid = 1; |
| 68 | } |
| 69 | |
| 70 | message GetInvoiceRequest { |
| 71 | string uid = 1; |
| 72 | } |
| 73 | |
| 74 | message GetInvoiceResponse { |
| 75 | Invoice invoice = 1; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | message RenderInvoiceRequest { |
| 79 | string uid = 1; |
Sergiusz Bazanski | a818ef2 | 2019-06-07 10:37:22 +0200 | [diff] [blame] | 80 | string language = 2; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | message RenderInvoiceResponse { |
| 84 | bytes data = 1; |
| 85 | } |
| 86 | |
| 87 | message SealInvoiceRequest { |
| 88 | string uid = 1; |
Sergiusz Bazanski | a818ef2 | 2019-06-07 10:37:22 +0200 | [diff] [blame] | 89 | enum DateSource { |
| 90 | DATE_SOURCE_NOW = 0; |
| 91 | DATE_SOURCE_PROFORMA = 1; |
| 92 | } |
| 93 | DateSource date_source = 2; |
| 94 | string language = 3; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | message SealInvoiceResponse { |
| 98 | } |
| 99 | |
| 100 | service Invoicer { |
| 101 | rpc CreateInvoice(CreateInvoiceRequest) returns (CreateInvoiceResponse); |
| 102 | rpc GetInvoice(GetInvoiceRequest) returns (GetInvoiceResponse); |
| 103 | rpc RenderInvoice(RenderInvoiceRequest) returns (stream RenderInvoiceResponse); |
| 104 | rpc SealInvoice(SealInvoiceRequest) returns (SealInvoiceResponse); |
| 105 | } |