Skip to content

Instantly share code, notes, and snippets.

@Oluwasetemi
Last active August 23, 2022 14:49
Show Gist options
  • Save Oluwasetemi/dfe7c6ecf797f5f8fff66576592fa832 to your computer and use it in GitHub Desktop.
Save Oluwasetemi/dfe7c6ecf797f5f8fff66576592fa832 to your computer and use it in GitHub Desktop.
current and updated schema for fluna-web-app
# This "input" configures a global authorization rule to enable public access to
# all models in this schema. Learn more about authorization rules here: https://docs.amplify.aws/cli/graphql/authorization-rules
input AMPLIFY {
globalAuthRule: AuthRule = { allow: public }
} # FOR TESTING ONLY!
type User
@model
@auth(
rules: [
{ allow: groups, groups: ["Admin"] }
{ allow: owner }
{ allow: private, operations: [read] }
]
) {
id: ID!
owner: String
@index(name: "byUser", queryField: "userByOwner", sortKeyFields: ["id"])
firstName: String
lastName: String
email: String
role: String
phone: String
signUpLocation: String
signUpTimezone: String
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
company: Company @belongsTo
payments: [Payments] @hasMany
}
type Company
@model
@auth(
rules: [
{ allow: groups, groups: ["Admin"] }
{ allow: owner }
{ allow: private, operations: [read] }
{ allow: public, operations: [read] }
]
) {
id: ID!
name: String
legalName: String
industryType: String
country: String
city: String
website: String
incorporationYear: String
businessDescription: String
numberOfFullTimeEmployees: Int
numberOfPartTimeEmployees: Int
typesOfCustomers: TypeOfCustomer
signUpAverageMonthlyRevenue: Int
signUpCreditCurrency: String
signUpCreditAmount: Int
treasuryNeeds: [TreasuryNeeds]
proofOfAddressType: String
stage: CompanyStage
proofOfAddress: String
countriesWhereCompanyHaveAccount: [String]
currencyOverride: AWSJSON
baseCurrency: String
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
owner: String
@index(name: "byOwner", queryField: "companyByOwner", sortKeyFields: ["id"])
user: [User] @hasMany
account: [Account] @hasMany
wallet: [Wallet] @hasMany
payments: [Payments] @hasMany
transaction: [Transaction] @hasMany
category: [Category] @hasMany
companyKYCStatus: CompanyKYCStatus
companyDocuments: [CompanyDocuments]
@hasMany(indexName: "byCompanyDocuments", fields: ["id"])
ownershipDetails: [OwnershipDetails]
@hasMany(indexName: "byOwnershipDetails", fields: ["id"])
rules: [RulesInfo]
}
type Account
@model
@searchable
@auth(
rules: [
{ allow: groups, groups: ["Admin"] }
{ allow: owner }
{ allow: private, operations: [create, read, update] }
{ allow: public, operations: [read] }
]
) {
id: ID!
accountId: ID
@index(
name: "byAccountId"
queryField: "accountByAccountId"
sortKeyFields: ["id"]
)
accountNickname: String
accountName: String
lastUpdatedDate: String
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
currency: String
accountType: String
accountNumber: String
accountToken: String
reAuthorize: Boolean
owner: String
@index(name: "byOwner", queryField: "accountByOwner", sortKeyFields: ["id"])
vendor: Vendor @belongsTo
bank: Bank @belongsTo
company: Company @belongsTo
recipient: Recipients @belongsTo
transaction: [Transaction] @hasMany
bankAccountNumber: String
routing: String
wireRouting: String
eftAccountNumber: String
eftInstitution: String
eftBranch: String
ibanAccountNumber: String
bicNumber: String
bacsAccountNumber: String
bacsSortCode: String
lastTransactionDate: String
wallet: Wallet @hasOne
balance: Float
accountCreationType: AccountCreationTypes
accountTransferType:AccountTransferTypes
}
enum AccountTransferTypes {
Local
International
}
enum AccountCreationTypes {
Mono
Plaid
Recipient
Wallet
}
type Vendor @model {
id: ID!
vendorName: String!
@index(
name: "byVendorName"
queryField: "vendorByVendorName"
sortKeyFields: ["id"]
)
vendorLogo: String
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
account: [Account] @hasMany
}
type Bank @model {
id: ID!
bankName: String
@index(
name: "byBankName"
queryField: "bankByBankName"
sortKeyFields: ["id"]
)
bankLogo: String
createdAt: AWSDateTime!
bankCode: String
@index(
name: "byBankCode"
queryField: "bankByCode"
sortKeyFields: ["id"]
)
updatedAt: AWSDateTime!
account: [Account] @hasMany
wallet: [Wallet] @hasMany
country: Country @belongsTo
}
type Transaction @model @auth(
rules: [
{ allow: groups, groups: ["Admin"] }
{ allow: owner }
{ allow: private, operations: [read, update] }
{ allow: public, operations: [read, update] }
]
) {
id: ID!
description: String
entity: String
categoryVendor: String
categoryStandardized: String
categoryUser: String
amount: Int
currency: String
channel: String
type: String
date: String
time: String
dateCreated: String
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
account: Account @belongsTo
company: Company @belongsTo
}
type Country @model {
id: ID!
countryName: String
@index(
name: "byCountryName"
queryField: "countryByCountryName"
sortKeyFields: ["id"]
)
countryFlag: String
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
vendorId: ID
region: String
@index(
name: "byRegion"
queryField: "countryByRegion"
sortKeyFields: ["id"]
)
currency: String
vendorSupported: Vendor @hasOne(fields: ["vendorId"])
bank: [Bank] @hasMany
}
type Currency @model {
id: ID!
base: String
rates: AWSJSON
dataCreated: String
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
}
type ExchangeRates @model {
id: ID!
currencyPair: String
buyPrice: Float
sellPrice: Float
baseCurrency: String
converteredCurrency: String
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
}
type TransactionActivities {
transactionid: String
accountid: String
companyid: String
description: String
entity: String
categoryvendor: String
categorystandardized: String
categoryuserrule: String
categoryuser: String
amount: Float
currency: String
channel: String
type: String
date: String
time: String
datecreated: String
iscash: Boolean
}
type TransactionActivitiesRecord {
transactionid: String
accountid: String
companyid: String
description: String
entity: String
categoryvendor: String
categorystandardized: String
categoryuser: String
amount: Float
currency: String
channel: String
type: String
date: String
datecreated: String
iscash: Boolean
}
input ModelTransactionActivitiesRecordFilterInput {
transactionid: ModelStringInput
accountid: ModelStringInput
companyid: ModelStringInput
description: ModelStringInput
entity: ModelStringInput
categoryVendor: ModelStringInput
categoryStandardized: ModelStringInput
categoryUser: ModelStringInput
amount: ModelFloatInput
currency: ModelStringInput
channel: ModelStringInput
type: ModelStringInput
date: ModelStringInput
datecreated: ModelStringInput
iscash: ModelBooleanInput
and: [ModelTransactionActivitiesRecordFilterInput]
or: [ModelTransactionActivitiesRecordFilterInput]
not: ModelTransactionActivitiesRecordFilterInput
}
enum ModelAttributeTypes {
binary
binarySet
bool
list
map
number
numberSet
string
stringSet
_null
}
input ModelIDInput {
ne: ID
eq: ID
le: ID
lt: ID
ge: ID
gt: ID
contains: ID
notContains: ID
between: [ID]
beginsWith: ID
attributeExists: Boolean
attributeType: ModelAttributeTypes
size: ModelSizeInput
}
input ModelStringInput {
ne: String
eq: String
le: String
lt: String
ge: String
gt: String
contains: String
notContains: String
between: [String]
beginsWith: String
attributeExists: Boolean
attributeType: ModelAttributeTypes
size: ModelSizeInput
}
input ModelSizeInput {
ne: Int
eq: Int
le: Int
lt: Int
ge: Int
gt: Int
between: [Int]
}
input ModelBooleanInput {
ne: Boolean
eq: Boolean
attributeExists: Boolean
attributeType: ModelAttributeTypes
}
input ModelFloatInput {
ne: Float
eq: Float
le: Float
lt: Float
ge: Float
gt: Float
between: [Float]
attributeExists: Boolean
attributeType: ModelAttributeTypes
}
type CompanyCurrency {
currency: String
rate: Float
status: String
}
type CompanyDetails {
companyName: String
companyRegistrationId: String
proofOfCompanyRegistration: String
proofOfCompanyRegistrationFileName: String
}
type CompanyAddress {
country: String
city: String
streetName: String
postCode: String
}
type KeyCompanyDirector {
firstName: String
lastName: String
emailAddress: String
}
type PersonalInfo {
firstName: String
lastName: String
emailAddress: String
}
type PersonalDetails {
dateOfBirth: String
position: String
phoneNumber: String
nationality: String
gender: String
bvn: String
}
type IdentificationDetails {
idType: String
idNumber: String
idUpload: String
idUploadFileName: String
hasHeldOffice: String
additionalDetails: String
}
type CompanyDocuments @model @auth(
rules: [
{ allow: groups, groups: ["Admin"] }
{ allow: owner }
{ allow: private }
{ allow: public }
]
){
id: ID!
key: String
bucketName: String
fileName: String
name: String
category: DocumentCategory
entityType: EntityTypes
entityId: ID!
@index(
name: "byCompanyDocuments"
queryField: "companyDocumentsByCompany"
sortKeyFields: ["id"]
)
company: Company @belongsTo(fields: ["entityId"])
ownershipDetail: OwnershipDetails @belongsTo(fields: ["entityId"])
loan: CompanyLoans @belongsTo(fields: ["entityId"])
}
enum DocumentCategory {
CompanyKyc
LoanOnLendingFacility
LoanOperationsFinancing
LoanPurchaseOrderFinancing
IdentificationDetails
CompanyDetails
}
enum EntityTypes {
Company
CompanyLoans
OwnershipDetails
}
type OwnershipDetails @model @auth(
rules: [
{ allow: groups, groups: ["Admin"] }
{ allow: owner }
{ allow: private }
{ allow: public }
]
) {
id: ID!
ownerType: OwnerType!
ownerPercentage: Int
fillOwnershipStatus: FillOwnershipStatus
companyDetails: CompanyDetails
companyAddress: CompanyAddress
keyCompanyDirector: KeyCompanyDirector
personalInfo: PersonalInfo
personalDetails: PersonalDetails
identificationDetails: IdentificationDetails
status: OwnershipDetailsStatus
companyID: ID! @index(name: "byOwnershipDetails", queryField: "getOwnershipDetailsByCompany", sortKeyFields: ["id"])
company: Company @belongsTo(fields: ["companyID"])
companyDocuments: [CompanyDocuments] @hasMany(indexName: "byCompanyDocuments", fields: ["id"])
}
enum TransferType {
Credit
Debit
}
type RulesInfo {
key: Int
index: Int
userID: ID!
name: String
priority: Int
accounts: String
category: String
description: String
subCategory: String
modifiedDate: String
transferType: TransferType
isFetchHistoricals: Boolean
}
type Category @model @auth(
rules: [
{ allow: groups, groups: ["Admin"] }
{ allow: owner }
{ allow: private }
{ allow: public, operations: [read, update] }
]
) {
id: ID!
name: String @index(name: "byCategoryName", queryField: "getByCategoryName", sortKeyFields: ["id"])
status: CategoryStatus
type: CategoryTypeTwo
companyID: ID! @index(name: "byCompanyCategoryId", queryField: "getCompanyCategoryId", sortKeyFields: ["id"])
company: Company @belongsTo(fields: ["companyID"])
subCategory: [SubCategory] @hasMany(indexName: "byCategory", fields: ["id"])
}
type SubCategory @model @auth(
rules: [
{ allow: groups, groups: ["Admin"] }
{ allow: owner }
{ allow: private }
{ allow: public, operations: [read, update] }
]
) {
id: ID!
name: String @index(name: "bySubCategoryName", queryField: "getBySubCategoryName", sortKeyFields: ["id"])
categoryID: ID! @index(name: "byCategory", sortKeyFields: ["name"])
category: Category @belongsTo(fields: ["categoryID"])
}
input CreateTransactionActivitiesInput {
isCash: Boolean
description: String
entity: String
categoryVendor: String
categoryStandardized: String
categoryUser: String
amount: Float
companyId: String
currency: String
channel: String
type: String
date: String
time: String
dateCreated: String
createdAt: AWSDateTime
updatedAt: AWSDateTime
}
input DeleteMultipleTransactionActivitiesInput {
transactionIds: [String]!
}
input DeleteTransactionActivitiesInput {
transactionId: String!
}
input UpdateTransactionActivitiesInput {
transactionId: String!
description: String
entity: String
categoryVendor: String
categoryStandardized: String
categoryUser: String
amount: Int
companyId: String
currency: String
channel: String
type: String
date: String
time: String
}
enum CompanyStage {
currentlyOnboarding
completedOnboarding
}
enum OwnerType {
entity
individual
}
enum FillOwnershipStatus {
manual
request
}
enum CompanyKYCStatus {
inprogress
pending
denied
approved
}
enum OwnershipDetailsStatus {
requested
submitted
}
enum TypeOfCustomer {
largeCompanies
smallBusinesses
publicSectorOrGovernment
consumersPrivateIndividuals
}
enum TreasuryNeeds {
workingCapitalLoans
invoiceFactoring
cashflowForecasting
fxRiskMitigation
paymentRiskAnalytics
}
type DailyBalances {
id: String
companyid: String
accountid: String
endofdaybalance: Float
currency: String
date: String
}
type CategoryType {
categorystandardized: String
type: String
}
input transactionFilterInput {
type: [String]
currency: [String]
categories: [String]
accountid: [String]
}
input dailyBalancesFilterInput {
accountid: [String]
currency: [String]
}
type Mutation {
createTransactionActivities(
input: CreateTransactionActivitiesInput!
): TransactionActivities
updateTransactionActivities(
input: UpdateTransactionActivitiesInput!
): TransactionActivities
deleteTransactionActivities(
input: DeleteTransactionActivitiesInput!
): TransactionActivities
deleteMultipleTransactionActivities(
input: DeleteMultipleTransactionActivitiesInput!
): TransactionActivities
}
input InputFilter {
type: [String]
currency: [String]
categories: [String]
accounts: [String]
}
type Query {
listTransactionActivities(
limit: Int
offset: Int
search: String
startDate: String
endDate: String
companyId: String
filter: InputFilter
): [TransactionActivities]
getTotal(
search: String
type: String
startDate: String
endDate: String
currency: String
companyId: String
filter: InputFilter
): String
TransactionActivitiesWithCount(
search: String
startDate: String
endDate: String
companyId: String
filter: InputFilter
): String
migrateUsersTransactions(
TransactionType: String
userId: String
companyId: String
): String
@function(name: "standardizedTransactionStateMachine-${env}")
checkUsersRules(companyID: String): String
@function(name: "checkUsersRules-${env}")
customGenericMailSender(recipientMails: [String], mailSubject: String, mailBody: String, ccMails: [String], bccMails: [String], replyAddresses: [String]): AWSJSON
@function(name: "customMailSender-${env}")
getCompanyCurrency(id: ID!): [CompanyCurrency]
@function(name: "GetCompanyCurrency-${env}")
getCompanyCategories(companyId: ID!): [Category]
@function(name: "getCompanyCategories-${env}")
sendKycInvite(email: String!, companyKYCID: String! inviterId: String!, ownerId: String!, requesterName: String!, recieverName: String!): AWSJSON
@function(name: "companyKycInvite-${env}")
fetchMonoTransactions(userID: String!, companyID: String!):AWSJSON @function(name: "monoTransactionMigration-${env}")
decodeToken(token: String!): AWSJSON @function(name: "decodeToken-${env}")
createDefaultUserCategories(id: ID!): String @function(name: "createDefaultUserCategories-${env}")
getRevenueAndSpendingActivities(
companyId: String
startDate: String
endDate: String
filter: transactionFilterInput
): [TransactionActivitiesRecord]
getSpendingBreakdownActivities(
companyId: String
startDate: String
endDate: String
filter: transactionFilterInput
): [TransactionActivitiesRecord]
getBalanceOverTime(
companyId: String
startDate: String
endDate: String
filter: dailyBalancesFilterInput
): [DailyBalances]
getTransactionActivities(
companyId: String
startDate: String
endDate: String
filter: transactionFilterInput
): [TransactionActivitiesRecord]
getLastestBalance(companyId: String): [DailyBalances]
getAccountEarningDetails(
companyId: String
limit: Int
filter: dailyBalancesFilterInput
): [DailyBalances]
getCategories(companyId: String): [CategoryType]
getUniqueCategories(companyId: String): [String]
}
enum LoanStatuses {
creditStructureCompleted
transactionDetailsCompleted
Review
Active
Completed
Rejected
}
enum LoanTypes {
purchaseOrderFinancing
operationsFinancing
onLendingFacility
}
enum CategoryStatus {
custom
default
}
enum CategoryTypeTwo {
debit
credit
}
enum loanPaymentStatus{
Unpaid
Paid
}
enum paymentType {
Interest
Principal
}
enum PaymentMode {
Full
Part
}
type CreditStructure {
loanName: String
currency: String
creditAmount: String
duration: String
targetDisbursementDate: String
desiredRampUp: String
}
type TransactionDetails {
relevantExperiences: String
macroEconomicImpact: String
unitEconomics: String
transactionShare: Int
confirmedBuyer: String
workedWithBuyer: String
priorTransactionBuyer: String
signedOffContractWithBuyer: String
attachSignedOffContractWithBuyer: String
expectToReceiveSignedOffContractBuyer: String
attachSignedOffContractWithLogisticProvider: String
logisticsShippingBuyer: String
signedOffProcessWithLogisticsProvider: String
expectToReceiveSignedOffContractLogistics: String
workedWithSupplier: String
priorTransactionsSupplier: String
relevantLicenses: String
keyRisks: String
qualityAssurances: String
cashFlowCycles: String
creditProgram: String
criteriaQualification: String
disbursementMechanism: String
logisticsShippingProcess: String
}
type LoanRecipientDetails {
bankName: String
accountName: String
accountNumber: String
}
type CompanyLoans
@model {
id: ID!
companyID: ID
applicationId: String
status: LoanStatuses
loanType: LoanTypes
creditStructure: CreditStructure
creditStructureApproved: CreditStructure
transactionDetails: TransactionDetails
recipient: LoanRecipientDetails
interest: Float
paymentMode: PaymentMode
rejectionReasons: String
companyDocuments: [CompanyDocuments]
@hasMany(indexName: "byCompanyDocuments", fields: ["id"])
loanPayments: [LoanPayments]
@hasMany(indexName: "byLoanPayments", fields: ["id"])
createdAt: AWSDateTime
updatedAt: AWSDateTime
}
type LoanPayments @model{
id: ID!
loanId: ID!
@index(
name: "byLoanPayments"
queryField: "loanByLoanPayments"
sortKeyFields: ["id"]
)
companyLoans: CompanyLoans @belongsTo(fields: ["loanId"])
companyId: ID
@index(
name: "byCompanyId"
queryField: "loanPaymentsByCompanyId"
sortKeyFields: ["id"]
)
paymentReference: String
dueDate: String
amount: Float
currency: String
paymentType: paymentType
status: loanPaymentStatus
notes: String
channel: String
repaymentStatus: String
amountRecieved: Float
paymentDate: String
payerName: String
payerAccountNumber: String
createdAt: AWSDateTime
updatedAt: AWSDateTime
}
type CompanyLoansDocuments @model {
id: ID!
loanID: ID!
name: String
companyID: ID
fileName: String
fileUrl: String
documentType: String
}
type Recipients @model{
id: ID!
name: String
email: String
accountName: String
accounts: [Account] @hasMany
owner: String
@index(name: "byOwner", queryField: "recipientsByOwner", sortKeyFields: ["updatedAt"])
lastUpdatedDate: String
createdAt: AWSDateTime!
autoCreated: Boolean
updatedAt: AWSDateTime!
payments: [Payments] @hasMany
}
type Payments @model @auth(
rules: [
{ allow: groups, groups: ["Admin"] }
{ allow: owner }
{ allow: private }
]
) {
id: ID!
transactionType: String
transactionAmount: Float
settledAmount: Float
currency: String
ownerId: ID
@index(
name: "byOwner"
queryField: "PaymentsByOwner"
sortKeyFields: ["updatedAt"]
)
owner: User @belongsTo(fields: ["ownerId"])
narration: String
category: String
company: Company @belongsTo
wallet: Wallet @belongsTo
recipientBankCode: String
recipientAccountNumber: String
recipientAccountName: String
transactionReference: String
responseMessage: String
responseCode: String
responseStatus: String
requeryStatus: Boolean
settlementDateTime: AWSDateTime
sessionId: String
settlementId: String
latestBalance: Float
provider: String
recipient: Recipients @belongsTo
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
}
type Wallet @model
@searchable
@auth(
rules: [
{ allow: groups, groups: ["Admin"] }
{ allow: owner }
{ allow: private, operations: [create, read, update] }
{ allow: public, operations: [read] }
]
) {
id: ID!
accountNumber: String
balance: Float!
accountName: String
owner: String
@index(name: "byOwner", queryField: "walletByOwner", sortKeyFields: ["id"])
currency: String
company: Company @belongsTo
bank: Bank @belongsTo
lastUpdatedDate: String
createdAt: AWSDateTime!
updatedAt: AWSDateTime!
provider: String
accountId: ID
account: Account @hasOne(fields: ["accountId"])
payments: [Payments] @hasMany
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment