17
17
import com .razikallayi .suraksha .utils .WordUtils ;
18
18
19
19
import java .io .Serializable ;
20
- import java .util .ArrayList ;
21
20
import java .util .Calendar ;
22
21
import java .util .List ;
23
22
@@ -49,7 +48,7 @@ public class Member implements Serializable {
49
48
private long closedAt ;
50
49
private long createdAt ;
51
50
private long updatedAt ;
52
- private List <Integer > accountNumbers = null ;
51
+ // private List<Integer> accountNumbers = null;
53
52
54
53
55
54
public Member () {
@@ -183,16 +182,16 @@ public static ContentValues getMemberContentValues(Member member) {
183
182
return values ;
184
183
}
185
184
186
- public static List <Transaction > fetchDeposits (Context context , String accountNumber ) {
187
- Cursor cursor = context .getContentResolver ().query (
188
- SurakshaContract .TxnEntry .buildFetchAllDepositsUri (),
189
- Transaction .TxnQuery .PROJECTION ,
190
- SurakshaContract .TxnEntry .COLUMN_LEDGER + "= ? AND "
191
- + SurakshaContract .TxnEntry .COLUMN_FK_ACCOUNT_NUMBER + "= ?" ,
192
- new String []{String .valueOf (SurakshaContract .TxnEntry .DEPOSIT_LEDGER ), accountNumber },
193
- SurakshaContract .TxnEntry .COLUMN_CREATED_AT + " DESC" );
194
- return Transaction .getTxnListFromCursor (context , cursor );
195
- }
185
+ // public static List<Transaction> fetchDeposits(Context context, String accountNumber) {
186
+ // Cursor cursor = context.getContentResolver().query(
187
+ // SurakshaContract.TxnEntry.buildFetchAllDepositsUri(),
188
+ // Transaction.TxnQuery.PROJECTION,
189
+ // SurakshaContract.TxnEntry.COLUMN_LEDGER + "= ? AND "
190
+ // + SurakshaContract.TxnEntry.COLUMN_FK_ACCOUNT_NUMBER + "= ?",
191
+ // new String[]{String.valueOf(SurakshaContract.TxnEntry.DEPOSIT_LEDGER), accountNumber},
192
+ // SurakshaContract.TxnEntry.COLUMN_CREATED_AT + " DESC");
193
+ // return Transaction.getTxnListFromCursor(context, cursor);
194
+ // }
196
195
197
196
//Get count of all active members
198
197
public static int getActiveMembersCount (Context context ) {
@@ -303,7 +302,7 @@ public boolean hasLoanDue(Context context) {
303
302
// LoanIssued date
304
303
LoanIssue loanIssued = getActiveLoan (context );
305
304
Calendar nextInstalmentCalendar = getNextInstalmentCalendar (context , loanIssued );
306
- return nextInstalmentCalendar != null && CalendarUtils .getDueDate () >= nextInstalmentCalendar .getTimeInMillis ();
305
+ return nextInstalmentCalendar != null && CalendarUtils .getDepositStartDay () >= nextInstalmentCalendar .getTimeInMillis ();
307
306
}
308
307
}
309
308
@@ -336,12 +335,12 @@ public Calendar getNextDepositMonthCalendar(Context context) {
336
335
}
337
336
338
337
public boolean hasDepositDue (Context context ) {
339
- if (!CalendarUtils .isDueDate ()) {
338
+ if (!CalendarUtils .isDepositStartDay ()) {
340
339
return false ;
341
340
}
342
341
Calendar nextDepositMonth = getNextDepositMonthCalendar (context );
343
342
nextDepositMonth .set (Calendar .DATE , CalendarUtils .getDueDay ());
344
- return CalendarUtils .getDueDate () >= CalendarUtils .normalizeDate (nextDepositMonth .getTimeInMillis ());
343
+ return CalendarUtils .getDepositStartDay () >= CalendarUtils .normalizeDate (nextDepositMonth .getTimeInMillis ());
345
344
}
346
345
347
346
public List <Transaction > fetchDeposits (Context context ) {
@@ -356,27 +355,46 @@ public List<Transaction> fetchDeposits(Context context) {
356
355
return Transaction .getTxnListFromCursor (context , cursor );
357
356
}
358
357
359
- @ Deprecated
360
- public List <Integer > fetchAccountNumbers (Context context ) {
361
- List <Integer > acNumbers = new ArrayList <>();
362
- //Fetching accountNumbers
363
- Cursor cursorAccountNumbers = context .getContentResolver ().query (
364
- SurakshaContract .AccountEntry .buildAccountsOfMemberUri (this .id ), new String []{
365
- SurakshaContract .AccountEntry .TABLE_NAME + "."
366
- + SurakshaContract .AccountEntry .COLUMN_ACCOUNT_NUMBER }, null , null , null );
367
- if (cursorAccountNumbers != null ) {
368
- while (cursorAccountNumbers .moveToNext ()) {
369
- acNumbers .add (cursorAccountNumbers .getInt (0 ));
370
- }
371
- cursorAccountNumbers .close ();
358
+ public int getTotalDeposits (Context context ) {
359
+ Cursor cursor = context .getContentResolver ().query (
360
+ SurakshaContract .TxnEntry .buildFetchAllDepositsUri (),
361
+ new String []{
362
+ SurakshaContract .TxnEntry .TABLE_NAME + "." + SurakshaContract .TxnEntry ._ID } ,
363
+ SurakshaContract .TxnEntry .COLUMN_LEDGER + "= ? AND "
364
+ + SurakshaContract .TxnEntry .COLUMN_FK_ACCOUNT_NUMBER + "= ?" ,
365
+ new String []{String .valueOf (SurakshaContract .TxnEntry .DEPOSIT_LEDGER ),
366
+ String .valueOf (accountNo )},null );
367
+
368
+ if (cursor ==null || cursor .getCount () <= 0 ) {
369
+ return 0 ;
370
+ }else {
371
+ int count = cursor .getCount ();
372
+ cursor .close ();
373
+ return count ;
372
374
}
373
- this .accountNumbers = acNumbers ;
374
- return acNumbers ;
375
375
}
376
376
377
- public List <Integer > getAccountNumbers () {
378
- return accountNumbers ;
379
- }
377
+ // @Deprecated
378
+ // public List<Integer> fetchAccountNumbers(Context context) {
379
+ // List<Integer> acNumbers = new ArrayList<>();
380
+ // //Fetching accountNumbers
381
+ // Cursor cursorAccountNumbers = context.getContentResolver().query(
382
+ // SurakshaContract.AccountEntry.buildAccountsOfMemberUri(this.id), new String[]{
383
+ // SurakshaContract.AccountEntry.TABLE_NAME + "."
384
+ // + SurakshaContract.AccountEntry.COLUMN_ACCOUNT_NUMBER}, null, null, null);
385
+ // if (cursorAccountNumbers != null) {
386
+ // while (cursorAccountNumbers.moveToNext()) {
387
+ // acNumbers.add(cursorAccountNumbers.getInt(0));
388
+ // }
389
+ // cursorAccountNumbers.close();
390
+ // }
391
+ // this.accountNumbers = acNumbers;
392
+ // return acNumbers;
393
+ // }
394
+
395
+ // public List<Integer> getAccountNumbers() {
396
+ // return accountNumbers;
397
+ // }
380
398
381
399
public byte [] getAvatar () {
382
400
return ImageUtils .drawableToByteArray (avatar );
0 commit comments