giseldo/neodataset huggingface dataset:
Create new subscription for CI Minutes if customer doesn't have an active subscription

Created by @doniquesmit 

## :reminder_ribbon:  &nbsp; Note to the engineer working on this issue

Additional context and customer cases can be found in this related issue https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/1485

## Description

- Customer tries to make a purchase for a CI minute pack, but the purchase fails with error: "Body: {"results"=>[{"Success"=>false, "Errors"=>[{"Code"=>"INVALID_VALUE", "Message"=>"The Contract effective date should not be later than the term end date of the basic subscription."}]}]}"
- Customer does have previous CI minute purchase showing as subscription widget
- Namespace is linked to the previous CI minute purchase
- SE tried to clear namespace linked with CI minute purchase, but this fails

## Customer info

- [Zuora account](https://www.zuora.com/apps/CustomerAccount.do?method=view&id=2c92a00e6f1e0d65016f31c3b0ea6b2b)
- [Customers portal](https://customers.gitlab.com/admin/customer/141666/edit)
- [ZD ticket](https://gitlab.zendesk.com/agent/tickets/212579)

## Sentry error

https://sentry.gitlab.net/gitlab/customersgitlabcom/issues/2550053/?referrer=gitlab_plugin

```
Stacktrace (most recent call first):

  lib/gitlab/logger_helpers.rb:24:in `public_send'
    Gitlab::Logger.public_send(log_level, object, options) # rubocop:disable GitlabSecurity/PublicSend
  lib/gitlab/logger_helpers.rb:24:in `log'
    Gitlab::Logger.public_send(log_level, object, options) # rubocop:disable GitlabSecurity/PublicSend
  lib/gitlab/logger_helpers.rb:13:in `log_error'
    log(:error, error, extra: extra)
  app/jobs/zuora/actions/amend.rb:11:in `rescue in perform'
    log_error(
  app/jobs/zuora/actions/amend.rb:6:in `perform'
    def perform(requests)
  lib/zuora/subscription.rb:33:in `amend'
    Zuora::Actions::Amend.perform_now(requests)
  app/services/amendment_base_service.rb:138:in `send_zuora_amendment_request'
    sort_amend_result(format_amend_result(Zuora::Subscription.amend([options])))
  app/services/amendment_base_service.rb:33:in `amend!'
    send_zuora_amendment_request(options)
  app/services/amend_subscription_service.rb:31:in `execute'
    result = amend!
  app/controllers/subscriptions_controller.rb:63:in `update'
    result = AmendSubscriptionService.new(@subscription, permitted_params_for_update).execute
...
(114 additional frame(s) were not displayed)

[IronBank] Failed to amend record
```

Story points: 2.0
Update Subscription Story with new manage action

<!-- Please complete the template below as best as you can. Make sure to check if this issue has already been raised by someone else first to avoid duplication. 

For each section below, please add screenshots or links or anything that may help visual learners understand the problem better, even if this takes you an extra minute or two this is a great help to some folks.

https://www.learning-styles-online.com/style/visual-spatial/

-->

### Situation

We recently introduced a new UI element in the Subscription Component to make it possible for customers to copy an `Activation Code` (gitlab-org/customers-gitlab-com#3006). See example here:

||
|-|
|![](https://gitlab.com/gitlab-org/customers-gitlab-com/uploads/06008e55d9154849ffe5ddb36442c7da/Screenshot_2021-04-27_at_07.28.59.png)|

(There's also have a `Copy license file` action and the 2 actions are mutually exclusive).

### Complication

The Subscription story does not contain a case for this meaning the smoke tests are not taking this scenario into account.

### Proposal

Given we added storyshots for smoke tests (gitlab-org/customers-gitlab-com#932), let's add this scenario to the Subscription stories.

### Result

Besides having the new scenario covered, we would expect a (slight) increase in coverage.

Story points: 2.0
Expired subscriptions - failing to retrieve one subscription stops the entire downgrade task

### Summary

When running the expired subscription downgrade task in production, the following error can be triggered:

```text
rake aborted!
Faraday::ConnectionFailed: execution expired
/home/gitlab-customers/customers-gitlab-com/vendor/bundle/ruby/2.6.0/gems/faraday-0.17.3/lib/faraday/adapter/net_http.rb:87:in `perform_request'
[...]
/home/gitlab-customers/customers-gitlab-com/vendor/bundle/ruby/2.6.0/gems/iron_bank-4.4.1/lib/iron_bank/cacheable.rb:41:in `where'
/home/gitlab-customers/customers-gitlab-com/app/models/customer.rb:120:in `block in raw_subscriptions'
/home/gitlab-customers/customers-gitlab-com/lib/utils/strong_memoize.rb:27:in `strong_memoize'
/home/gitlab-customers/customers-gitlab-com/app/models/customer.rb:119:in `raw_subscriptions'
/home/gitlab-customers/customers-gitlab-com/app/finders/subscriptions_finder.rb:69:in `subscriptions'
/home/gitlab-customers/customers-gitlab-com/app/finders/subscriptions_finder.rb:22:in `by_id_or_name'
/home/gitlab-customers/customers-gitlab-com/app/models/customer.rb:96:in `find_subscription'
/home/gitlab-customers/customers-gitlab-com/app/models/order.rb:131:in `subscription'
/home/gitlab-customers/customers-gitlab-com/app/services/check_order_in_sync_service.rb:69:in `zuora_subscription'
/home/gitlab-customers/customers-gitlab-com/app/services/check_order_in_sync_service.rb:34:in `end_date_in_sync_with_zuora?'
/home/gitlab-customers/customers-gitlab-com/app/services/check_order_in_sync_service.rb:11:in `execute'
/home/gitlab-customers/customers-gitlab-com/app/services/check_order_in_sync_service.rb:5:in `execute'
/home/gitlab-customers/customers-gitlab-com/app/jobs/expire_order_job.rb:16:in `perform'
[...]
```

(This error on [Sentry](https://sentry.gitlab.net/gitlab/customersgitlabcom/issues/2626906/))

This error, which can happen randomly, means that we didn't manage to retrieve a subscription for a given order from Zuora.

### Steps to reproduce

run the `orders:downgrade_expired_subscriptions` task in production.

### What is the current *bug* behavior?

Error triggers and rake task stops.

### What is the expected *correct* behavior?

The fact that we get this error when retrieving a subscription for one order should not be a reason to stop the rake task, we should carry on in processing the remaining orders.

Story points: 2.0
Follow up: Notification on unlinked subscriptions execution

### Problem

:warning: We don't expect any code to be delivered as part of this effort, this issue is to consistently track any unexpected event in the first executions of `OrphanedComSubscriptionEmailCronJob`

https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/1887 introduced a cron job to notify customers about paid .com subscriptions that are not linked to a GitLab namespace.

This job will run weekly on Mondays:
- For the first Monday of the month it will notify all active + paid + .com + unlinked subscriptions
- For any other monday it will refine this sets to subscriptions created in the last 36 days

We want to follow up on the first executions and validate there are no unexpected failures:
- [x] Monday, May 17th 
- [x] Monday, May 24th
- [x] Monday, May 31st
- [x] Monday, May 7th (Bigger run without the `last 36 days restriction`

### Proposal

For the provided dates:
- Check Sentry and the sidekiq queues for any unexpected behavior.
- Update this issue.

Story points: 1.0
Use metadata to set feature tag for feature specs

The following discussion from !3209 should be addressed:

- [ ] @ddavison started a [discussion](https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/3209#note_570157634): 

    > _Nonblocker comment_ It's odd we don't derive this metadata from the `spec/features/*` directory.  Maybe we should consider doing this later:
    > 
    > ```ruby
    > #=> spec_helper.rb pseudo
    > RSpec.configure do |config|
    >   config.define_derived_metadata(path: %r{/spec/feature}) do |meta|
    >     meta[:feature] = true
    >   end
    > end
    > ```
    > 
    > That way we could omit the adding the arguably superfluous `:feature` tag.

Story points: 1.0
Remove individual usages of aggregate_failures

## Problem

In https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/3214#note_571133280 `aggregate_failures` was used within an individual test case. Although `aggregate_failures` is enabled for the [whole test suite](https://gitlab.com/gitlab-org/customers-gitlab-com/-/blob/a17ae042dae80ec4803a36bb983b3a2bc6c8b372/spec/spec_helper.rb#L46). Looking through the code showed that there are a few places where this setting is explicitly set for individual test cases or spec files.

## Proposal

Clean those places up to fall back to the global setting of `aggregate_failures`.

## Result

No mixed usage of `aggregate_failures` throughout the test suite.

Story points: 1.0
Include product title in success modal

### Proposal

In `app/frontend/javascripts/purchase/components/purchase_success_modal.vue`, 

When a subscription is purchased, we want to show the product title in the success confirmation modal below the title, as show in the screenshot:

<img src="/uploads/012feedf63b840568c06e8044c9f64da/Screen_Shot_2021-05-06_at_10.47.21.png" width="800"/>

### Details 

We've 2 places where new subscription purchases could happen:

- `new_ee_subscription.vue` for self-managed subscriptions
- `new_gitlab_subscription.vue` for GitLab.com subscriptions

We could leverage Vue [slots](https://vuejs.org/v2/guide/components-slots.html) or find a better solution.

Story points: 2.0
Replace clipboard.js usage with ClipboardAPI

## Problem

For copying text to clipboard we’re using `clipboard.js` that use `document.execCommand('copy')`.

MDN says using the mention method above [is discouraged](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand), alternatively we can use [Clipboard API](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard#using_the_clipboard_api).

`clipboard.js` has a [stale closed issue](https://github.com/zenorocha/clipboard.js/issues/683) about using the Clipboard API, but no maintainer has dropped by.

Clipboard API is [supported](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API#browser_compatibility) by the browsers that [GitLab supports](https://docs.gitlab.com/ee/install/requirements.html#supported-web-browsers).

## Proposal

Replace `clipboard.js` usage with the new Clipboard API.

Example of using the Clipboard API: https://gitlab.com/atlas-italia/atlas-sdmx/-/blob/main/src/components/SmdXplorer/index.ts#L57

- [x] Remove `no-enforce-focus` property [`purchase_success_modal.vue`](https://gitlab.com/gitlab-org/customers-gitlab-com/-/blob/00c5a795850c266bc37d5e7e4415f1781cd4127a/app/frontend/javascripts/purchase/components/purchase_success_modal.vue#L58-60) if !3182 is merged before this one.

Story points: 2.0
Onboard new team member

<!-- Please complete the template below as best as you can. Make sure to check if this issue has already been raised by someone else first to avoid duplication. 

For each section below, please add screenshots or links or anything that may help visual learners understand the problem better, even if this takes you an extra minute or two this is a great help to some folks.

https://www.learning-styles-online.com/style/visual-spatial/

-->

We've got a new engineer joining the Fulfillment FE Purchase team - yay!

This issue captures the time allocation our onboarding buddy will need to be a good onboarding buddy :)

### TODO

- https://gitlab.com/gitlab-org/fulfillment-meta/-/issues/215
- https://gitlab.com/gitlab-org/frontend/onboarding/-/issues/14
- https://gitlab.com/gitlab-com/team-member-epics/employment/-/issues/2740

Story points: 3.0
Remove unused VCR cassettes and fix prefix for detection

### Problem

While working on https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2748, an investigated VCR cassette didn't have a corresponding spec. While digging further into this it turned out that it isn't used at all. After running the test suite to detect unused cassettes with a command (`VCR_REPORT_UNUSED_CASSETTES=true bundle exec rspec`) from the my local reverse search in the terminal, nothing turned up. Looking into to the definition of the prefix, it turned out that only `1` is accepted as a value. Previously `true` was also working but that was changed in https://gitlab.com/gitlab-org/customers-gitlab-com/-/merge_requests/2579.

It also turns out that the CI/CD variable for `VCR_REPORT_UNUSED_CASSETTES` for the pipelines is set to `true`.

### Proposal

- [x] Remove all unused VCR cassettes
- [x] ~~Change value for CI/CD variable to `1`~~ A better suggestion came up [in Slack](https://gitlab.slack.com/archives/CMJ8JR0RH/p1619767112159100?thread_ts=1619700985.141000&cid=CMJ8JR0RH) about removing the CI/CD variable the value is already set via the [.gitlab-ci.yml](https://gitlab.com/gitlab-org/customers-gitlab-com/-/blob/3f5f471ba8dadc29f3f1e5b4914be59c0e8d72ae/.gitlab-ci.yml#L42).

### Result

- Removal of unused VCR cassettes from the code.
- RSpec job in CI pipeline detects unused VCR cassettes again

Story points: 1.0
Add test coverage for EoaStarterBronze::AutoRenewService

# Problem
While working on !3160 and renaming `EoaAutoRenewService` to `EoaStarterBronze::AutoRenewService`, no test coverage for the class or the rake task (`lib/tasks/iron_bank.rake`) that uses it was found.

# Proposal

Add test coverage for at least the service class.

Story points: 1.0
Effective Price should use Invoice Item - Unit Price, not Invoice Item - Charge Amount.

<!-- Please complete the template below as best as you can. Make sure to check if this issue has already been raised by someone else first to avoid duplication. 

For each section below, please add screenshots or links or anything that may help visual learners understand the problem better, even if this takes you an extra minute or two this is a great help to some folks.

https://www.learning-styles-online.com/style/visual-spatial/

-->

### Problem

@a_luna @amandarueda looking at the data coming over to salesforce, it looks like we had a bad mapping for what we are sending to Effective Price: https://gitlab.com/gitlab-org/customers-gitlab-com/-/blob/staging/app/services/salesforce/create_opportunity_objects_service.rb#L310

That line should be using the Invoice Item Unit Price field and not the Charge Amount. I see that this object is created by Zuora::InvoiceItem, and want to make sure that this might be an additional field it needs instead of a complete change at that level as I do not know what else is using the Charge Amount.

### Proposal

The `effective_price` value sent to the [`CreateRatePlanChargeService`](https://gitlab.com/gitlab-org/customers-gitlab-com/-/blob/9f0fd64a397a5fc3ff3ea3a5e9131ac7fd3f30c9/app/services/salesforce/create_quote_rate_plan_charge_service.rb) should map to `InvoiceItem->Unit Price` instead of `InvoiceItem->Charge Amount`.

[This line](https://gitlab.com/gitlab-org/customers-gitlab-com/-/blob/staging/app/services/salesforce/create_opportunity_objects_service.rb#L310) needs to change to `effective_price: invoice_item.unit_price`

### Result

### Next steps (if any)

### How will we measure success?

Story points: 2.0
AutoRenewJob fails for no credit_card_expiration_year

### Problem

When fetching the default payment for a customer, the default payment returns as a 'Credit Card' and it do exists within Zuora but some of the fetched Credit Cards payments has the `credit_card_expiration_year` and `credit_card_expiration_month` as nil.

Due to which the [check here](https://gitlab.com/gitlab-org/customers-gitlab-com/-/blob/staging/app/services/auto_renew_service.rb#L40) results in throwing an exception `TypeError: no implicit conversion from nil to integer` 

### Proposal

Check for the presence of `credit_card_expiration_year` and `credit_card_expiration_month` before checking whether the credit card date is valid 

https://sentry.gitlab.net/gitlab/customersgitlabcom/issues/2586755/?query=is%3Aunresolved

https://customers.gitlab.com/sidekiq/retries

Story points: 1.0
Additional indexes on license_seat_link

### Problem
Nearly every day customers.gitlab.com suffers degraded performance between 00:00 and 01:00 UTC, for a few minutes at least, often paging the SRE on-call because our blackbox probes are failing.  For the latest example, see https://gitlab.com/gitlab-com/gl-infra/production/-/issues/4314

### Proposal
Add two indexes to license_seat_link, on `report_timestamp` and `zuora_subscription_name`, to make the queries more efficient than having to perform a full sequential scan of the entire table.

### Result

Hopefully better uptime/performance and fewer pages for the on-call SRE

### Next steps (if any)

### How will we measure success?

Number of pages for the on-call SRE

Story points: 1.0
BE: Create CI Minutes architecture proposal

### Summary

As part of https://gitlab.com/groups/gitlab-org/-/epics/5715, we need to draft an initial proposal of how CI provisioning can be implemented.

At a high level, this should include:

- Storing CI minute purchases
- Syncing/Updating GitLab.com with CI minute purchases
- Retrieving current CI minute usage statistics
- more tbc.

Further information and a summary can be found here: https://gitlab.com/groups/gitlab-org/-/epics/4331#note_529739414

Story points: 2.0
Remove batch_id and headers from coupon generator csv

Based on conversation [here](https://gitlab.com/gitlab-com/marketing/community-relations/community-operations/community-operations/-/issues/75#note_557366613) two things need to happen:

* Remove `.csv` `batch_id` column
* Remove `.csv` headers

https://gitlab.com/gitlab-org/customers-gitlab-com/blob/4a1d1c718f408ee3c5edaaaf6e107341c7b3944e/app/services/coupons/export_service.rb#L3
 

### Problem

### Proposal

### Result

### Next steps (if any)

### How will we measure success?

Story points: 1.0
Community Programs Self-Checkout - Controllers/views/routes for Community Programs

As part of https://gitlab.com/groups/gitlab-org/-/epics/5712 users will be guided to CustomersDot to claim their subscription/license

### TODO

Create controllers/views/routes to support:

* [SaaS or Self-Managed landing page](https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/3010)
  ```bash
  customers.gitlab.com/subscriptions/community_program/new?coupon_code=<COUPON>&product=<PRODUCT>
    # renders: /subscriptions/community_program/new.html.haml
  ```
* Community program SaaS purchase route
  ```bash
  customers.gitlab.com/subscriptions/community_program/new?coupon_code=<COUPON>&product=<PRODUCT>&edition=saas
    # renders: /subscriptions/community_program/new_saas.html.haml
  ```
* Community program self-managed purchase route
  ```bash
  customers.gitlab.com/subscriptions/community_program/new?coupon_code=<COUPON>&product=<PRODUCT>&edition=self_managed
    # renders: /subscriptions/community_program/new_self_managed.html.haml
  ```

`<COUPON>` = coupon code (ie 123456)
`<PRODUCT>` = one of `['oss', 'edu', 'startup']` (case insensitive)

If the user is not authenticated the action will redirect to sign-in/register first.
If the FF is disabled, or the requested product cannot be found, the action will redirect to the plans page.

Story points: 5.0
SaaS - Community Programs Self-Checkout - Coupon code input

As part of https://gitlab.com/groups/gitlab-org/-/epics/5068 users will be guided to CustomersDot need input the coupon code they've received.

[Designs](https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2677/designs/Community_programs_checkout___Invalid_coupon_code_error.png)


![image](/uploads/196f6cc2c92d5541d007507af9f48688/image.png)


### TODO

1. Add input field for coupon code
1. Pass coupon code to API payload when purchasing subscription following https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2362
1. Render error message inline if code is consumed `This code has already been used.` or not valid `This code is not valid. Try re-entering the code from your email`

### How to see the pages

- Make sure you've the [`community_program_coupons`](https://gitlab.com/gitlab-org/customers-gitlab-com/-/feature_flags/91/edit) enabled for your setup.
- Login to your CustomersDot
- Navigate to any of:
  - `/subscriptions/community_program/new?edition=self_managed&coupon_code=coupon_test&product=oss`
  - `/subscriptions/community_program/new?edition=saas&coupon_code=coupon_test&product=oss`

Story points: 2.0
Community Programs Self-Checkout - namespace-select

As part of https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2363#note_551260268 users will be guided to CustomersDot to apply their SaaS subscription. If they do not have groups created or correct ownership they need to address this problem in GitLab.com

[Designs](https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2677/designs/SaaS_-_Community_programs_checkout___No_group_error_state.png)


![image](/uploads/1edd41d1ebc902d1086478219db38bc6/image.png)


### TODO

1. Modify `namespace-select` to have [clarifying information  on  Owner permission](https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2677/designs/SaaS_-_Community_programs_checkout___No_group_error_state.png#note_547892789)
1. Modify `namespace-select` to give danger alert and a link to GL.com [if no groups are detected](https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2677/designs/SaaS_-_Community_programs_checkout___No_group_error_state.png#note_543289696)

Story points: 3.0
Community Programs Self-Checkout - subscription-details component

As part of https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2363#note_551260268

[Designs](https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2677/designs/SaaS_-_Community_programs_checkout.png)


![image](/uploads/1b55105d3393b825ae68481c4a6c64ca/image.png)


### TODO

When creating this component, it needs a flag to hide prices for community program

1. Extract component from existing purchase flows
1. Consume component in Self-Managed community program self-checkout

### How to see the pages

- Make sure you've the [`community_program_coupons`](https://gitlab.com/gitlab-org/customers-gitlab-com/-/feature_flags/91/edit) enabled for your setup.
- Login to your CustomersDot

- Navigate to any of:
  - [/subscriptions/community_program/new?product=edu&edition=self_managed](http://localhost:5000/subscriptions/community_program/new?product=edu&edition=self_managed)
  - [/subscriptions/community_program/new?coupon_code=coupon_test&product=oss&edition=self_managed](http://localhost:5000/subscriptions/community_program/new?coupon_code=coupon_test&product=oss&edition=self_managed)
  - [/subscriptions/community_program/new?product=startup&edition=self_managed](http://localhost:5000/subscriptions/community_program/new?product=startup&edition=self_managed)

Story points: 5.0
Community Programs Self-Checkout - purchase-confirmation-card allow for no CC

As part of https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2363#note_551260268 users will be able to complete the checkout flow of community programs without giving a credit card.

![image](/uploads/6fdc044bc30c8b210daf5353aa61270e/image.png)


### TODO

1. control showing payment methods and make `paymentMethods` prop optional
1. IMPORTANT it should be explicitly opt-in to not enter a credit card. In the majority of our flows the user has to give a credit card, this should be the default.

Story points: 2.0
Community Programs Self-Checkout - Skeleton apps

As part of https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/2363#note_547510966 we'll have two purchase flows. SaaS and Self-Managed. This issue covers creating skeleton apps we can iterate on.


### TODO

* Pass variables from HAML and query string to Vue app
* "Claim subscription" title
* dynamic subtitle
* form placeholder
* identify if this is EDU | Start-up | OSS

Story points: 2.0