Skip to content

Commit

Permalink
Set up Server Name
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Stalka committed Mar 2, 2017
1 parent e002935 commit 31b4383
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/classes/RenewalSubscriptionsBatch.cls
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public without sharing class RenewalSubscriptionsBatch implements Database.Batch
public List<Accounting_Subscription__c> getFutureSubscriptions() {
return [SELECT Id, Accounting_subscriber_domain__r.Name FROM Accounting_Subscription__c
WHERE Accounting_subscriber_domain__r.Name != '' AND is_active__c = true AND is_trial__c = false
AND date_end__c != null AND date_end__c >: this.currentDate.addDays(60)];
AND date_end__c != null AND date_end__c >: this.currentDate.addDays(60) AND Server_Name__c = 'CommCareHQ'];
}

/**
Expand All @@ -235,7 +235,7 @@ public without sharing class RenewalSubscriptionsBatch implements Database.Batch
Accounting_subscriber_domain__r.cpAllWebUsers__c, Software_Plan_Edition__c, Renewal_Opportunity_created__c FROM Accounting_Subscription__c
WHERE Accounting_subscriber_domain__r.Name != '' AND Accounting_subscriber_domain__r.Opportunity__c = '' AND date_end__c != null AND date_end__c <=: this.currentDate.addDays(60)
AND date_end__c >=: this.currentDate AND Accounting_subscriber_domain__r.Name NOT IN: domainsWithFutureSubscriptions AND is_active__c = true
AND is_trial__c = false ORDER BY date_end__c DESC];
AND is_trial__c = false AND Server_Name__c = 'CommCareHQ' ORDER BY date_end__c DESC];
}

private void processProductsErrors(List<Database.SaveResult> insertResults, List<Opportunity> newOpps) {
Expand Down
44 changes: 22 additions & 22 deletions src/classes/RenewalSubscriptionsTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public class RenewalSubscriptionsTest {
List<PricebookEntry> entries = [SELECT Id, Name, ProductCode, UseStandardPrice, UnitPrice, Pricebook2Id FROM PricebookEntry];
System.debug('Entries ; ' + entries);

Accounting_BillingAccount__c billingAccount1 = new Accounting_BillingAccount__c(account_type__c = 'Pro', is_active__c = true, created_by__c = '[email protected]', created_by_domain__c = 'domain_1', dimagi_contact__c = '[email protected]');
Accounting_BillingAccount__c billingAccount1 = new Accounting_BillingAccount__c(Server_Name__c = 'CommCareHQ', account_type__c = 'Pro', is_active__c = true, created_by__c = '[email protected]', created_by_domain__c = 'domain_1', dimagi_contact__c = '[email protected]');
insert billingAccount1;
Accounting_BillingAccount__c billingAccount2 = new Accounting_BillingAccount__c(account_type__c = 'Conventional 1', is_active__c = true, created_by__c = '[email protected]', created_by_domain__c = 'domain_2', dimagi_contact__c = '[email protected]');
Accounting_BillingAccount__c billingAccount2 = new Accounting_BillingAccount__c(Server_Name__c = 'CommCareHQ', account_type__c = 'Conventional 1', is_active__c = true, created_by__c = '[email protected]', created_by_domain__c = 'domain_2', dimagi_contact__c = '[email protected]');
insert billingAccount2;
Accounting_BillingAccount__c billingAccount3 = new Accounting_BillingAccount__c(account_type__c = 'Conventional 2', is_active__c = true, created_by__c = '[email protected]', created_by_domain__c = 'domain_2', dimagi_contact__c = '[email protected]');
Accounting_BillingAccount__c billingAccount3 = new Accounting_BillingAccount__c(Server_Name__c = 'CommCareHQ', account_type__c = 'Conventional 2', is_active__c = true, created_by__c = '[email protected]', created_by_domain__c = 'domain_2', dimagi_contact__c = '[email protected]');
insert billingAccount3;
Accounting_BillingAccount__c billingAccount4 = new Accounting_BillingAccount__c(account_type__c = 'Conventional 3', is_active__c = true, created_by__c = '[email protected]', created_by_domain__c = 'domain_2', dimagi_contact__c = '[email protected]');
Accounting_BillingAccount__c billingAccount4 = new Accounting_BillingAccount__c(Server_Name__c = 'CommCareHQ', account_type__c = 'Conventional 3', is_active__c = true, created_by__c = '[email protected]', created_by_domain__c = 'domain_2', dimagi_contact__c = '[email protected]');
insert billingAccount4;
Accounting_BillingAccount__c billingAccount5 = new Accounting_BillingAccount__c(account_type__c = 'Free', is_active__c = true, created_by__c = '[email protected]', created_by_domain__c = 'domain_3', dimagi_contact__c = '[email protected]');
Accounting_BillingAccount__c billingAccount5 = new Accounting_BillingAccount__c(Server_Name__c = 'CommCareHQ', account_type__c = 'Free', is_active__c = true, created_by__c = '[email protected]', created_by_domain__c = 'domain_3', dimagi_contact__c = '[email protected]');
insert billingAccount5;

Business_Unit__c bizUnit = new Business_Unit__c(Name = 'Test Business Unit 1');
Expand All @@ -44,48 +44,48 @@ public class RenewalSubscriptionsTest {

Account testAccount = new Account(Name = 'Test Account');
insert testAccount;
Domain__c domain1 = new Domain__c(Name = 'domain_1', cpAllWebUsers__c = 30, Account__c = testAccount.Id);
Domain__c domain1 = new Domain__c(Server_Name__c = 'CommCareHQ', Name = 'domain_1', cpAllWebUsers__c = 30, Account__c = testAccount.Id);
insert domain1;
Domain__c domain2 = new Domain__c(Name = 'domain_2', cpAllWebUsers__c = 22);
Domain__c domain2 = new Domain__c(Server_Name__c = 'CommCareHQ', Name = 'domain_2', cpAllWebUsers__c = 22);
insert domain2;
Domain__c domain3 = new Domain__c(Name = 'domain_3', cpAllWebUsers__c = 11);
Domain__c domain3 = new Domain__c(Server_Name__c = 'CommCareHQ', Name = 'domain_3', cpAllWebUsers__c = 11);
insert domain3;
Domain__c domain4 = new Domain__c(Name = 'domain_4', cpAllWebUsers__c = 111, Opportunity__c = opp.Id);
Domain__c domain4 = new Domain__c(Server_Name__c = 'CommCareHQ', Name = 'domain_4', cpAllWebUsers__c = 111, Opportunity__c = opp.Id);
insert domain4;

Accounting_Softwareplan__c softwarePlan1 = new Accounting_Softwareplan__c(edition__c = 'Pro');
Accounting_Softwareplan__c softwarePlan1 = new Accounting_Softwareplan__c(Server_Name__c = 'CommCareHQ', edition__c = 'Pro');
insert softwarePlan1;
Accounting_Softwareplan__c softwarePlan2 = new Accounting_Softwareplan__c(edition__c = 'Community');
Accounting_Softwareplan__c softwarePlan2 = new Accounting_Softwareplan__c(Server_Name__c = 'CommCareHQ', edition__c = 'Community');
insert softwarePlan2;
Accounting_Softwareplan__c softwarePlan3 = new Accounting_Softwareplan__c(edition__c = 'Conventional');
Accounting_Softwareplan__c softwarePlan3 = new Accounting_Softwareplan__c(Server_Name__c = 'CommCareHQ', edition__c = 'Conventional');
insert softwarePlan3;

Accounting_SoftwarePlanVersion__c planVersion1 = new Accounting_SoftwarePlanVersion__c(Accounting_SoftwarePlan__c = softwarePlan1.Id);
Accounting_SoftwarePlanVersion__c planVersion1 = new Accounting_SoftwarePlanVersion__c(Server_Name__c = 'CommCareHQ', Accounting_SoftwarePlan__c = softwarePlan1.Id);
insert planVersion1;
Accounting_SoftwarePlanVersion__c planVersion2 = new Accounting_SoftwarePlanVersion__c(Accounting_SoftwarePlan__c = softwarePlan2.Id);
Accounting_SoftwarePlanVersion__c planVersion2 = new Accounting_SoftwarePlanVersion__c(Server_Name__c = 'CommCareHQ', Accounting_SoftwarePlan__c = softwarePlan2.Id);
insert planVersion2;
Accounting_SoftwarePlanVersion__c planVersion3 = new Accounting_SoftwarePlanVersion__c(Accounting_SoftwarePlan__c = softwarePlan3.Id);
Accounting_SoftwarePlanVersion__c planVersion3 = new Accounting_SoftwarePlanVersion__c(Server_Name__c = 'CommCareHQ', Accounting_SoftwarePlan__c = softwarePlan3.Id);
insert planVersion3;

Accounting_Subscription__c subscription1 = new Accounting_Subscription__c(is_trial__c = false, date_start__c = Date.newInstance(2016, 1, 1), date_end__c = Date.newInstance(2017, 1, 1), service_type__c = 'Implementation', is_active__c = true,
Accounting_Subscription__c subscription1 = new Accounting_Subscription__c(Server_Name__c = 'CommCareHQ', is_trial__c = false, date_start__c = Date.newInstance(2016, 1, 1), date_end__c = Date.newInstance(2017, 1, 1), service_type__c = 'Implementation', is_active__c = true,
Renewal_Opportunity_created__c = false, account__c = billingAccount1.Id, Accounting_subscriber_domain__c = domain1.Id, plan_version__c = planVersion1.Id);
insert subscription1;
Accounting_Subscription__c subscription2 = new Accounting_Subscription__c(is_trial__c = false, date_start__c = Date.newInstance(2016, 1, 1), date_end__c = Date.newInstance(2016, 11, 2), service_type__c = 'Other', is_active__c = true,
Accounting_Subscription__c subscription2 = new Accounting_Subscription__c(Server_Name__c = 'CommCareHQ', is_trial__c = false, date_start__c = Date.newInstance(2016, 1, 1), date_end__c = Date.newInstance(2016, 11, 2), service_type__c = 'Other', is_active__c = true,
Renewal_Opportunity_created__c = false, account__c = billingAccount2.Id, Accounting_subscriber_domain__c = domain2.Id, plan_version__c = planVersion2.Id);
insert subscription2;
Accounting_Subscription__c subscription3 = new Accounting_Subscription__c(is_trial__c = false, date_start__c = Date.newInstance(2016, 6, 1), date_end__c = Date.newInstance(2016, 12, 3), service_type__c = 'Other', is_active__c = true,
Accounting_Subscription__c subscription3 = new Accounting_Subscription__c(Server_Name__c = 'CommCareHQ', is_trial__c = false, date_start__c = Date.newInstance(2016, 6, 1), date_end__c = Date.newInstance(2016, 12, 3), service_type__c = 'Other', is_active__c = true,
Renewal_Opportunity_created__c = false, account__c = billingAccount3.Id, Accounting_subscriber_domain__c = domain2.Id, plan_version__c = planVersion2.Id);
insert subscription3;
Accounting_Subscription__c subscription4 = new Accounting_Subscription__c(is_trial__c = false, date_start__c = Date.newInstance(2016, 12, 3), date_end__c = Date.newInstance(2017, 1, 20), service_type__c = 'Other', is_active__c = true,
Accounting_Subscription__c subscription4 = new Accounting_Subscription__c(Server_Name__c = 'CommCareHQ', is_trial__c = false, date_start__c = Date.newInstance(2016, 12, 3), date_end__c = Date.newInstance(2017, 1, 20), service_type__c = 'Other', is_active__c = true,
Renewal_Opportunity_created__c = false, account__c = billingAccount4.Id, Accounting_subscriber_domain__c = domain2.Id, plan_version__c = planVersion2.Id);
insert subscription4;
Accounting_Subscription__c subscription5 = new Accounting_Subscription__c(is_trial__c = false, date_start__c = Date.newInstance(2016, 1, 1), date_end__c = Date.newInstance(2017, 5, 1), service_type__c = 'Product', is_active__c = true,
Accounting_Subscription__c subscription5 = new Accounting_Subscription__c(Server_Name__c = 'CommCareHQ', is_trial__c = false, date_start__c = Date.newInstance(2016, 1, 1), date_end__c = Date.newInstance(2017, 5, 1), service_type__c = 'Product', is_active__c = true,
Renewal_Opportunity_created__c = false, account__c = billingAccount5.Id, Accounting_subscriber_domain__c = domain3.Id, plan_version__c = planVersion3.Id);
insert subscription5;
Accounting_Subscription__c subscription6 = new Accounting_Subscription__c(is_trial__c = false, date_start__c = Date.newInstance(2016, 1, 1), date_end__c = Date.newInstance(2017, 1, 1), service_type__c = 'Product', is_active__c = true,
Accounting_Subscription__c subscription6 = new Accounting_Subscription__c(Server_Name__c = 'CommCareHQ', is_trial__c = false, date_start__c = Date.newInstance(2016, 1, 1), date_end__c = Date.newInstance(2017, 1, 1), service_type__c = 'Product', is_active__c = true,
Renewal_Opportunity_created__c = false, account__c = billingAccount5.Id, Accounting_subscriber_domain__c = domain4.Id, plan_version__c = planVersion3.Id);
insert subscription6;
Accounting_Subscription__c subscription7 = new Accounting_Subscription__c(is_trial__c = false, date_start__c = Date.newInstance(2016, 1, 1), date_end__c = Date.newInstance(2017, 1, 12), service_type__c = 'Product', is_active__c = true,
Accounting_Subscription__c subscription7 = new Accounting_Subscription__c(Server_Name__c = 'CommCareHQ', is_trial__c = false, date_start__c = Date.newInstance(2016, 1, 1), date_end__c = Date.newInstance(2017, 1, 12), service_type__c = 'Product', is_active__c = true,
Renewal_Opportunity_created__c = false, account__c = billingAccount5.Id, Accounting_subscriber_domain__c = domain4.Id, plan_version__c = planVersion3.Id);
insert subscription7;

Expand Down

0 comments on commit 31b4383

Please sign in to comment.