{"action":"opened","issue":{"url":"https://api.github.com/repos/killbill/killbill/issues/321","labels_url":"https://api.github.com/repos/killbill/killbill/issues/321/labels{/name}","comments_url":"https://api.github.com/repos/killbill/killbill/issues/321/comments","events_url":"https://api.github.com/repos/killbill/killbill/issues/321/events","html_url":"https://github.com/killbill/killbill/issues/321","id":76488790,"number":321,"title":"Implement recurring billing mode IN_ADVANCE","user":{"login":"sbrossie","id":246910,"avatar_url":"https://avatars.githubusercontent.com/u/246910?v=3","gravatar_id":"","url":"https://api.github.com/users/sbrossie","html_url":"https://github.com/sbrossie","followers_url":"https://api.github.com/users/sbrossie/followers","following_url":"https://api.github.com/users/sbrossie/following{/other_user}","gists_url":"https://api.github.com/users/sbrossie/gists{/gist_id}","starred_url":"https://api.github.com/users/sbrossie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbrossie/subscriptions","organizations_url":"https://api.github.com/users/sbrossie/orgs","repos_url":"https://api.github.com/users/sbrossie/repos","events_url":"https://api.github.com/users/sbrossie/events{/privacy}","received_events_url":"https://api.github.com/users/sbrossie/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/killbill/killbill/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/killbill/killbill/labels/INVOICE","name":"INVOICE","color":"0b02e1"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-14T20:58:28Z","updated_at":"2015-05-14T20:58:28Z","closed_at":null,"body":"(See thread: https://groups.google.com/forum/#!msg/killbilling-users/kTKAX38bh10/3a42O50j_k0J)\r\n\r\nThe main differences, between the IN_ADVANCE and IN_ARREAR are:\r\n* The targetDate of the invoice will be used to compute the past invoice (IN_ARREAR) or the upcoming invoice (IN_ADVANCE). Most of the code that we wrote (BillingIntervalDetail, ...) to deal with the period, targetDate, ... should be reusable . You should not have to write too much code, or then you are probably on the wrong path.\r\n* For IN_ARREAR, the logic should be simpler, because there is no 'REPAIR' since you have all the information at the time you create the invoice, so this is simpler.\r\n\r\nIn file https://github.com/killbill/killbill/blob/master/invoice/src/main/java/org/killbill/billing/invoice/generator/DefaultInvoiceGenerator.java:\r\n* The 'generateInvoice' method will be modified to NOT call 'generateInAdvanceInvoiceItems', but instead call a more generic method that will look at the current value of the 'recurringBillingMode' in your catalog. Note that we have some abstraction for the billingMode , see 'instantiateBillingMode', but this is not plugged at the right place-- some old implementation. So you will have to reshuffle things a bit.\r\n* The usage sections also have a 'billingMode', so if you want to also do usage InArrear, you will also have to look at what we do in 'generateUsageInvoiceItems. I am unclear if this is something you are interested in.\r\n"}}