# Synthetic finance schema (generated by scripts/gen_schema.py)

# Ledger documentation
Ledger as led0
---
LedgerId PK int IDENTITY
RenewalRef0 int FK 0-0 Renewal.RenewalId
PromotionRef1 int FK -0< pro28.PromotionId
Field0Ledger datetime INDEX
Field1Ledger datetime default=9
Field2Ledger int
Field3Ledger string
Field4Ledger decimal(10,2)
Field5Ledger string NULL
Field6Ledger varchar(200)
Field7Ledger varchar(200) INDEX

LedgerEntry
----------
LedgerEntryId PK int IDENTITY
CampaignRef0 int FK >0- Campaign.CampaignId
QuotaRef1 int FK - Quota.QuotaId
Field0LedgerEntry int UNIQUE
Field1LedgerEntry datetime
Field2LedgerEntry decimal(10,2)
Field3LedgerEntry date INDEX
Field4LedgerEntry string NULL

Journal
---
JournalId PK int IDENTITY
ContractRef0 int FK -< Contract.ContractId
Field0Journal int UNIQUE
Field1Journal date UNIQUE
"Display Name" string="Unnamed Journal"

JournalLine
rel >- Quota
-
JournalLineId PK int IDENTITY
PriceListRef0 int FK >- PriceList.PriceListId
Field0JournalLine datetime default=8
Field1JournalLine uuid
Field2JournalLine date INDEX
Field3JournalLine bool UNIQUE
Field4JournalLine int NULL
Field5JournalLine date
Field6JournalLine datetime

Currency
---
CurrencyId PK int IDENTITY
DealStageRef0 int FK >-< DealStage.DealStageId
Field0Currency datetime default=2
Field1Currency money
Field2Currency uuid INDEX
Field3Currency bool
Field4Currency string UNIQUE
Field5Currency money UNIQUE
Field6Currency money
Field7Currency uuid UNIQUE

# ExchangeRate documentation
"finance.ExchangeRate"
----
ExchangeRateId PK int IDENTITY
TerritoryRef0 int FK -0 ter7.TerritoryId
Field0ExchangeRate text
Field1ExchangeRate text INDEX
Field2ExchangeRate int default=3
Field3ExchangeRate bool INDEX
Field4ExchangeRate uuid NULL
Field5ExchangeRate datetime NULL
Field6ExchangeRate datetime

TaxRate
----------
TaxRateId PK int IDENTITY
Field0TaxRate date

TaxCode as tax7
---
TaxCodeId PK int IDENTITY
ResellerRef0 int FK 0- res35.ResellerId
Field0TaxCode text

CostCenter
---
CostCenterId PK int IDENTITY
Field0CostCenter string INDEX
Field1CostCenter datetime
Field2CostCenter datetime INDEX
Field3CostCenter uuid INDEX
Field4CostCenter text INDEX
Field5CostCenter decimal(10,2) default=9
Field6CostCenter varchar(200) UNIQUE
Field7CostCenter money default=5

Budget
----
BudgetId PK int IDENTITY
Field0Budget datetime default=9
Field1Budget uuid INDEX
Field2Budget text UNIQUE
Field3Budget bool default=8
Field4Budget money UNIQUE

# BudgetLine documentation
BudgetLine
---
BudgetLineId PK int IDENTITY
LeadRef0 int FK 0-0 Lead.LeadId
SalesNoteRef1 int FK -0< SalesNote.SalesNoteId
Field0BudgetLine decimal(10,2)
Field1BudgetLine bool
Field2BudgetLine money
Field3BudgetLine varchar(200)
Field4BudgetLine varchar(200) default=8
Field5BudgetLine bool INDEX
Field6BudgetLine string INDEX

FiscalYear
-
FiscalYearId PK int IDENTITY
ContractRef0 int FK >0- Contract.ContractId
PaymentRef1 int FK - Payment.PaymentId
Field0FiscalYear string UNIQUE
Field1FiscalYear bool
Field2FiscalYear money UNIQUE

FiscalPeriod
----------
FiscalPeriodId PK int IDENTITY
LedgerRef0 int FK -< led0.LedgerId
Field0FiscalPeriod text default=0
Field1FiscalPeriod string
Field2FiscalPeriod datetime
Field3FiscalPeriod string
Field4FiscalPeriod string NULL
Field5FiscalPeriod datetime
Field6FiscalPeriod bool UNIQUE
Field7FiscalPeriod bool INDEX

