Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Add support for all the account related functionalities using couchbase to extend offline support in the application #191

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@

<activity android:name=".ui.online.groups.groupdetails.GroupDetailsActivity" />

<activity android:name=".ui.online.accounting.accounts.accountDetails.AccountDetailsActivity" />

<activity
android:name=".ui.online.accounting.accounts.createaccount.CreateAccountActivity"
android:windowSoftInputMode="adjustResize|stateHidden" />

<activity
android:name=".ui.online.groups.creategroup.CreateGroupActivity"
android:windowSoftInputMode="adjustResize|stateHidden" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ package org.apache.fineract.couchbase

enum class DocumentType(val value: String) {
GROUP("Group"),
CUSTOMER("customer")
CUSTOMER("customer"),
ACCOUNT("Account")
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.apache.fineract.data.datamanager

import io.reactivex.Completable
import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.functions.Function
Expand Down Expand Up @@ -36,6 +37,11 @@ class DataManagerAccounting @Inject constructor(val baseManagerApi: BaseApiManag
.onErrorResumeNext(Function<Throwable, ObservableSource<AccountPage>>
{ Observable.just(FakeRemoteDataSource.getAccountPage()) })

fun createAccount(account: Account) : Completable =
baseManagerApi.accountingService.createAccount(account)

fun updateAccount(identifier: String, account: Account) : Completable =
baseManagerApi.accountingService.updateAccount(identifier, account)

fun findAccount(identifier: String): Observable<Account> =
baseManagerApi.accountingService.findAccount(identifier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ package org.apache.fineract.data.models.accounts
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.android.parcel.Parcelize
import org.apache.fineract.couchbase.DocumentType

@Parcelize
data class Account(

@SerializedName("type") val type: AccountType? = null,
@SerializedName("identifier") val identifier: String? = null,
@SerializedName("name") val name: String? = null,
@SerializedName("holders") val holders: Set<String>? = null,
@SerializedName("signatureAuthorities") val signatureAuthorities: Set<String>? = null,
@SerializedName("balance") val balance: Double? = null,
@SerializedName("referenceAccount") val referenceAccount: String? = null,
@SerializedName("ledger") val ledger: String? = null,
@SerializedName("state") val state: State? = null,
@SerializedName("alternativeAccountNumber") val alternativeAccountNumber: String? = null,
@SerializedName("createdOn") val createdOn: String? = null,
@SerializedName("createdBy") val createdBy: String? = null,
@SerializedName("lastModifiedOn") val lastModifiedOn: String? = null,
@SerializedName("lastModifiedBy") val lastModifiedBy: String? = null

var type: AccountType? = null,
var identifier: String? = null,
var name: String? = null,
var holders: List<String>? = null,
var signatureAuthorities: List<String>? = null,
var balance: Double? = null,
var referenceAccount: String? = null,
var ledger: String? = null,
var state: State? = null,
var alternativeAccountNumber: String? = null,
var createdOn: String? = null,
var createdBy: String? = null,
var lastModifiedOn: String? = null,
var lastModifiedBy: String? = null,
var documentType: String = DocumentType.ACCOUNT.value
) : Parcelable {

enum class State {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.apache.fineract.data.services

import io.reactivex.Completable
import io.reactivex.Observable
import org.apache.fineract.data.models.accounts.Account
import org.apache.fineract.data.models.accounts.AccountPage
import org.apache.fineract.data.models.accounts.Ledger
import org.apache.fineract.data.models.accounts.LedgerPage
import org.apache.fineract.data.remote.EndPoints
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.*


interface AccountingService {
Expand All @@ -24,4 +24,11 @@ interface AccountingService {
@GET(EndPoints.API_ACCOUNTING_PATH + "/accounts/{identifier}")
fun findAccount(@Path("identifier") identifier: String): Observable<Account>

@POST(EndPoints.API_ACCOUNTING_PATH + "/accounts")
fun createAccount(@Body account: Account) : Completable

@PUT(EndPoints.API_ACCOUNTING_PATH + "/accounts/{identifier}")
fun updateAccount(@Path("identifier") identifier: String,
@Body account: Account) : Completable

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
import org.apache.fineract.injection.module.ActivityModule;
import org.apache.fineract.ui.offline.CustomerPayloadFragment;
import org.apache.fineract.ui.online.DashboardActivity;
import org.apache.fineract.ui.online.accounting.accounts.accountDetails.AccountDetailsActivity;
import org.apache.fineract.ui.online.accounting.accounts.accountDetails.AccountDetailsFragment;
import org.apache.fineract.ui.online.accounting.accounts.AccountsFragment;
import org.apache.fineract.ui.online.accounting.accounts.accounttasks.AccountTaskBottomSheetFragment;
import org.apache.fineract.ui.online.accounting.accounts.createaccount.AccountDetailsStepFragment;
import org.apache.fineract.ui.online.accounting.accounts.createaccount.AccountReviewStepFragment;
import org.apache.fineract.ui.online.accounting.accounts.createaccount.AddAccountHoldersStepFragment;
import org.apache.fineract.ui.online.accounting.accounts.createaccount.AddAccountSignAuthoritiesFragment;
import org.apache.fineract.ui.online.accounting.accounts.createaccount.CreateAccountActivity;
import org.apache.fineract.ui.online.accounting.ledgers.LedgerFragment;
import org.apache.fineract.ui.online.customers.createcustomer.customeractivity
.CreateCustomerActivity;
Expand Down Expand Up @@ -159,5 +167,21 @@ public interface ActivityComponent {
void inject(GroupDetailsFragment groupDetailsFragment);

void inject(GroupTasksBottomSheetFragment groupTasksBottomSheetFragment);

void inject(AccountDetailsActivity accountDetailsActivity);

void inject(AccountDetailsFragment accountDetailsFragment);

void inject(CreateAccountActivity createAccountActivity);

void inject(AccountDetailsStepFragment accountDetailsStepFragment);

void inject(AccountReviewStepFragment accountReviewStepFragment);

void inject(AddAccountSignAuthoritiesFragment addAccountSignAuthoritiesFragment);

void inject(AddAccountHoldersStepFragment addAccountHoldersStepFragment);

void inject(AccountTaskBottomSheetFragment accountTaskBottomSheetFragment);
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import kotlinx.android.synthetic.main.item_account.view.*
import org.apache.fineract.R
import org.apache.fineract.data.models.accounts.Account
import org.apache.fineract.injection.ApplicationContext
import org.apache.fineract.ui.base.OnItemClickListener
import org.apache.fineract.utils.DateUtils
import org.apache.fineract.utils.StatusUtils
import javax.inject.Inject
Expand All @@ -20,6 +22,8 @@ class AccountsAdapter @Inject constructor(@ApplicationContext val context: Conte

var accounts: List<Account> = ArrayList()

lateinit var onItemClickListener: OnItemClickListener

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {

val view = LayoutInflater.from(parent?.context).inflate(R.layout.item_account, parent, false)
Expand Down Expand Up @@ -55,12 +59,27 @@ class AccountsAdapter @Inject constructor(@ApplicationContext val context: Conte
notifyDataSetChanged()
}

class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun setItemClickListener(onItemClickListener: OnItemClickListener) {
this.onItemClickListener = onItemClickListener
}

inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener {

val tvIdentifier: TextView = itemView.tv_account_identifier
val tvModifiedBy: TextView = itemView.tv_modified_by
val tvModifiedOn: TextView = itemView.tv_modified_on
val tvName: TextView = itemView.tv_name
val ivAccountTypeIndicator: AppCompatImageView = itemView.iv_type_indicator
val llAccount: LinearLayout = itemView.ll_account

init {
llAccount.setOnClickListener(this)
}

override fun onClick(v: View?) {
if (onItemClickListener != null) {
onItemClickListener.onItemClick(v, adapterPosition)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.apache.fineract.ui.online.accounting.accounts

/**
* Created by Varun Jain on 23/July/2021
*/

enum class AccountAction {
EDIT,
CREATE
}
Loading