Skip to content
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

feat: Add Wallet Consumed Amount #356

Merged
merged 4 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/graphql/resolvers/wallets_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def resolve(customer_id: nil, ids: nil, page: nil, limit: nil, status: nil)
wallets = wallets.where(status: status) if status.present?
wallets = wallets.where(id: ids) if ids.present?

wallets
wallets.order(status: :asc, created_at: :desc)
rescue ActiveRecord::RecordNotFound
not_found_error
end
Expand Down
2 changes: 2 additions & 0 deletions app/graphql/types/mutation_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ class MutationType < Types::BaseObject
field :create_customer_wallet, mutation: Mutations::Wallets::Create
field :update_customer_wallet, mutation: Mutations::Wallets::Update
field :terminate_customer_wallet, mutation: Mutations::Wallets::Terminate

field :create_customer_wallet_transaction, mutation: Mutations::WalletTransactions::Create
end
end
1 change: 1 addition & 0 deletions app/graphql/types/wallets/object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Object < Types::BaseObject
field :currency, Types::CurrencyEnum, null: false
field :credits_balance, String, null: false
field :balance, String, null: false
field :consumed_amount, String, null: false
field :consumed_credits, String, null: false

field :expiration_date, GraphQL::Types::ISO8601Date, null: true
Expand Down
7 changes: 7 additions & 0 deletions db/migrate/20220801101144_add_consumed_amount_to_wallets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddConsumedAmountToWallets < ActiveRecord::Migration[7.0]
def change
add_column :wallets, :consumed_amount, :decimal, default: 0, precision: 5
end
end
6 changes: 4 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1617,6 +1617,19 @@ input CreateCustomerWalletInput {
rateAmount: String!
}

"""
Autogenerated input type of CreateCustomerWalletTransaction
"""
input CreateCustomerWalletTransactionInput {
"""
A unique identifier for the client performing the mutation.
"""
clientMutationId: String
grantedCredits: String!
paidCredits: String!
walletId: ID!
}

"""
Autogenerated input type of CreatePlan
"""
Expand Down Expand Up @@ -2777,6 +2790,16 @@ type Mutation {
input: CreateCustomerWalletInput!
): Wallet

"""
Creates a new Customer Wallet Transaction
"""
createCustomerWalletTransaction(
"""
Parameters for CreateCustomerWalletTransaction
"""
input: CreateCustomerWalletTransactionInput!
): WalletTransaction

"""
Creates a new Plan
"""
Expand Down Expand Up @@ -3562,6 +3585,7 @@ type User {

type Wallet {
balance: String!
consumedAmount: String!
consumedCredits: String!
createdAt: ISO8601DateTime!
creditsBalance: String!
Expand All @@ -3585,6 +3609,7 @@ type WalletCollection {

type WalletDetails {
balance: String!
consumedAmount: String!
consumedCredits: String!
createdAt: ISO8601DateTime!
creditsBalance: String!
Expand Down
136 changes: 136 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4773,6 +4773,77 @@
],
"enumValues": null
},
{
"kind": "INPUT_OBJECT",
"name": "CreateCustomerWalletTransactionInput",
"description": "Autogenerated input type of CreateCustomerWalletTransaction",
"interfaces": null,
"possibleTypes": null,
"fields": null,
"inputFields": [
{
"name": "clientMutationId",
"description": "A unique identifier for the client performing the mutation.",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "walletId",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "paidCredits",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "grantedCredits",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"enumValues": null
},
{
"kind": "INPUT_OBJECT",
"name": "CreatePlanInput",
Expand Down Expand Up @@ -8927,6 +8998,35 @@
}
]
},
{
"name": "createCustomerWalletTransaction",
"description": "Creates a new Customer Wallet Transaction",
"type": {
"kind": "OBJECT",
"name": "WalletTransaction",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null,
"args": [
{
"name": "input",
"description": "Parameters for CreateCustomerWalletTransaction",
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "CreateCustomerWalletTransactionInput",
"ofType": null
}
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
}
]
},
{
"name": "createPlan",
"description": "Creates a new Plan",
Expand Down Expand Up @@ -13362,6 +13462,24 @@

]
},
{
"name": "consumedAmount",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null,
"args": [

]
},
{
"name": "consumedCredits",
"description": null,
Expand Down Expand Up @@ -13682,6 +13800,24 @@

]
},
{
"name": "consumedAmount",
"description": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "String",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null,
"args": [

]
},
{
"name": "consumedCredits",
"description": null,
Expand Down