Vendor
---
VendorId PK int IDENTITY
Field0Vendor money
Field1Vendor varchar(200) NULL
Field2Vendor string INDEX
Field3Vendor date INDEX
Field4Vendor date NULL
Field5Vendor uuid INDEX
Field6Vendor datetime INDEX
Field7Vendor datetime NULL
Field8Vendor string UNIQUE

Bill as bil14
rel >- led0
----
BillId PK int IDENTITY
PaymentMethodRef0 int FK >- PaymentMethod.PaymentMethodId
CurrencyRef1 int FK >-< Currency.CurrencyId
Field0Bill uuid NULL
Field1Bill money
Field2Bill decimal(10,2) default=6
Field3Bill bool UNIQUE
Field4Bill datetime

# BillLine documentation
BillLine
----------
BillLineId PK int IDENTITY
CustomerRef0 int FK -0 cus0.CustomerId
Field0BillLine date UNIQUE

BankAccount
---
BankAccountId PK int IDENTITY
FiscalYearRef0 int FK 0- FiscalYear.FiscalYearId
PlanRef1 int FK 0-0 Plan.PlanId
Field0BankAccount decimal(10,2) UNIQUE
Field1BankAccount varchar(200)
Field2BankAccount int INDEX
Field3BankAccount int UNIQUE

BankTransaction
---
BankTransactionId PK int IDENTITY
Field0BankTransaction bool NULL
Field1BankTransaction decimal(10,2) default=2
Field2BankTransaction bool default=8
Field3BankTransaction datetime UNIQUE
Field4BankTransaction uuid

"finance.Reconciliation"
----
ReconciliationId PK int IDENTITY
Field0Reconciliation string NULL
Field1Reconciliation money UNIQUE
Field2Reconciliation string
Field3Reconciliation datetime
Field4Reconciliation uuid
Field5Reconciliation datetime INDEX
Field6Reconciliation bool
Field7Reconciliation decimal(10,2)

Asset
----
AssetId PK int IDENTITY
CouponRef0 int FK -0< cou14.CouponId
LedgerEntryRef1 int FK >0- LedgerEntry.LedgerEntryId
Field0Asset uuid
Field1Asset money NULL
"Display Name" string="Unnamed Asset"

# Depreciation documentation
Depreciation
-
DepreciationId PK int IDENTITY
Field0Depreciation uuid
Field1Depreciation decimal(10,2) NULL
Field2Depreciation money UNIQUE
Field3Depreciation text default=6
Field4Depreciation varchar(200)

Expense as exp21
-
ExpenseId PK int IDENTITY
SegmentRef0 int FK - Segment.SegmentId
Field0Expense datetime
Field1Expense bool INDEX
Field2Expense uuid UNIQUE
Field3Expense string default=5
Field4Expense bool INDEX
Field5Expense datetime
Field6Expense uuid

ExpenseClaim
---
ExpenseClaimId PK int IDENTITY
LedgerRef0 int FK -< led0.LedgerId
CampaignRef1 int FK >- Campaign.CampaignId
Field0ExpenseClaim int NULL

Approval
---
ApprovalId PK int IDENTITY
BasketRef0 int FK >-< Basket.BasketId
QuoteRef1 int FK -0 Quote.QuoteId
Field0Approval decimal(10,2) NULL
Field1Approval decimal(10,2) NULL
Field2Approval date UNIQUE
Field3Approval varchar(200) default=2
Field4Approval datetime
Field5Approval int
Field6Approval bool default=3
Field7Approval bool NULL
Field8Approval datetime NULL

AuditLog
----------
AuditLogId PK int IDENTITY
CouponRef0 int FK 0- cou14.CouponId
ChannelRef1 int FK 0-0 Channel.ChannelId
Field0AuditLog uuid default=5
Field1AuditLog date INDEX
Field2AuditLog text default=3
Field3AuditLog int UNIQUE
Field4AuditLog uuid
Field5AuditLog uuid INDEX
Field6AuditLog string
Field7AuditLog uuid

# Allocation documentation
Allocation
rel >- Plan
---
AllocationId PK int IDENTITY
Field0Allocation datetime
Field1Allocation date
Field2Allocation bool default=6

Accrual
----
AccrualId PK int IDENTITY
AuditLogRef0 int FK -0< AuditLog.AuditLogId
Field0Accrual string
Field1Accrual text INDEX
Field2Accrual uuid INDEX
Field3Accrual bool INDEX
Field4Accrual money UNIQUE
Field5Accrual money
Field6Accrual datetime NULL

