Skip to content

Commit 1824fd3

Browse files
liveHarshitiamareebjamal
authored andcommitted
fix: Make billing information compulsory for paid orders (#2136)
1 parent 0003ecc commit 1824fd3

File tree

5 files changed

+25
-31
lines changed

5 files changed

+25
-31
lines changed

app/src/main/java/org/fossasia/openevent/general/attendees/AttendeeFragment.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ import kotlinx.android.synthetic.main.fragment_attendee.view.cardNumber
5959
import kotlinx.android.synthetic.main.fragment_attendee.view.acceptCheckbox
6060
import kotlinx.android.synthetic.main.fragment_attendee.view.countryPicker
6161
import kotlinx.android.synthetic.main.fragment_attendee.view.billingInfoContainer
62-
import kotlinx.android.synthetic.main.fragment_attendee.view.billingInfoCheckboxSection
63-
import kotlinx.android.synthetic.main.fragment_attendee.view.billingEnabledCheckbox
6462
import kotlinx.android.synthetic.main.fragment_attendee.view.billingCity
6563
import kotlinx.android.synthetic.main.fragment_attendee.view.billingCompany
6664
import kotlinx.android.synthetic.main.fragment_attendee.view.taxId
@@ -126,6 +124,7 @@ class AttendeeFragment : Fragment(), ComplexBackPressFragment {
126124
private val safeArgs: AttendeeFragmentArgs by navArgs()
127125
private lateinit var timer: CountDownTimer
128126
private lateinit var card: Card
127+
private var showBillingInfoLayout = false
129128

130129
override fun onCreate(savedInstanceState: Bundle?) {
131130
super.onCreate(savedInstanceState)
@@ -134,6 +133,8 @@ class AttendeeFragment : Fragment(), ComplexBackPressFragment {
134133
attendeeViewModel.singleTicket = safeArgs.ticketIdAndQty?.value?.map { it.second }?.sum() == 1
135134
}
136135

136+
showBillingInfoLayout = safeArgs.hasPaidTickets || safeArgs.amount > 0
137+
137138
attendeeRecyclerAdapter.setEventId(safeArgs.eventId)
138139
if (attendeeViewModel.paymentCurrency.isNotBlank())
139140
ticketsRecyclerAdapter.setCurrency(attendeeViewModel.paymentCurrency)
@@ -318,7 +319,6 @@ class AttendeeFragment : Fragment(), ComplexBackPressFragment {
318319

319320
attendeeViewModel.totalAmount.value = safeArgs.amount
320321
rootView.paymentSelectorContainer.isVisible = safeArgs.amount > 0
321-
rootView.billingInfoCheckboxSection.isVisible = safeArgs.amount > 0
322322

323323
attendeeViewModel.tickets
324324
.nonNull()
@@ -488,16 +488,12 @@ class AttendeeFragment : Fragment(), ComplexBackPressFragment {
488488
}
489489

490490
private fun setupBillingInfo() {
491+
rootView.billingInfoContainer.isVisible = showBillingInfoLayout
492+
attendeeViewModel.billingEnabled = showBillingInfoLayout
491493
rootView.billingCompanyLayout.setRequired()
492494
rootView.billingAddressLayout.setRequired()
493495
rootView.billingCityLayout.setRequired()
494496
rootView.billingPostalCodeLayout.setRequired()
495-
rootView.billingInfoContainer.isVisible = rootView.billingEnabledCheckbox.isChecked
496-
attendeeViewModel.billingEnabled = rootView.billingEnabledCheckbox.isChecked
497-
rootView.billingEnabledCheckbox.setOnCheckedChangeListener { _, isChecked ->
498-
attendeeViewModel.billingEnabled = isChecked
499-
rootView.billingInfoContainer.isVisible = isChecked
500-
}
501497
}
502498

503499
private fun setupCountryOptions() {
@@ -691,7 +687,7 @@ class AttendeeFragment : Fragment(), ComplexBackPressFragment {
691687
rootView.email.checkEmpty()
692688

693689
var checkBillingInfo = true
694-
if (rootView.billingEnabledCheckbox.isChecked) {
690+
if (showBillingInfoLayout) {
695691
checkBillingInfo = rootView.billingCompany.checkEmpty() && rootView.billingAddress.checkEmpty() &&
696692
rootView.billingCity.checkEmpty() && rootView.billingPostalCode.checkEmpty()
697693
}

app/src/main/java/org/fossasia/openevent/general/ticket/TicketsFragment.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,16 @@ class TicketsFragment : Fragment() {
213213
}
214214

215215
private fun redirectToAttendee() {
216-
217216
val wrappedTicketAndQty = TicketIdAndQtyWrapper(ticketIdAndQty)
218217
ticketsViewModel.mutableAmount.value = null
219218
findNavController(rootView).navigate(TicketsFragmentDirections.actionTicketsToAttendee(
220219
eventId = safeArgs.eventId,
221220
ticketIdAndQty = wrappedTicketAndQty,
222221
currency = safeArgs.currency,
223-
amount = totalAmount
222+
amount = totalAmount,
223+
hasPaidTickets = ticketsViewModel.hasPaidTickets
224224
))
225+
ticketsViewModel.hasPaidTickets = false
225226
}
226227

227228
private fun redirectToLogin() {

app/src/main/java/org/fossasia/openevent/general/ticket/TicketsViewModel.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class TicketsViewModel(
4444
val ticketTableVisibility: LiveData<Boolean> = mutableTicketTableVisibility
4545
val ticketIdAndQty = MutableLiveData<List<Triple<Int, Int, Float>>>()
4646
var discountCodeCurrentLayout = APPLY_DISCOUNT_CODE
47+
var hasPaidTickets = false
4748

4849
fun isLoggedIn() = authHolder.isLoggedIn()
4950

@@ -128,6 +129,8 @@ class TicketsViewModel(
128129
}
129130
}
130131
price.let { prices += price * qty[index++] }
132+
if (ticket.type == TICKET_TYPE_PAID)
133+
hasPaidTickets = true
131134
}
132135
mutableAmount.value = prices + donation
133136
}, {

app/src/main/res/layout/fragment_attendee.xml

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -370,25 +370,6 @@
370370
tools:itemCount="3"
371371
tools:listitem="@layout/item_attendee" />
372372

373-
<RelativeLayout
374-
android:id="@+id/billingInfoCheckboxSection"
375-
android:layout_width="match_parent"
376-
android:layout_height="wrap_content">
377-
<TextView
378-
android:layout_width="wrap_content"
379-
android:layout_height="wrap_content"
380-
android:text="@string/billing_information"
381-
android:textColor="@color/black"
382-
android:textSize="@dimen/heading_text_size"
383-
android:layout_alignParentStart="true"
384-
android:layout_centerVertical="true"/>
385-
<CheckBox
386-
android:id="@+id/billingEnabledCheckbox"
387-
android:layout_width="wrap_content"
388-
android:layout_height="wrap_content"
389-
android:layout_alignParentEnd="true"/>
390-
</RelativeLayout>
391-
392373
<LinearLayout
393374
android:id="@+id/billingInfoContainer"
394375
android:layout_width="match_parent"
@@ -397,6 +378,14 @@
397378
android:orientation="vertical"
398379
android:visibility="gone"
399380
tools:visibility="visible">
381+
382+
<TextView
383+
android:layout_width="wrap_content"
384+
android:layout_height="wrap_content"
385+
android:text="@string/billing_information"
386+
android:textColor="@color/black"
387+
android:textSize="@dimen/heading_text_size"/>
388+
400389
<com.google.android.material.textfield.TextInputLayout
401390
android:id="@+id/billingCompanyLayout"
402391
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"

app/src/main/res/navigation/navigation_graph.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,11 @@
728728
app:argType="float"
729729
app:nullable="false"
730730
android:defaultValue="0.0"/>
731+
732+
<argument
733+
android:name="hasPaidTickets"
734+
app:argType="boolean"
735+
android:defaultValue="false"/>
731736
</fragment>
732737
<fragment
733738
android:id="@+id/orderCompletedFragment"

0 commit comments

Comments
 (0)