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

Add support for Creating, editing and viewing Product using Couchbase #192

Open
wants to merge 5 commits 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 @@ -66,6 +66,10 @@

<activity android:name=".ui.online.loanaccounts.loanapplication.loanactivity.LoanApplicationActivity" />

<activity
android:name=".ui.product.createproduct.CreateProductActivity"
android:windowSoftInputMode="adjustResize|stateHidden" />

<activity
android:name=".ui.online.customers.createcustomer.customeractivity.CreateCustomerActivity"
android:windowSoftInputMode="adjustResize|stateHidden" />
Expand Down Expand Up @@ -94,6 +98,8 @@
android:name=".ui.online.groups.creategroup.CreateGroupActivity"
android:windowSoftInputMode="adjustResize|stateHidden" />

<activity android:name=".ui.product.productdetails.ProductDetailsActivity" />

<receiver
android:name=".jobs.JobsReceiver"
android:exported="false">
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"),
PRODUCT("Product")
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package org.apache.fineract.data.models.loan

import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.android.parcel.Parcelize

/**
* @author Rajan Maurya
* On 12/07/17.
*/

@Parcelize
data class TermRange(
@SerializedName("temporalUnit") var temporalUnit: String?,
@SerializedName("maximum") var maximum: Double?
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.apache.fineract.data.models.product

import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.android.parcel.Parcelize

/**
* @author Rajan Maurya
* On 20/07/17.
*/

@Parcelize
data class BalanceRange (
@SerializedName("minimum") var minimum: Double? = null,
@SerializedName("maximum") var maximum: Double? = null
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.apache.fineract.data.models.product

import kotlinx.android.parcel.Parcelize

/**
* @author Rajan Maurya
* On 20/07/17.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.apache.fineract.data.models.product

import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.android.parcel.Parcelize

/**
* @author Rajan Maurya
* On 20/07/17.
*/

@Parcelize
data class InterestRange (
@SerializedName("minimum") var minimum: Double? = null,
@SerializedName("maximum") var maximum: Double? = null
)
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.apache.fineract.data.models.product

import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import kotlinx.android.parcel.Parcelize
import kotlinx.android.parcel.RawValue
import org.apache.fineract.couchbase.DocumentType
import org.apache.fineract.data.models.loan.AccountAssignment
import org.apache.fineract.data.models.loan.TermRange
import java.util.ArrayList
Expand All @@ -10,22 +14,24 @@ import java.util.ArrayList
* On 20/07/17.
*/

@Parcelize
data class Product (
@SerializedName("identifier") val identifier: String? = null,
@SerializedName("name") val name: String? = null,
@SerializedName("termRange") val termRange: TermRange? = null,
@SerializedName("balanceRange") val balanceRange: BalanceRange? = null,
@SerializedName("interestRange") val interestRange: InterestRange? = null,
@SerializedName("interestBasis") val interestBasis: InterestBasis? = null,
@SerializedName("patternPackage") val patternPackage: String? = null,
@SerializedName("description") val description: String? = null,
@SerializedName("currencyCode") val currencyCode: String? = null,
@SerializedName("minorCurrencyUnitDigits") val minorCurrencyUnitDigits: Int = 0,
@SerializedName("accountAssignments") val accountAssignments: List<AccountAssignment> =
@SerializedName("identifier") var identifier: String? = null,
@SerializedName("name") var name: String? = null,
@SerializedName("termRange") var termRange: TermRange? = null,
@SerializedName("balanceRange") var balanceRange: BalanceRange? = null,
@SerializedName("interestRange") var interestRange: InterestRange? = null,
@SerializedName("interestBasis") var interestBasis: InterestBasis? = null,
@SerializedName("patternPackage") var patternPackage: String? = null,
@SerializedName("description") var description: String? = null,
@SerializedName("currencyCode") var currencyCode: String? = null,
@SerializedName("minorCurrencyUnitDigits") var minorCurrencyUnitDigits: Int = 0,
@SerializedName("accountAssignments") var accountAssignments: List<AccountAssignment> =
ArrayList(),
@SerializedName("parameters") val parameters: 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
)
@SerializedName("parameters") var parameters: String? = null,
@SerializedName("createdOn") var createdOn: String? = null,
@SerializedName("createdBy") var createdBy: String? = null,
@SerializedName("lastModifiedOn") var lastModifiedOn: String? = null,
@SerializedName("lastModifiedBy") var lastModifiedBy: String? = null,
var documentType: String = DocumentType.PRODUCT.value
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@
import org.apache.fineract.ui.online.review.AddLoanReviewFragment;
import org.apache.fineract.ui.online.roles.roleslist.RolesFragment;
import org.apache.fineract.ui.online.teller.TellerFragment;
import org.apache.fineract.ui.product.ProductFragment;
import org.apache.fineract.ui.product.createproduct.AddAccountAssignmentsFragment;
import org.apache.fineract.ui.product.createproduct.CreateProductActivity;
import org.apache.fineract.ui.product.createproduct.ProductDetailsStepFragment;
import org.apache.fineract.ui.product.createproduct.ProductReviewStepFragment;
import org.apache.fineract.ui.product.productlist.ProductFragment;
import org.apache.fineract.ui.product.productdetails.ProductDetailsActivity;
import org.apache.fineract.ui.product.productdetails.ProductDetailsFragment;

import dagger.Subcomponent;

Expand Down Expand Up @@ -159,5 +165,17 @@ public interface ActivityComponent {
void inject(GroupDetailsFragment groupDetailsFragment);

void inject(GroupTasksBottomSheetFragment groupTasksBottomSheetFragment);

void inject(ProductDetailsActivity productDetailsActivity);

void inject(ProductDetailsFragment productDetailsFragment);

void inject(CreateProductActivity createProductActivity);

void inject(ProductDetailsStepFragment productDetailsStepFragment);

void inject(AddAccountAssignmentsFragment addAccountAssignmentsFragment);

void inject(ProductReviewStepFragment productReviewStepFragment);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.apache.fineract.ui.adapters

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.account_assignments_item.view.*
import org.apache.fineract.R
import org.apache.fineract.data.models.loan.AccountAssignment
import javax.inject.Inject

class ProductAccountAssignmentsAdapter @Inject constructor() :
RecyclerView.Adapter<ProductAccountAssignmentsAdapter.ViewHolder>() {

private var accountAssignmentsList = ArrayList<AccountAssignment>()
private var onItemClickListener: OnItemClickListener? = null
private var isReview = false

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder.from(parent)
}

override fun getItemCount(): Int = accountAssignmentsList.size

override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.bind(accountAssignmentsList[position], onItemClickListener, isReview)
}

fun setOnItemClickListener(onItemClickListener: OnItemClickListener?) {
this.onItemClickListener = onItemClickListener
}

fun submitList(list: ArrayList<AccountAssignment>) {
accountAssignmentsList = list
notifyDataSetChanged()
}

fun setReview(isReview: Boolean) {
this.isReview = isReview
}

class ViewHolder private constructor(itemView: View) : RecyclerView.ViewHolder(itemView) {

fun bind(accountAssignment: AccountAssignment, onItemClickListener: OnItemClickListener?, isReview: Boolean) {
if (isReview) {
itemView.ivEditProductAccountAss.visibility = View.GONE
itemView.ivDeleteProductAccountAss.visibility = View.GONE
} else {
itemView.ivEditProductAccountAss.visibility = View.VISIBLE
itemView.ivDeleteProductAccountAss.visibility = View.VISIBLE
}
itemView.tvDesignator.text = accountAssignment.designator
itemView.tvAccountIdentifier.text = accountAssignment.accountIdentifier
itemView.tvLedgerIdentifier.text = accountAssignment.ledgerIdentifier
itemView.ivDeleteProductAccountAss.setOnClickListener {
onItemClickListener?.onDeleteClicked(adapterPosition)
}
itemView.ivEditProductAccountAss.setOnClickListener {
onItemClickListener?.onEditClicked(adapterPosition)
}
}

companion object {
fun from(parent: ViewGroup): ViewHolder {
return ViewHolder(
LayoutInflater.from(parent.context)
.inflate(R.layout.account_assignments_item, parent, false)
)
}
}
}

interface OnItemClickListener {
fun onEditClicked(position: Int)
fun onDeleteClicked(position: Int)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ 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_product.view.*
import org.apache.fineract.R
import org.apache.fineract.data.models.product.Product
import org.apache.fineract.injection.ApplicationContext
import org.apache.fineract.ui.base.OnItemClickListener
import org.apache.fineract.utils.DateUtils
import javax.inject.Inject

class ProductAdapter @Inject constructor(@ApplicationContext val context: Context)
: RecyclerView.Adapter<ProductAdapter.ViewHolder>() {

private var products: List<Product> = ArrayList()
lateinit var onItemClickListener: OnItemClickListener

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

Expand Down Expand Up @@ -50,11 +53,26 @@ class ProductAdapter @Inject constructor(@ApplicationContext val context: Contex
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 tvProductIdentifier: TextView = itemView.tv_product_identifier
val tvModifiedBy: TextView = itemView.tv_modified_by
val tvModifiedOn: TextView = itemView.tv_modified_on
val tvName: TextView = itemView.tv_name
val llProduct: LinearLayout = itemView.ll_product

init {
llProduct.setOnClickListener(this)
}

override fun onClick(p0: View?) {
if (onItemClickListener != null) {
onItemClickListener.onItemClick(p0, adapterPosition)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.apache.fineract.ui.online.launcher.LauncherActivity;
import org.apache.fineract.ui.online.roles.roleslist.RolesFragment;
import org.apache.fineract.ui.online.teller.TellerFragment;
import org.apache.fineract.ui.product.ProductFragment;
import org.apache.fineract.ui.product.productlist.ProductFragment;
import org.apache.fineract.utils.MaterialDialog;

import javax.inject.Inject;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.apache.fineract.ui.product

enum class ProductAction {
EDIT,
CREATE
}
Loading