-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Shipping Labels Revamp] Add Customs requirement check #13413
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
cf3b844
Define ShouldRequireCustomsForm use case
ThomazFB 8b9dce0
Add US military state logic into ShouldRequireCustomsForm use case
ThomazFB 0006023
Finish ShouldRequireCustomsForm business logic
ThomazFB 7ba07c7
Make ShouldRequireCustomsForm injectable
ThomazFB 7fd47ed
Add ShouldRequireCustomsFormTest file
ThomazFB c6bf739
Add ShouldRequireCustomsFormTest unit test scenarios
ThomazFB 3ea8d07
Fix lint issues
ThomazFB ca67034
Define the CustomsState
ThomazFB 2a1fae8
Adjust CustomsState to match the strategy used inside the WooShipping…
ThomazFB 7b087d2
Combine the Customs state with the ViewState flow
ThomazFB 0aea6b4
Add Flow logic to control Customs requirement changes
ThomazFB e820ab4
Wire the Customs state with the WooShippingLabelCreationScreen
ThomazFB f7aab61
Declare CustomsCard associated with the Customs state
ThomazFB 306519d
Add missing Customs string resources
ThomazFB 8b6601b
Define initial scaffold for the Customs section
ThomazFB 50fee13
Adjust Customs card to follow design requirements
ThomazFB 510b5b2
Introduce Badge UI for the Customs card
ThomazFB a4a4f56
Add Edit action into the Customs section
ThomazFB bae7fb8
Fix lint issues
ThomazFB 8d042c3
Fix Customs Card paddings
ThomazFB 5057b5c
Fix build errors in WooShippingLabelCreationViewModelTest
ThomazFB 515f0ec
Add unit test coverage for the Custom State values
ThomazFB 092eeb8
Fix lint issues
ThomazFB 1e64abe
Update optional Modifier parameter rule to follow file strategy
ThomazFB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...n/com/woocommerce/android/ui/orders/wooshippinglabels/customs/ShouldRequireCustomsForm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.woocommerce.android.ui.orders.wooshippinglabels.customs | ||
|
||
import com.woocommerce.android.ui.orders.wooshippinglabels.WooShippingAddresses | ||
import javax.inject.Inject | ||
|
||
class ShouldRequireCustomsForm @Inject constructor() { | ||
operator fun invoke(addressData: WooShippingAddresses): Boolean { | ||
if (addressData.isDifferentCountryShipment) return true | ||
|
||
val isOriginAddressMilitary = isAddressInMilitaryState( | ||
addressData.shipFrom.country, | ||
addressData.shipFrom.state.orEmpty() | ||
) | ||
|
||
val isShippingAddressMilitary = isAddressInMilitaryState( | ||
addressData.shipTo.country.code, | ||
addressData.shipTo.state.codeOrRaw | ||
) | ||
|
||
return isOriginAddressMilitary || isShippingAddressMilitary | ||
} | ||
|
||
private val WooShippingAddresses.isDifferentCountryShipment | ||
get() = shipFrom.country != shipTo.country.code | ||
|
||
private fun isAddressInMilitaryState( | ||
countryCode: String, | ||
stateCode: String | ||
) = countryCode == US_COUNTRY_CODE && stateCode in US_MILITARY_STATES | ||
|
||
companion object { | ||
const val US_COUNTRY_CODE = "US" | ||
val US_MILITARY_STATES = arrayOf("AA", "AE", "AP") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!