Skip to content

Commit

Permalink
Merge pull request #214 from StoriqaTeam/feature/subscription
Browse files Browse the repository at this point in the history
Fill trial start date
  • Loading branch information
serejkaaa512 authored Mar 5, 2019
2 parents 9611a92 + c2b9713 commit 423cab9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/models/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub struct NewStoreSubscription {
pub currency: Currency,
pub value: Amount,
pub wallet_address: Option<WalletAddress>,
pub trial_start_date: Option<NaiveDateTime>,
}

#[derive(Clone, Debug, Default, Serialize, Deserialize, AsChangeset)]
Expand Down
2 changes: 2 additions & 0 deletions src/services/store_subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl<
currency: payload.currency,
value: Amount::new(DEFAULT_EUR_CENTS_AMOUNT),
wallet_address: None,
trial_start_date: None,
})),
Currency::Stq => create_store_subscription_account(account_service, store_id),
Currency::Eth | Currency::Btc | Currency::Usd | Currency::Rub => {
Expand Down Expand Up @@ -213,6 +214,7 @@ fn create_store_subscription_account<AS: AccountService>(account_service: AS, st
currency: Currency::Stq,
value: Amount::new(DEFAULT_STQ_WEI_AMOUNT),
wallet_address: Some(account.wallet_address),
trial_start_date: None,
});
Box::new(fut)
}
3 changes: 2 additions & 1 deletion src/services/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<

match store_subscription.status {
StoreSubscriptionStatus::Trial => {
let trial_duration = store_subscription.trial_start_date.ok_or({
let trial_duration = store_subscription.trial_start_date.ok_or_else(|| {
let e = format_err!("Store {} has empty trial start time", store_id);
ectx!(try err e, ErrorKind::Internal)
})? - now;
Expand Down Expand Up @@ -162,6 +162,7 @@ fn find_update_or_create_store_subscription(
currency: DEFAULT_CURRENCY,
value: Amount::new(DEFAULT_EUR_CENTS_AMOUNT),
wallet_address: None,
trial_start_date: Some(now),
};

store_subscription_repo.create(new_store_subscription)
Expand Down

0 comments on commit 423cab9

Please sign in to comment.