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 | |
Serge Bazanski | d9f9123 | 2020-10-30 15:17:29 +0100 | [diff] [blame] | 5 | // GTU codes as defined by JPK_V7. In context of polish VAT/tax law. |
| 6 | // Original schema: http://crd.gov.pl/wzor/2020/05/08/9393/schemat.xsd |
| 7 | // These are used to tag invoice Items. These then get coalesced when an |
| 8 | // Invoice gets created, and that set of tags (specific now to an invoice) |
| 9 | // is then submitted to accounting. |
| 10 | // Numerical values of each code correspond to its numeric name (which is |
| 11 | // enshrined in the JPK schema). |
| 12 | // For each value, we provide one of more of following comments: |
| 13 | // - PL: official polish <xsd:documentation> field from schema. |
| 14 | // - EN: non-legally binding english translation for internal documentation |
| 15 | // purposes. |
| 16 | // - COMMENT: extra comments for internal documentation purposes. |
| 17 | enum GTUCode { |
| 18 | GTU_INVALID = 0; |
| 19 | // PL: Dostawa napojów alkoholowych - alkoholu etylowego, piwa, wina, |
| 20 | // napojów fermentowanych i wyrobów pośrednich, w rozumieniu przepisów |
| 21 | // o podatku akcyzowym |
| 22 | // EN: Supply of alcoholic beverages - ethanol, beer, wine, fermented |
| 23 | // beverages and intermediate products, within the meaning of |
| 24 | // provisions on excise duty. |
| 25 | GTU_01 = 1; |
| 26 | // PL: Dostawa towarów, o których mowa w art. 103 ust. 5aa ustawy |
| 27 | // EN: Supply of goods referred to in Art. 103 paragraph 5aa of the VAT law |
| 28 | // COMMENT: liquid fuels. |
| 29 | GTU_02 = 2; |
| 30 | // PL: Dostawa oleju opałowego w rozumieniu przepisów o podatku akcyzowym |
| 31 | // oraz olejów smarowych, pozostałych olejów o kodach CN od 2710 19 71 |
| 32 | // do 2710 19 99, z wyłączeniem wyrobów o kodzie CN 2710 19 85 (oleje |
| 33 | // białe, parafina ciekła) oraz smarów plastycznych zaliczanych do kodu |
| 34 | // CN 2710 19 99, olejów smarowych o kodzie CN 2710 20 90, preparatów |
| 35 | // smarowych objętych pozycją CN 3403, z wyłączeniem smarów |
| 36 | // plastycznych objętych tą pozycją |
| 37 | // EN: Supply of fuel oil under the provisions of provisions on excise |
| 38 | // duty, and lubricating oils, other oils with CN codes from 2710 19 71 |
| 39 | // do 2710 19 99, except products with code CN 2710 19 85 (while |
| 40 | // mineral oils, liquid paraffin) and high viscosity oils classified |
| 41 | // under code CN 2710 19 199, lubricating oils with code CN 2710 20 90, |
| 42 | // lubricating products classified under code CN 3403, except high |
| 43 | // viscosity lubricants classified under this code. |
| 44 | GTU_03 = 3; |
| 45 | // PL: Dostawa wyrobów tytoniowych, suszu tytoniowego, płynu do papierosów |
| 46 | // elektronicznych i wyrobów nowatorskich, w rozumieniu przepisów o |
| 47 | // podatku akcyzowym |
| 48 | // EN: Supply of tobacco products, dried tobacco, electronic cigarette |
| 49 | // liquids and designer products, within the meaning of provisions on |
| 50 | // excise duty. |
| 51 | GTU_04 = 4; |
| 52 | // PL: Dostawa odpadów - wyłącznie określonych w poz. 79-91 załącznika nr |
| 53 | // 15 do ustawy |
| 54 | // EN: Waste supply - only as defined in annex 15 position 79-91 of the VAT |
| 55 | // law. |
| 56 | // COMMENT: non-WEEE waste, except batteries. |
| 57 | GTU_05 = 5; |
| 58 | // PL: Dostawa urządzeń elektronicznych oraz części i materiałów do nich, |
| 59 | // wyłącznie określonych w poz. 7-9, 59-63, 65, 66, 69 i 94-96 załącznika |
| 60 | // nr 15 do ustawy |
| 61 | // EN: Supply of electronic devices and components thereof, only as defined |
| 62 | // in annex 15, positions 7-9, 59-63, 65, 66, 69 and 94-96 of the VAT |
| 63 | // law. |
| 64 | // COMMENT: print cartridges, ink, plastics, processors, computers, HDDs, |
| 65 | // SSDs, mobile phones, video game consoles, photo cameras, |
| 66 | // photocopier parts, software bundles on SSDs, video on SSDs. |
| 67 | // COMMENT: tl;dr computer accessories and stuff, but not CDs/DVDs. |
| 68 | GTU_06 = 6; |
| 69 | // PL: Dostawa pojazdów oraz części samochodowych o kodach wyłącznie CN |
| 70 | // 8701 - 8708 oraz CN 8708 10 |
| 71 | // EN: Supply of vehicles and car parts only with CN codes 8701-8708 and CN |
| 72 | // 8708 10. |
| 73 | GTU_07 = 7; |
| 74 | // PL: Dostawa metali szlachetnych oraz nieszlachetnych - wyłącznie |
| 75 | // określonych w poz. 1-3 załącznika nr 12 do ustawy oraz w poz. 12-25, |
| 76 | // 33-40, 45, 46, 56 i 78 załącznika nr 15 do ustawy |
| 77 | // EN: Supply of precious and common metals - only as defined in annex 12 |
| 78 | // positions 1-3 and annex 15 positions 12-25, 33-40, 45, 46, 56, 78 of |
| 79 | // the VAT law. |
| 80 | // COMMENT: metals but also wax/stearine for sculpting, metal waste, |
| 81 | // antiques (>100Y) containing metal. |
| 82 | GTU_08 = 8; |
| 83 | // PL: Dostawa leków oraz wyrobów medycznych - produktów leczniczych, |
| 84 | // środków spożywczych specjalnego przeznaczenia żywieniowego oraz |
| 85 | // wyrobów medycznych, objętych obowiązkiem zgłoszenia, o którym mowa w |
| 86 | // art. 37av ust. 1 ustawy z dnia 6 września 2001 r. - Prawo |
| 87 | // farmaceutyczne (Dz. U. z 2019 r. poz. 499, z późn. zm.) |
| 88 | // EN: Supply of medicine and medical products - [...] |
| 89 | GTU_09 = 9; |
| 90 | // PL: Dostawa budynków, budowli i gruntów |
| 91 | // EN: Supply of buildings, structures and land. |
| 92 | GTU_10 = 10; |
| 93 | // PL: Świadczenie usług w zakresie przenoszenia uprawnień do emisji gazów |
| 94 | // cieplarnianych, o których mowa w ustawie z dnia 12 czerwca 2015 r. o |
| 95 | // systemie handlu uprawnieniami do emisji gazów cieplarnianych (Dz. U. |
| 96 | // z 2018 r. poz. 1201 i 2538 oraz z 2019 r. poz. 730, 1501 i 1532) |
| 97 | // EN: Supply of services related to transfer of greenhouse gas emission |
| 98 | // allowances, as defined in Dz. U. z 2018r. poz. 1201 i 2538 oraz z |
| 99 | // 2019r. poz. 730, 1501 i 1532. |
| 100 | GTU_11 = 11; |
| 101 | // PL: Świadczenie usług o charakterze niematerialnym - wyłącznie: |
| 102 | // doradczych, księgowych, prawnych, zarządczych, szkoleniowych, |
| 103 | // marketingowych, firm centralnych (head offices), reklamowych, |
| 104 | // badania rynku i opinii publicznej, w zakresie badań naukowych i prac |
| 105 | // rozwojowych |
| 106 | // EN: Supply of non-material services - only: consulting, accounting, |
| 107 | // legal, managerial, training, marketing, head offices, advertisement, |
| 108 | // market and public opinion study, within academic research and R&D. |
| 109 | // COMMENT: IT consulting falls under this. |
| 110 | GTU_12 = 12; |
| 111 | // PL: Świadczenie usług transportowych i gospodarki magazynowej - Sekcja H |
| 112 | // PKWiU 2015 symbol ex 49.4, ex 52.1 |
| 113 | // EN: Supply of transport and logistics services [...]. |
| 114 | GTU_13 = 13; |
| 115 | } |
| 116 | |
| 117 | // SP codes as defined by JPK_V7. In context of polish VAT/tax law. |
| 118 | // Original schema: http://crd.gov.pl/wzor/2020/05/08/9393/schemat.xsd |
| 119 | // These are used to tag invoices, and describe sale procedures regarding this |
| 120 | // invoice. |
| 121 | // Numerical values are arbitrary. |
| 122 | // For each value, we provide one of more of following comments: |
| 123 | // - PL: official polish <xsd:documentation> field from schema. |
| 124 | // - EN: non-legally binding english translation for internal documentation |
| 125 | // purposes. |
| 126 | // - COMMENT: extra comments for internal documentation purposes. |
| 127 | enum SPCode { |
| 128 | SP_INVALID = 0; |
| 129 | // PL: Dostawa w ramach sprzedaży wysyłkowej z terytorium kraju, o której |
| 130 | // mowa w art. 23 ustawy |
| 131 | // EN: Mail Order sales, as per art. 23 of the VAT law. |
| 132 | SP_SW = 1; |
| 133 | // PL: Świadczenie usług telekomunikacyjnych, nadawczych i elektronicznych, |
| 134 | // o których mowa w art. 28k ustawy |
| 135 | // EN: Supply of telecommunication, broadcast and electronic services as |
| 136 | // per artc. 28k of the VAT law. |
| 137 | // COMMENT: MOSS EU VAT sales. |
| 138 | SP_EE = 2; |
| 139 | // PL: Istniejące powiązania między nabywcą a dokonującym dostawy towarów |
| 140 | // lub usługodawcą, o których mowa w art. 32 ust. 2 pkt 1 ustawy |
| 141 | // EN: Existing connection between the buyer and supplier of goods or |
| 142 | // services, as per art. 32, par. 2 point 2 of the VAT law |
| 143 | SP_TP = 3; |
| 144 | // PL: Wewnątrzwspólnotowe nabycie towarów dokonane przez drugiego w |
| 145 | // kolejności podatnika VAT w ramach transakcji trójstronnej w |
| 146 | // procedurze uproszczonej, o której mowa w dziale XII rozdziale 8 |
| 147 | // ustawy |
| 148 | // EN: Intra-EU goods supply by the second VAT taxpayer in a tripartite |
| 149 | // simplified procedures as defined insection XII chapter 8 of the VAT |
| 150 | // law |
| 151 | SP_TT_WNT = 4; |
| 152 | // PL: Dostawa towarów poza terytorium kraju dokonana przez drugiego w |
| 153 | // kolejności podatnika VAT w ramach transakcji trójstronnej w |
| 154 | // procedurze uproszczonej, o której mowa w dziale XII rozdziale 8 |
| 155 | // ustawy |
| 156 | // EN: Foreign goods supply by the second VAT taxpayer in a tripartite |
| 157 | // simplified procedures as defined insection XII chapter 8 of the VAT |
| 158 | // law |
| 159 | SP_TT_D = 5; |
| 160 | // PL: Świadczenie usług turystyki opodatkowane na zasadach marży zgodnie z |
| 161 | // art. 119 ustawy |
| 162 | // EN: Supply of tourism services under magin tax as per art. 119 of the |
| 163 | // VAT law |
| 164 | SP_MR_T = 6; |
| 165 | // PL: Dostawa towarów używanych, dzieł sztuki, przedmiotów |
| 166 | // kolekcjonerskich i antyków, opodatkowana na zasadach marży zgodnie z |
| 167 | // art. 120 ustawy |
| 168 | // EN: Supply of used goods, art, collectibles and antiques under margin |
| 169 | // tax as per art 120 of the VAT law |
| 170 | SP_MR_UZ = 7; |
| 171 | // PL: Wewnątrzwspólnotowa dostawa towarów następująca po imporcie tych |
| 172 | // towarów w ramach procedury celnej 42 (import) |
| 173 | // EN: Intra-EU goods supply after import of these goods as part of the |
| 174 | // customs procedure 42 (import) |
| 175 | SP_I_42 = 8; |
| 176 | // PL: Wewnątrzwspólnotowa dostawa towarów następująca po imporcie tych |
| 177 | // towarów w ramach procedury celnej 63 (import) |
| 178 | // EN: Intra-EU goods supply after import of these goods as part of the |
| 179 | // customs procedure 63 (import) |
| 180 | SP_I_63 = 9; |
| 181 | // PL: Transfer bonu jednego przeznaczenia dokonany przez podatnika |
| 182 | // działającego we własnym imieniu, opodatkowany zgodnie z art. 8a ust. |
| 183 | // 1 ustawy |
| 184 | // EN: Transfer of a single-purpose voucher by a taxpayer acting on their |
| 185 | // own behalf, taxed under art. 8a paragraph 1 of the VAT law |
| 186 | SP_B_SPV = 10; |
| 187 | // PL: Dostawa towarów oraz świadczenie usług, których dotyczy bon jednego |
| 188 | // przeznaczenia na rzecz podatnika, który wyemitował bon zgodnie z |
| 189 | // art. 8a ust. 4 ustawy |
| 190 | // EN: Supply of goods and services affected by single-purpose voucher for |
| 191 | // a taxpayer, which emitted that voucher in accordance with art. 8a |
| 192 | // paragraph 4 of the VAT law |
| 193 | SP_B_SPV_DOSTAWA = 11; |
| 194 | // PL: Świadczenie usług pośrednictwa oraz innych usług dotyczących |
| 195 | // transferu bonu różnego przeznaczenia, opodatkowane zgodnie z art. 8b |
| 196 | // ust. 2 ustawy |
| 197 | // EN: Supply of intermediary services and other services relating to the |
| 198 | // transfer of multi-purpose vouchers, taxed in accordance with art. 8b |
| 199 | // paragraph 2 of the VAT law |
| 200 | SP_B_MPV_PROWIZJA = 12; |
| 201 | // PL: Transakcja objęta obowiązkiem stosowania mechanizmu podzielonej |
| 202 | // płatności |
| 203 | // EN: Transaction required to use the VAT split payment mechanism |
| 204 | SP_MPP = 13; |
| 205 | } |
| 206 | |
| 207 | |
| 208 | // VAT invoice item (ie. entry). |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 209 | message Item { |
| 210 | string title = 1; |
| 211 | uint64 count = 2; |
| 212 | uint64 unit_price = 3; |
| 213 | // in thousands of percent points |
| 214 | // (ie 23% == 23000) |
| 215 | uint64 vat = 4; |
Serge Bazanski | d9f9123 | 2020-10-30 15:17:29 +0100 | [diff] [blame] | 216 | // GTU codes for this item. |
| 217 | repeated GTUCode gtu_code = 7; |
| 218 | |
| 219 | // Denormalized fields follow. These are only present in Invoice, not |
| 220 | // InvoiceData. |
Sergiusz Bazanski | 3976e3c | 2019-05-01 15:27:49 +0200 | [diff] [blame] | 221 | uint64 total_net = 5; |
| 222 | uint64 total = 6; |
Serge Bazanski | d9f9123 | 2020-10-30 15:17:29 +0100 | [diff] [blame] | 223 | // Next tag: 8 |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 224 | } |
| 225 | |
Serge Bazanski | d9f9123 | 2020-10-30 15:17:29 +0100 | [diff] [blame] | 226 | // Point of contact for an invoice. |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 227 | message ContactPoint { |
| 228 | string medium = 1; |
| 229 | string contact = 2; |
| 230 | } |
| 231 | |
Serge Bazanski | d9f9123 | 2020-10-30 15:17:29 +0100 | [diff] [blame] | 232 | // Invoice 'intent' - ie. data given by an Invoice creator. These never change |
| 233 | // after creation. |
Sergiusz Bazanski | 3976e3c | 2019-05-01 15:27:49 +0200 | [diff] [blame] | 234 | message InvoiceData { |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 235 | repeated Item item = 1; |
| 236 | repeated string invoicer_billing = 2; |
| 237 | repeated ContactPoint invoicer_contact = 3; |
| 238 | repeated string customer_billing = 4; |
| 239 | string invoicer_vat_id = 5; |
| 240 | string invoicer_company_number = 12; |
| 241 | string customer_vat_id = 6; |
| 242 | bool reverse_vat = 7; |
| 243 | bool us_customer = 11; |
Sergiusz Bazanski | a818ef2 | 2019-06-07 10:37:22 +0200 | [diff] [blame] | 244 | // Optional, if not given the proforma will be created with the current time. |
| 245 | int64 date = 14; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 246 | int64 days_due = 8; |
| 247 | string iban = 9; |
| 248 | string swift = 10; |
Sergiusz Bazanski | c2d322c | 2019-05-01 13:14:32 +0200 | [diff] [blame] | 249 | string unit = 13; |
Serge Bazanski | d9f9123 | 2020-10-30 15:17:29 +0100 | [diff] [blame] | 250 | repeated SPCode sp_code = 15; |
| 251 | // Next tag: 16 |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 252 | } |
| 253 | |
Sergiusz Bazanski | 3976e3c | 2019-05-01 15:27:49 +0200 | [diff] [blame] | 254 | message Invoice { |
| 255 | // Original invoice parameters/data. |
| 256 | InvoiceData data = 1; |
| 257 | enum State { |
| 258 | STATE_INVALID = 0; |
| 259 | STATE_PROFORMA = 1; |
| 260 | STATE_SEALED = 2; |
| 261 | }; |
| 262 | State state = 2; |
| 263 | string uid = 9; |
| 264 | // If sealed, otherwise 'proforma'. |
| 265 | string final_uid = 3; |
| 266 | int64 date = 4; |
| 267 | int64 due_date = 5; |
| 268 | // Denormalized fields follow. |
| 269 | uint64 total_net = 6; |
| 270 | uint64 total = 7; |
| 271 | string unit = 8; |
Serge Bazanski | d9f9123 | 2020-10-30 15:17:29 +0100 | [diff] [blame] | 272 | repeated GTUCode gtu_codes = 10; |
| 273 | // Next tag: 11; |
Sergiusz Bazanski | 3976e3c | 2019-05-01 15:27:49 +0200 | [diff] [blame] | 274 | } |
| 275 | |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 276 | message CreateInvoiceRequest { |
Sergiusz Bazanski | 3976e3c | 2019-05-01 15:27:49 +0200 | [diff] [blame] | 277 | InvoiceData invoice_data = 1; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | message CreateInvoiceResponse { |
| 281 | // Unique invoice ID |
| 282 | string uid = 1; |
| 283 | } |
| 284 | |
| 285 | message GetInvoiceRequest { |
| 286 | string uid = 1; |
| 287 | } |
| 288 | |
| 289 | message GetInvoiceResponse { |
| 290 | Invoice invoice = 1; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 291 | } |
| 292 | |
| 293 | message RenderInvoiceRequest { |
| 294 | string uid = 1; |
Sergiusz Bazanski | a818ef2 | 2019-06-07 10:37:22 +0200 | [diff] [blame] | 295 | string language = 2; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | message RenderInvoiceResponse { |
| 299 | bytes data = 1; |
| 300 | } |
| 301 | |
| 302 | message SealInvoiceRequest { |
| 303 | string uid = 1; |
Sergiusz Bazanski | a818ef2 | 2019-06-07 10:37:22 +0200 | [diff] [blame] | 304 | enum DateSource { |
| 305 | DATE_SOURCE_NOW = 0; |
| 306 | DATE_SOURCE_PROFORMA = 1; |
| 307 | } |
| 308 | DateSource date_source = 2; |
| 309 | string language = 3; |
Sergiusz Bazanski | fb18c99 | 2019-05-01 12:27:03 +0200 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | message SealInvoiceResponse { |
| 313 | } |
| 314 | |
| 315 | service Invoicer { |
| 316 | rpc CreateInvoice(CreateInvoiceRequest) returns (CreateInvoiceResponse); |
| 317 | rpc GetInvoice(GetInvoiceRequest) returns (GetInvoiceResponse); |
| 318 | rpc RenderInvoice(RenderInvoiceRequest) returns (stream RenderInvoiceResponse); |
| 319 | rpc SealInvoice(SealInvoiceRequest) returns (SealInvoiceResponse); |
| 320 | } |