Skip to content

Instantly share code, notes, and snippets.

@stan229
Created October 28, 2011 15:31
Show Gist options
  • Save stan229/1322546 to your computer and use it in GitHub Desktop.
Save stan229/1322546 to your computer and use it in GitHub Desktop.
def updateCompanySubscription(companyId,duration) {
if(duration <= 0) {
return deactivateCompany(companyId)
} else if(duration > 0) {
def company = Company.get(companyId)
company.isActive = true
def today = new Date()
if(company.endDate < today ) {
company.startDate = today
company.endDate = today
}
use(TimeCategory) {
company.endDate += duration.months
}
company.isActive = true
company.save()
return company
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment