bgpwtf/invoice: add recurrent billing tool

Change-Id: Ic3cc03d7b04304ae8c7aa76d8bb889ae8c144838
diff --git a/bgpwtf/invoice/proto/recurrent.proto b/bgpwtf/invoice/proto/recurrent.proto
new file mode 100644
index 0000000..1f4ac66
--- /dev/null
+++ b/bgpwtf/invoice/proto/recurrent.proto
@@ -0,0 +1,50 @@
+syntax = "proto3";
+package invoice;
+option go_package = "code.hackerspace.pl/hscloud/bgpwtf/invoice/proto";
+
+import "bgpwtf/invoice/proto/invoice.proto";
+
+// Subscription is the subscription to a service for which we want to generate
+// monthly (at least for now) invoices.
+message Subscription {
+    // Template is the data that will be used to emit the invoice. It will be
+    // used verbatim in a CreateInvoice request, apart from the following
+    // changes:
+    // - if 'date' is not set, the current date will be substituted instead
+    // - for every item in the invoice, any %Y and %M value in its title will
+    //   be replaced by the year and month of the billing cycle. The billing
+    //   cycle is defined in relation to the date in the Cycle enum below..
+    InvoiceData template = 1;
+
+    // Cycle defines the billing cycle policy for this subscription.
+    enum Cycle {
+        CYCLE_INVALID = 0;
+        // The subscription is billed for the month that it is invoiced for.
+        // Eg., if the invoice has a date of April 1st, April 15th or April
+        // 30th, the %M in title will be replaced with 04.
+        //
+        // This is used for subscriptions that are invoiced a month in advance,
+        // with invoices being sent out in the beginning of the month.
+        //
+        // In the future, the meaning of this enum value might change to 'bill
+        // at beginning of month/cycle', but currently we only bill once per
+        // month.
+        CYCLE_CURRENT = 1;
+        // The subscription is billed for the month from when it was invoiced.
+        // Eg., if the invoice has a date of April 1st, April 15th or April
+        // 30th, the %M in the title will be replaced with 03.
+        // This is used for subscriptions that are invoiced right after a month
+        // ends.
+        // In the future, the meaning of this enum value might change to 'bill
+        // at end of month/cycle', but currently we only bill once per month.
+        CYCLE_PREV = 2;
+    }
+    Cycle cycle = 2;
+}
+
+// Configuration is a prototext defining subscriptions. Currently it's read
+// from a file by //bgpwtf/invoice/recurrent. In The future this might be
+// broken up into a database schema.
+message Configuration {
+    repeated Subscription subscription = 1;
+}