Skip to content

Commit

Permalink
MBL-2052 PLOT projects not working after scheme change on BE (#2215)
Browse files Browse the repository at this point in the history
* Remove 'projectIsPledgeOverTimeAllowed' from the project

* fix showPlotWidget

---------

Co-authored-by: Isabel Martin <[email protected]>
Co-authored-by: Leigh Douglas <[email protected]>
  • Loading branch information
3 people authored Jan 30, 2025
1 parent d6261ed commit b6ab5da
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 37 deletions.
1 change: 0 additions & 1 deletion app/src/main/graphql/project.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ mutation CreateFlagging($contentId: ID!, $details: String, $kind: NonDeprecatedF
query BuildPaymentPlan($slug: String!, $amount: String!) {
project(slug: $slug) {
paymentPlan(amount: $amount) {
projectIsPledgeOverTimeAllowed
amountIsPledgeOverTimeEligible
paymentIncrements {
amount {
Expand Down
72 changes: 50 additions & 22 deletions app/src/main/graphql/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -760,18 +760,12 @@ enum Feature {

reset_backer_survey_2024

disable_shipping_at_pledge

pledge_projects_overview_2024

pledge_projects_overview_ios_2024

copy_rewards

pledge_redemption_v1

pledge_redemption_vat

survey_reward_questions_2024

address_collection_for_digital_rewards_2024
Expand All @@ -796,17 +790,19 @@ enum Feature {

notification_banner_update_2024

multiple_shipfrom_locations_2024

pledge_redemption_unified_creator_ui

react_backed_projects

copy_addons

KDS_messages_app

pledge_management_refunds

discover_ui_2025

pledge_management_beta

creator_experience_2025
}

"""
Expand Down Expand Up @@ -1766,6 +1762,11 @@ type Project implements Node & Commentable {
"""
profile: ProjectProfile

"""
The text of the currently applied project notice, empty if there is no notice
"""
projectNotice: String

"""
When this project was Project of the Day.
"""
Expand Down Expand Up @@ -5055,30 +5056,40 @@ A hash containing the original, refunded, and remaining amounts.
"""
type AdjustmentAmount {
"""
the original total amount
original total amount
"""
originalTotal: Int!

"""
the refunded total amount
amount that has been refunded after all adjustments are applied
"""
refundedTotal: Int!

"""
the remaining total amount
amount remaining after all adjustments are applied
"""
remainingTotal: Int!

"""
whether the reward has been removed from the backing
"""
removed: Boolean
}

"""
A reward that is modified by an adjustment.
"""
type AdjustmentReward {
"""
original total for reward
original total amount
"""
originalTotal: Int!

"""
uuid for the refund item
"""
refundItemId: ID!

"""
amount that has been refunded after all adjustments are applied
"""
Expand All @@ -5089,10 +5100,15 @@ type AdjustmentReward {
"""
remainingTotal: Int!

"""
whether the reward has been removed from the backing
"""
removed: Boolean

"""
graphql id of reward to be refunded
"""
rewardId: ID!
rewardId: String!
}

"""
Expand Down Expand Up @@ -7081,6 +7097,11 @@ enum FlaggingKind {
"""
PROTOTYPE_MISREPRESENTATION

"""
undisclosed-ai-use
"""
UNDISCLOSED_AI_USE

"""
misrep-support-impersonation
"""
Expand Down Expand Up @@ -8441,11 +8462,6 @@ type PaymentPlan {
amountIsPledgeOverTimeEligible: Boolean!

paymentIncrements: [PaymentIncrement!]

"""
Whether the project permits pledge over time pledges
"""
projectIsPledgeOverTimeAllowed: Boolean!
}

"""
Expand Down Expand Up @@ -9108,6 +9124,8 @@ enum UserRestrictionKind {
edit_spotlight_pages

phone

prelaunch_early
}

"""
Expand Down Expand Up @@ -14516,10 +14534,15 @@ input AdjustmentInput {
An object removed as part of an adjustment
"""
input RemovalInput {
"""
id of the reward associated with the removal
"""
rewardId: Int!

"""
id of object to be removed
"""
id: Int!
refundItemId: ID!

"""
type of object to be removed (reward, reward item, or order item)
Expand All @@ -14534,7 +14557,7 @@ input RefundInput {
"""
id of object to be refunded
"""
id: Int
refundItemId: ID

"""
type of refund
Expand Down Expand Up @@ -14965,6 +14988,11 @@ enum NonDeprecatedFlaggingKind {
"""
PROTOTYPE_MISREPRESENTATION

"""
undisclosed-ai-use
"""
UNDISCLOSED_AI_USE

"""
misrep-support-impersonation
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,24 @@ class PaymentPlanFactory {
fun paymentPlan(
paymentIncrements: List<PaymentIncrement>?,
amountIsPledgeOverTimeEligible: Boolean,
projectIsPledgeOverTimeAllowed: Boolean,
): PaymentPlan {
return builder()
.paymentIncrements(paymentIncrements)
.amountIsPledgeOverTimeEligible(amountIsPledgeOverTimeEligible)
.projectIsPledgeOverTimeAllowed(projectIsPledgeOverTimeAllowed)
.build()
}

fun eligibleAllowedPaymentPlan(paymentIncrements: List<PaymentIncrement>): PaymentPlan {
return this.paymentPlan(
paymentIncrements = paymentIncrements,
amountIsPledgeOverTimeEligible = true,
projectIsPledgeOverTimeAllowed = true
)
}

fun ineligibleAllowedPaymentPlan(): PaymentPlan {
return this.paymentPlan(
paymentIncrements = null,
amountIsPledgeOverTimeEligible = false,
projectIsPledgeOverTimeAllowed = true
)
}
}
Expand Down
9 changes: 1 addition & 8 deletions app/src/main/java/com/kickstarter/models/PaymentPlan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,20 @@ import kotlinx.parcelize.Parcelize
data class PaymentPlan(
val amountIsPledgeOverTimeEligible: Boolean,
val paymentIncrements: List<PaymentIncrement>?,
val projectIsPledgeOverTimeAllowed: Boolean,
) : Parcelable {
fun amountIsPledgeOverTimeEligible() = this.amountIsPledgeOverTimeEligible
fun paymentIncrements() = this.paymentIncrements
fun projectIsPledgeOverTimeAllowed() = this.projectIsPledgeOverTimeAllowed

@Parcelize
data class Builder(
var amountIsPledgeOverTimeEligible: Boolean = false,
var paymentIncrements: List<PaymentIncrement>? = null,
var projectIsPledgeOverTimeAllowed: Boolean = false,
) : Parcelable {
fun amountIsPledgeOverTimeEligible(amountIsPledgeOverTimeEligible: Boolean) = apply { this.amountIsPledgeOverTimeEligible = amountIsPledgeOverTimeEligible }
fun paymentIncrements(paymentIncrements: List<PaymentIncrement>?) = apply { this.paymentIncrements = paymentIncrements }
fun projectIsPledgeOverTimeAllowed(projectIsPledgeOverTimeAllowed: Boolean) = apply { this.projectIsPledgeOverTimeAllowed = projectIsPledgeOverTimeAllowed }
fun build() = PaymentPlan(
amountIsPledgeOverTimeEligible = amountIsPledgeOverTimeEligible,
paymentIncrements = paymentIncrements,
projectIsPledgeOverTimeAllowed = projectIsPledgeOverTimeAllowed,
)
}

Expand All @@ -36,15 +31,13 @@ data class PaymentPlan(
fun toBuilder() = Builder(
amountIsPledgeOverTimeEligible = amountIsPledgeOverTimeEligible,
paymentIncrements = paymentIncrements,
projectIsPledgeOverTimeAllowed = projectIsPledgeOverTimeAllowed,
)

override fun equals(other: Any?): Boolean {
var equals = super.equals(other)
if (other is PaymentPlan) {
equals = amountIsPledgeOverTimeEligible() == other.amountIsPledgeOverTimeEligible() &&
paymentIncrements() == other.paymentIncrements() &&
projectIsPledgeOverTimeAllowed() == other.projectIsPledgeOverTimeAllowed()
paymentIncrements() == other.paymentIncrements()
}
return equals
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,6 @@ fun paymentPlanTransformer(buildPaymentPlanResponse: BuildPaymentPlanQuery.Payme
return PaymentPlan.builder()
.paymentIncrements(paymentIncrements)
.amountIsPledgeOverTimeEligible(buildPaymentPlanResponse.amountIsPledgeOverTimeEligible)
.projectIsPledgeOverTimeAllowed(buildPaymentPlanResponse.projectIsPledgeOverTimeAllowed)
.build()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class CrowdfundCheckoutViewModel(val environment: Environment, bundle: Bundle? =
emitCurrentState(isLoading = false)
}
.collectLatest {
showPlotWidget = it.projectIsPledgeOverTimeAllowed
showPlotWidget = project.isPledgeOverTimeAllowed() == true
plotEligible = it.amountIsPledgeOverTimeEligible
paymentIncrements = it.paymentIncrements
emitCurrentState(isLoading = false)
Expand Down

0 comments on commit b6ab5da

Please sign in to comment.