This repository has been archived by the owner on May 6, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from Tolfix/dev
v1.9
- Loading branch information
Showing
32 changed files
with
1,660 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { resolverAdminAccess } from "../ResolverAccess"; | ||
import { composeWithMongoose } from "graphql-compose-mongoose"; | ||
import SubscriptionModel from "../../Models/Subscriptions.model"; | ||
|
||
export const SubscriptionGraphQL = composeWithMongoose(SubscriptionModel); | ||
export const startsWith = "Subscription"; | ||
export const SubscriptionQuery = { | ||
...resolverAdminAccess({ | ||
subscriptionById: SubscriptionGraphQL.getResolver("findById"), | ||
subscriptionByIds: SubscriptionGraphQL.getResolver("findByIds"), | ||
subscriptionOne: SubscriptionGraphQL.getResolver("findOne"), | ||
subscriptionMany: SubscriptionGraphQL.getResolver("findMany"), | ||
subscriptionCount: SubscriptionGraphQL.getResolver("count"), | ||
subscriptionConnection: SubscriptionGraphQL.getResolver("connection"), | ||
subscriptionPagination: SubscriptionGraphQL.getResolver("pagination"), | ||
}) | ||
} | ||
|
||
export const SubscriptionMutation = { | ||
...resolverAdminAccess({ | ||
subscriptionCreateOne: SubscriptionGraphQL.getResolver("createOne"), | ||
subscriptionCreateMany: SubscriptionGraphQL.getResolver("createMany"), | ||
subscriptionUpdateById: SubscriptionGraphQL.getResolver("updateById"), | ||
subscriptionUpdateOne: SubscriptionGraphQL.getResolver("updateOne"), | ||
subscriptionUpdateMany: SubscriptionGraphQL.getResolver("updateMany"), | ||
subscriptionRemoveById: SubscriptionGraphQL.getResolver("removeById"), | ||
subscriptionRemoveOne: SubscriptionGraphQL.getResolver("removeOne"), | ||
subscriptionRemoveMany: SubscriptionGraphQL.getResolver("removeMany"), | ||
}) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,7 @@ const CustomerSchema = new Schema | |
extra: { | ||
type: Object, | ||
required: false, | ||
default: {}, | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import mongoose, { Document, model, Schema } from "mongoose"; | ||
import increment from "mongoose-auto-increment"; | ||
import { MongoDB_URI } from "../../Config"; | ||
import { A_InvoiceStatus } from "../../Interfaces/Invoice.interface"; | ||
import { IQuotes } from "../../Interfaces/Quotes.interface"; | ||
import { ISubscription } from "../../Interfaces/Subscriptions.interface"; | ||
import Logger from "../../Lib/Logger"; | ||
import GetText from "../../Translation/GetText"; | ||
import { A_CC_Payments, A_RecurringMethod } from "../../Types/PaymentMethod"; | ||
|
||
const SubscriptionSchema = new Schema | ||
( | ||
{ | ||
|
||
id: Number, | ||
|
||
uid: { | ||
type: String, | ||
required: false, | ||
description: GetText().txt_Uid_Description, | ||
}, | ||
|
||
customer_uid: { | ||
type: String, | ||
required: true, | ||
}, | ||
|
||
products: { | ||
type: [ | ||
{ | ||
product_id: Number, | ||
configurable_options_ids: { | ||
type: [ | ||
{ | ||
id: Number, | ||
option_index: Number, | ||
}, | ||
], | ||
required: false | ||
}, | ||
quantity: Number, | ||
} | ||
], | ||
required: true, | ||
}, | ||
|
||
promotion_codes: { | ||
type: [Number], | ||
default: [] | ||
}, | ||
|
||
renewing_method: { | ||
type: String, | ||
enum: [...A_RecurringMethod], | ||
required: true, | ||
}, | ||
|
||
payment_method: { | ||
type: String, | ||
enum: ["credit_card", "paypal"], | ||
default: "credit_card", | ||
}, | ||
|
||
status: { | ||
type: String, | ||
enum: [...A_InvoiceStatus], | ||
default: "active", | ||
}, | ||
|
||
start_date: { | ||
type: String, | ||
required: true, | ||
}, | ||
|
||
transactions: { | ||
type: [Number], | ||
default: [], | ||
} | ||
|
||
} | ||
); | ||
|
||
// Log when creation | ||
SubscriptionSchema.post('save', function(doc: IQuotes & Document) | ||
{ | ||
Logger.db(GetText().database.txt_Model_Created(doc.modelName, doc.uid)); | ||
// Logger.db(`Created Quotes ${doc.id}`); | ||
}); | ||
|
||
const connection = mongoose.createConnection(MongoDB_URI); | ||
increment.initialize(connection); | ||
|
||
SubscriptionSchema.plugin(increment.plugin, { | ||
model: 'subscription', | ||
field: 'id', | ||
startAt: 0, | ||
incrementBy: 1 | ||
}); | ||
|
||
const SubscriptionModel = model<ISubscription & Document>("subscription", SubscriptionSchema); | ||
|
||
export default SubscriptionModel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export default ` | ||
width: 100%; | ||
border-collapse: collapse; | ||
thead th, | ||
tfoot th, | ||
thead th, | ||
tfoot th { | ||
border-bottom: 1px solid #999; | ||
text-align: left; | ||
margin: 0; | ||
padding: 7px 5px; | ||
} | ||
tbody tr td, | ||
tbody tr td { | ||
margin: 0; | ||
padding: 7px 5px; | ||
border-top: 1px solid #E6E6E6; | ||
} | ||
` |
Oops, something went wrong.