New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sync for centers #724

Merged
merged 1 commit into from Aug 7, 2017
Jump to file or symbol
Failed to load files and symbols.
+44 −2
Diff settings

Always

Just for now

@@ -559,7 +559,7 @@ public void onError(Throwable e) {
@Override @Override
public void onNext(GroupWithAssociations groupWithAssociations) { public void onNext(GroupWithAssociations groupWithAssociations) {
mClients = groupWithAssociations.getClientMembers(); mClients = Utils.getActiveClients(groupWithAssociations.getClientMembers());
mClientSyncIndex = 0; mClientSyncIndex = 0;
resetIndexes(); resetIndexes();
if (mClients.size() != 0) { if (mClients.size() != 0) {
@@ -644,7 +644,7 @@ public void onError(Throwable e) {
public void onNext(ClientAccounts clientAccounts) { public void onNext(ClientAccounts clientAccounts) {
mLoanAccountList = Utils.getActiveLoanAccounts(clientAccounts mLoanAccountList = Utils.getActiveLoanAccounts(clientAccounts
.getLoanAccounts()); .getLoanAccounts());
mSavingsAccountList = Utils.getActiveSavingsAccounts(clientAccounts mSavingsAccountList = Utils.getSyncableSavingsAccounts(clientAccounts
.getSavingsAccounts()); .getSavingsAccounts());
checkAccountsSyncStatusAndSyncClientAccounts(); checkAccountsSyncStatusAndSyncClientAccounts();
@@ -10,6 +10,7 @@
import com.mifos.objects.PaymentTypeOption; import com.mifos.objects.PaymentTypeOption;
import com.mifos.objects.accounts.loan.LoanAccount; import com.mifos.objects.accounts.loan.LoanAccount;
import com.mifos.objects.accounts.savings.SavingsAccount; import com.mifos.objects.accounts.savings.SavingsAccount;
import com.mifos.objects.client.Client;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.ArrayList; import java.util.ArrayList;
@@ -120,6 +121,47 @@ public void call(SavingsAccount savingsAccount) {
return accounts; return accounts;
} }
public static List<Client> getActiveClients(List<Client> clients) {
final List<Client> accounts = new ArrayList<>();
Observable.from(clients)
.filter(new Func1<Client, Boolean>() {
@Override
public Boolean call(Client client) {
return (client.isActive());
}
})
.subscribe(new Action1<Client>() {
@Override
public void call(Client client) {
accounts.add(client)
;
}
});
return accounts;
}
public static List<SavingsAccount> getSyncableSavingsAccounts(List<SavingsAccount>
savingsAccounts) {
final List<SavingsAccount> accounts = new ArrayList<>();
Observable.from(savingsAccounts)
.filter(new Func1<SavingsAccount, Boolean>() {
@Override
public Boolean call(SavingsAccount savingsAccount) {
return (savingsAccount.getDepositType().getValue().equals("Savings") &&
savingsAccount.getStatus().getActive() &&
!savingsAccount.isRecurring());
}
})
.subscribe(new Action1<SavingsAccount>() {
@Override
public void call(SavingsAccount savingsAccount) {
accounts.add(savingsAccount)
;
}
});
return accounts;
}
/** /**
* This Method Converting the List<Integer> of Activation Date to String. * This Method Converting the List<Integer> of Activation Date to String.
* *
ProTip! Use n and p to navigate between commits in a pull request.