used amount added for coupon
This commit is contained in:
BIN
.idea/caches/build_file_checksums.ser
generated
BIN
.idea/caches/build_file_checksums.ser
generated
Binary file not shown.
@@ -11,6 +11,7 @@ import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import ch.pizzacucina.android.R;
|
||||
import ch.pizzacucina.android.activity.BaseActivity;
|
||||
import ch.pizzacucina.android.helper.PriceHelper;
|
||||
import ch.pizzacucina.android.model.PersonalCouponModel;
|
||||
|
||||
public class PersonalCouponCodesRecyclerAdapter extends RecyclerView.Adapter<PersonalCouponCodesRecyclerAdapter.ViewHolder> {
|
||||
@@ -22,6 +23,7 @@ public class PersonalCouponCodesRecyclerAdapter extends RecyclerView.Adapter<Per
|
||||
|
||||
@BindView(R.id.personalCouponCodeTextView) TextView personalCouponCodeTextView;
|
||||
@BindView(R.id.personalCouponTotalAmountTextView) TextView personalCouponTotalAmountTextView;
|
||||
@BindView(R.id.personalCouponUsedAmountTextView) TextView personalCouponUsedAmountTextView;
|
||||
@BindView(R.id.personalCouponRemainingAmountTextView) TextView personalCouponRemainingAmountTextView;
|
||||
@BindView(R.id.personalCouponStatusTextView) TextView personalCouponStatusTextView;
|
||||
|
||||
@@ -46,9 +48,16 @@ public class PersonalCouponCodesRecyclerAdapter extends RecyclerView.Adapter<Per
|
||||
@Override
|
||||
public void onBindViewHolder(PersonalCouponCodesRecyclerAdapter.ViewHolder holder, int position) {
|
||||
|
||||
holder.personalCouponCodeTextView.setText(personalCouponCodeList.get(position).getCode());
|
||||
holder.personalCouponTotalAmountTextView.setText(personalCouponCodeList.get(position).getAmount());
|
||||
holder.personalCouponRemainingAmountTextView.setText(personalCouponCodeList.get(position).getTotal());
|
||||
PersonalCouponModel couponModel = personalCouponCodeList.get(position);
|
||||
|
||||
holder.personalCouponCodeTextView.setText(couponModel.getCode());
|
||||
holder.personalCouponTotalAmountTextView.setText(couponModel.getAmount());
|
||||
holder.personalCouponRemainingAmountTextView.setText(couponModel.getTotal());
|
||||
|
||||
double totalAmount = toDoubleSafe(PriceHelper.removeCurrencyFromPrice(couponModel.getAmount()));
|
||||
double remainingAmount = toDoubleSafe(PriceHelper.removeCurrencyFromPrice(couponModel.getTotal()));
|
||||
double usedAmount = totalAmount - remainingAmount;
|
||||
holder.personalCouponUsedAmountTextView.setText(doubleToStringWithCurrency(usedAmount));
|
||||
|
||||
String statusMessage = "";
|
||||
if(personalCouponCodeList.get(position).isActive()){
|
||||
@@ -65,4 +74,24 @@ public class PersonalCouponCodesRecyclerAdapter extends RecyclerView.Adapter<Per
|
||||
return personalCouponCodeList.size();
|
||||
}
|
||||
|
||||
private double toDoubleSafe(String stringToDouble){
|
||||
double d = 0;
|
||||
try{
|
||||
d = Double.parseDouble(stringToDouble);
|
||||
}
|
||||
catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
private String doubleToStringWithCurrency(double d){
|
||||
String dString = String.valueOf(d);
|
||||
int index = dString.indexOf(".");
|
||||
if(index != -1 && dString.length() - index == 2){
|
||||
dString = dString.concat("0");
|
||||
}
|
||||
return "CHF " + dString;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ public class PaymentMethodFragment extends CreateOrderBaseFragment {
|
||||
@BindString(R.string.alert_choose_payment_method) String choosePaymentMethodText;
|
||||
@BindString(R.string.coupon_is_not_active) String couponIsNotActiveText;
|
||||
@BindString(R.string.coupon_used_dialog_title) String couponUsedDialogTitle;
|
||||
@BindString(R.string.coupon_used_dialog_content_part_1) String couponUsedDialogContentPart1;
|
||||
@BindString(R.string.coupon_used_dialog_content_part_2) String couponUsedDialogContentPart2;
|
||||
@BindString(R.string.coupon_used_dialog_message) String couponUsedDialogMessage;
|
||||
|
||||
private ArrayList<PaymentMethodModel> paymentMethodList = new ArrayList<>();
|
||||
private PaymentMethodsRecyclerAdapter paymentMethodsRecyclerAdapter;
|
||||
@@ -244,17 +243,11 @@ public class PaymentMethodFragment extends CreateOrderBaseFragment {
|
||||
couponModel = response.body().getData();
|
||||
couponModel.setStoreName(SessionHelper.getSelectedStore().getStoreName());
|
||||
if(couponModel.isActive()){
|
||||
|
||||
String couponName = "";
|
||||
if(couponModel instanceof PersonalCouponModel){
|
||||
couponName = ((PersonalCouponModel) couponModel).getTheme();
|
||||
}
|
||||
|
||||
SessionHelper.saveSelectedCoupon(couponModel);
|
||||
DialogHelper.showDialogWithPositiveButton(
|
||||
couponUsedDialogTitle,
|
||||
BaseActivity.currentActivity,
|
||||
couponUsedDialogContentPart1 + " " + couponName + " " + couponUsedDialogContentPart2);
|
||||
couponUsedDialogMessage);
|
||||
getCartProducts();
|
||||
}
|
||||
else {
|
||||
@@ -307,7 +300,7 @@ public class PaymentMethodFragment extends CreateOrderBaseFragment {
|
||||
DialogHelper.showDialogWithPositiveButton(
|
||||
couponUsedDialogTitle,
|
||||
BaseActivity.currentActivity,
|
||||
couponUsedDialogContentPart1 + " " + couponName + " " + couponUsedDialogContentPart2);
|
||||
couponUsedDialogMessage);
|
||||
getCartProducts();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
android:background="@color/white"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingEnd="8dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
@@ -70,6 +70,31 @@
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Regular.ttf"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="10sp"
|
||||
android:text="@string/voucher_used_amount"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/personalCouponUsedAmountTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
fontPath="fonts/Quicksand-Bold.ttf"
|
||||
android:textColor="@color/red"
|
||||
android:textSize="12sp"
|
||||
tools:text="CHF 10.00"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.4"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -92,7 +117,7 @@
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="0.75"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -167,8 +167,7 @@
|
||||
<string name="coupon_code">Gutscheincode (Wahlweise)</string>
|
||||
<string name="payment_method">Zahlungsart</string>
|
||||
<string name="coupon_used_dialog_title">Gutscheincode</string>
|
||||
<string name="coupon_used_dialog_content_part_1">Sie haben erfolgreich Ihre</string>
|
||||
<string name="coupon_used_dialog_content_part_2">eingelöst.</string>
|
||||
<string name="coupon_used_dialog_message">Sie haben erfolgreich Ihre Gutschein eingelöst</string>
|
||||
<string name="coupon_is_not_active">Der Coupon ist nicht aktiv.</string>
|
||||
<!-- PaymentMethodFragment-->
|
||||
|
||||
@@ -226,6 +225,7 @@
|
||||
<string name="vouchers_title">GUTSCHEINE</string>
|
||||
<string name="voucher_code">Code:</string>
|
||||
<string name="voucher_total_amount">Belastet:</string>
|
||||
<string name="voucher_used_amount">Eingelöst:</string>
|
||||
<string name="voucher_remaining_amount">Restguthaben:</string>
|
||||
<string name="voucher_remaining_status">Aktiv:</string>
|
||||
<!-- ProfileFragment-->
|
||||
|
||||
Reference in New Issue
Block a user