-
Notifications
You must be signed in to change notification settings - Fork 121
[Shipping Labels] Woomob 891 make hs tariff number mandatory for eu destination #15946
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
Changes from 6 commits
64b8d2c
740180a
581a649
498edc7
53e9359
9f34394
c249322
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,13 +64,21 @@ final class WooShippingCustomsItemViewModel: ObservableObject { | |
|
|
||
| private var cancellables = Set<AnyCancellable>() | ||
|
|
||
| /// WOOMOB-891 | ||
| /// Shipments with a EU destination address must contain HS tariff number | ||
| /// | ||
| /// Introduced to enforce tariff validation | ||
| /// if `true` then `hsTariffNumber` must be valid for `requiredInformationIsEntered` to be `true` | ||
| @Published private(set) var isHSTariffNumberRequired: Bool = false | ||
|
|
||
| init(itemName: String, | ||
| itemProductID: Int64, | ||
| itemQuantity: Decimal, | ||
| itemValue: Double, | ||
| itemWeight: Double, | ||
| currencySymbol: String, | ||
| originCountryCode: AnyPublisher<String?, Never>? = nil, | ||
| isHSTariffNumberRequired: AnyPublisher<Bool, Never>? = nil, | ||
| storageManager: StorageManagerType = ServiceLocator.storageManager) { | ||
| self.title = itemName | ||
| self.description = itemName | ||
|
|
@@ -89,6 +97,9 @@ final class WooShippingCustomsItemViewModel: ObservableObject { | |
| originCountryCode? | ||
| .assign(to: &$originCountryCode) | ||
|
|
||
| isHSTariffNumberRequired? | ||
| .assign(to: &$isHSTariffNumberRequired) | ||
|
|
||
| fetchCountries() | ||
|
|
||
| combineToPreselectCountry() | ||
|
|
@@ -128,15 +139,27 @@ private extension WooShippingCustomsItemViewModel { | |
| } | ||
|
|
||
| func combineRequiredInformationIsEntered() { | ||
| Publishers.CombineLatest4($description, $valuePerUnit, $weightPerUnit, $selectedCountry) | ||
| .sink { [weak self] description, valuePerUnit, weightPerUnit, selectedCountry in | ||
| guard let self else { return } | ||
| requiredInformationIsEntered = description.isNotEmpty && | ||
| valuePerUnit.isNotEmpty && | ||
| Self.isWeightValid(weightPerUnit) && | ||
| selectedCountry != nil | ||
| } | ||
| .store(in: &cancellables) | ||
| Publishers.CombineLatest4( | ||
| $description, | ||
| $valuePerUnit, | ||
| $weightPerUnit, | ||
| $selectedCountry | ||
| ) | ||
| .combineLatest($hsTariffNumber, $isHSTariffNumberRequired) | ||
| .sink { [weak self] result in | ||
| guard let self else { return } | ||
|
|
||
| let ((description, valuePerUnit, weightPerUnit, selectedCountry), hsTariffNumber, isHSTariffNumberRequired) = result | ||
|
|
||
| let hsTariffNumberRequirementMet = hsTariffNumber.isEmpty && !isHSTariffNumberRequired || isValidTariffNumber && hsTariffNumber.isNotEmpty | ||
|
||
|
|
||
| requiredInformationIsEntered = description.isNotEmpty && | ||
| valuePerUnit.isNotEmpty && | ||
| Self.isWeightValid(weightPerUnit) && | ||
| selectedCountry != nil && | ||
| hsTariffNumberRequirementMet | ||
| } | ||
| .store(in: &cancellables) | ||
| } | ||
|
|
||
| func combineHSTariffNumberTotalValue() { | ||
|
|
||
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.
Nit: redundant line.