Provision
----------
ProvisionId PK int IDENTITY
Field0Provision string INDEX
Field1Provision string NULL

Loan as loa28
-
LoanId PK int IDENTITY
JournalRef0 int FK >0- Journal.JournalId
LeadRef1 int FK - Lead.LeadId
Field0Loan bool
Field1Loan int default=4
Field2Loan datetime
Field3Loan date NULL
Field4Loan varchar(200) NULL
Field5Loan string default=5
Field6Loan bool UNIQUE

Repayment
---
RepaymentId PK int IDENTITY
InvoiceRef0 int FK -< Invoice.InvoiceId
Field0Repayment int UNIQUE
Field1Repayment datetime UNIQUE
Field2Repayment int NULL
Field3Repayment date
Field4Repayment varchar(200)

# CreditNote documentation
CreditNote
---
CreditNoteId PK int IDENTITY
VendorRef0 int FK >- Vendor.VendorId
Field0CreditNote bool UNIQUE
Field1CreditNote datetime default=5
Field2CreditNote date
Field3CreditNote varchar(200) default=2
Field4CreditNote int UNIQUE
Field5CreditNote uuid INDEX
Field6CreditNote date INDEX
Field7CreditNote datetime default=3

"finance.DebitNote"
-
DebitNoteId PK int IDENTITY
BillLineRef0 int FK >-< BillLine.BillLineId
Field0DebitNote datetime INDEX
Field1DebitNote text

Settlement
---
SettlementId PK int IDENTITY
TerritoryRef0 int FK -0 ter7.TerritoryId
Field0Settlement decimal(10,2) NULL

Chargeback
---
ChargebackId PK int IDENTITY
ActivityRef0 int FK 0- Activity.ActivityId
Field0Chargeback string INDEX
Field1Chargeback money NULL
Field2Chargeback money
Field3Chargeback decimal(10,2) default=8
Field4Chargeback bool INDEX
Field5Chargeback int

Fee
----------
FeeId PK int IDENTITY
Field0Fee date default=6
Field1Fee money UNIQUE
Field2Fee string
Field3Fee bool default=2
Field4Fee uuid
Field5Fee money NULL

# GLAccount documentation
GLAccount as gla35
----------
GLAccountId PK int IDENTITY
FiscalYearRef0 int FK 0-0 FiscalYear.FiscalYearId
ProvisionRef1 int FK -0< Provision.ProvisionId
Field0GLAccount money
Field1GLAccount bool UNIQUE

GLGroup
rel >- PlanFeature
-
GLGroupId PK int IDENTITY
CouponRef0 int FK >0- cou14.CouponId
ProvisionRef1 int FK - Provision.ProvisionId
Field0GLGroup decimal(10,2) UNIQUE
Field1GLGroup varchar(200)
Field2GLGroup varchar(200) NULL
Field3GLGroup varchar(200) NULL
Field4GLGroup string
Field5GLGroup uuid default=7
Field6GLGroup date
Field7GLGroup date UNIQUE
Field8GLGroup bool INDEX
"Display Name" string="Unnamed GLGroup"

Entity
-
EntityId PK int IDENTITY
BankAccountRef0 int FK -< BankAccount.BankAccountId
Field0Entity datetime
Field1Entity bool
Field2Entity datetime INDEX
Field3Entity int UNIQUE
Field4Entity datetime

Intercompany
-
IntercompanyId PK int IDENTITY
GLGroupRef0 int FK >- GLGroup.GLGroupId
AuditLogRef1 int FK >-< AuditLog.AuditLogId
Field0Intercompany uuid default=9
Field1Intercompany int default=7
Field2Intercompany decimal(10,2) default=5
Field3Intercompany uuid NULL
Field4Intercompany int
Field5Intercompany bool default=1
Field6Intercompany varchar(200) NULL

Consolidation
----------
ConsolidationId PK int IDENTITY
ProvisionRef0 int FK -0 Provision.ProvisionId
Field0Consolidation date UNIQUE
Field1Consolidation bool INDEX
Field2Consolidation money
Field3Consolidation date
Field4Consolidation bool UNIQUE
Field5Consolidation string
Field6Consolidation money UNIQUE
Field7Consolidation date UNIQUE
Field8Consolidation string
