Merge branch 'rav001' into rvv001
This commit is contained in:
commit
b9cf0bcb9f
2 changed files with 127 additions and 137 deletions
256
src/DB.hs
256
src/DB.hs
|
@ -22,178 +22,162 @@ import Control.Exception (throwIO)
|
|||
import Control.Monad (forM_, when)
|
||||
import Control.Monad.IO.Class (MonadIO, liftIO)
|
||||
import Control.Monad.Logger (NoLoggingT, runNoLoggingT)
|
||||
import Data.Aeson
|
||||
import Data.Bifunctor (bimap)
|
||||
import qualified Data.ByteString as BS
|
||||
import Data.HexString
|
||||
import Data.List (group, sort)
|
||||
import Data.Maybe (catMaybes, fromJust, isJust)
|
||||
import Data.Pool (Pool)
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as TE
|
||||
import Data.Time (UTCTime(..))
|
||||
import Data.UUID (UUID)
|
||||
import Data.Word
|
||||
import Database.Esqueleto.Experimental
|
||||
import qualified Database.Persist.Sqlite as PS
|
||||
import qualified Database.Persist.MySQL as PM
|
||||
import Database.Persist.TH
|
||||
|
||||
newtype UuidDB = UuidDB
|
||||
{ getUUID :: UUID
|
||||
} deriving newtype (Eq, Show, Read, ToJSON, FromJSON)
|
||||
|
||||
derivePersistFieldJSON "UuidDB"
|
||||
|
||||
newtype HexStringDB = HexStringDB
|
||||
{ getHex :: HexString
|
||||
} deriving newtype (Eq, Show, Read)
|
||||
|
||||
derivePersistField "HexStringDB"
|
||||
|
||||
share
|
||||
[mkPersist sqlSettings, mkMigrate "migrateAll"]
|
||||
[persistLowerCase|
|
||||
ZgoBlock
|
||||
block_id Int --Block Id number
|
||||
block_confs Int default=0 -- Block confirnations
|
||||
block_network String default="" -- Block Network
|
||||
block_height Int default=0 -- Block Height
|
||||
block_time Int default=0 -- Block time
|
||||
UniqueBlock block_id
|
||||
ZgoBlock json
|
||||
confs Int default=0
|
||||
network String default=""
|
||||
height Int default=0
|
||||
time Int default=0
|
||||
deriving Show Eq
|
||||
ZgoBlockTx
|
||||
blocktx_block_id Int --'Block Tx parent
|
||||
blocktx_id Int -- Block Tx record Id
|
||||
blocktx_txid String -- Block Tx Id
|
||||
UniqueBlockTx blocktx_block_id blocktx_id
|
||||
blocktx_block_id Int
|
||||
blocktx_id Int
|
||||
blocktx_txid String
|
||||
deriving Show Eq
|
||||
ZgoCountry
|
||||
country_code String -- Two Character Country Code
|
||||
country_name String -- Country unique name
|
||||
UniqueCountryCode country_code
|
||||
ZgoCountry json
|
||||
code T.Text
|
||||
name T.Text
|
||||
UniqueCountryCode code
|
||||
deriving Show Eq
|
||||
ZgoItem
|
||||
item_owner_id Int -- Owner Id
|
||||
item_id String -- Item Id
|
||||
item_name String -- Item name',
|
||||
item_description T.Text default="" -- Item description
|
||||
item_cost Float default=0.0 -- Item Unit price
|
||||
UniqueItemId item_owner item_id
|
||||
ZgoItem json
|
||||
owner_id Int
|
||||
name T.Text
|
||||
description T.Text default=""
|
||||
cost Double default=0.0
|
||||
deriving Show Eq
|
||||
ZgoLanguages
|
||||
encode_id String -- Language encoding id
|
||||
view_name String default-"" -- View name that use this language'
|
||||
view_element String default="" -- 'Element name
|
||||
view_element_text T.Text default="" -- Text to be displayed'
|
||||
UniqueLanguage encode_id view_name view_element
|
||||
encode_id T.Text
|
||||
name T.Text default-""
|
||||
element T.Text default=""
|
||||
element_text T.Text default=""
|
||||
deriving Show Eq
|
||||
ZgoOrders
|
||||
order_id Int -- Order Id
|
||||
order_zaddress T.Text -- Order zcash address
|
||||
order_session T.Text -- Order session id
|
||||
order_timestamp Int -- Order timestamp
|
||||
order_closed Word8 -- Order closed flag
|
||||
order_currency String -- Order currency
|
||||
order_price Float default=0.0 -- Order ZEC price
|
||||
order_total Float default=0.0 -- Order total amount
|
||||
order_totalzec Float default=0.0 -- Order total in ZEC
|
||||
order_paid Word8 default=0 -- Order paid status
|
||||
order_token String default="" -- Order token
|
||||
order_extinv String default="" -- Order External Invoice
|
||||
order_shortcode String default='' -- Order invoice shortcode
|
||||
order_taxamount Float default=0.0 -- Order tax amount
|
||||
order_tipamount Float default=0.0 -- Order tip amount
|
||||
order_vatamount Float default=0.0 -- Orcer VAT amount'
|
||||
UniqueOrderId order_id
|
||||
ZgoOrder json
|
||||
owner ZgoOwnerId
|
||||
session ZgoUserId
|
||||
timestamp Int
|
||||
closed Word8
|
||||
currency T.Text
|
||||
price Double
|
||||
total Double
|
||||
totalzec Double
|
||||
paid Bool
|
||||
token T.Text default=""
|
||||
externalInvoice T.Text default=""
|
||||
shortcode T.Text
|
||||
taxamount Double
|
||||
tipamount Double
|
||||
vatamount Double
|
||||
deriving Show Eq
|
||||
ZgoOrderLines
|
||||
orderline_orderid Int default=0 -- Orderlines Order Id
|
||||
orderline_line Int default=0 -- Orderlines Line number
|
||||
orderline_qty Int default=0 -- Orderline item qty
|
||||
orderline_name T.Text default="" -- Orderline item description
|
||||
orderline_cost Float default=0.0 -- Orderline item cost
|
||||
UniqueOrderLine orderline_orderid orderline_line
|
||||
orderId ZgoOrderId
|
||||
qty Int default=0
|
||||
name T.Text default=""
|
||||
cost Double default=0.0
|
||||
deriving Show Eq
|
||||
ZgoOwner
|
||||
owner_id Int --'Owner ID number
|
||||
owner_co_name String default="" -- Company''s name
|
||||
owner_firstname String -- Owner's first name
|
||||
owner_lastname String -- Owner's last name
|
||||
owner_email String -- Owner's email address
|
||||
owner_street String -- Owner's street
|
||||
owner_city String -- Owner's city
|
||||
owner_state String -- Owner's state
|
||||
owner_zipcode String -- Owner's zip code
|
||||
owner_phone String -- Owner's phone number
|
||||
owner_country String -- Owner's country
|
||||
owner_website String -- Owner's website URL
|
||||
owner_currency String -- Owner's currency',
|
||||
owner_zcaddress String -- Owner's zcash address
|
||||
owner_usezats Word8 -- Use zats for display
|
||||
owner_crmtoken T.Text -- Owner's crm token
|
||||
owner_usetax Word8 -- Use tax flag
|
||||
owner_taxvalue Float -- Tax rate to use
|
||||
owner_usevat Word8 -- Use vat flag
|
||||
owner_vat Float -- Vat rate to use
|
||||
owner_payconf Word8 -- Confirm payment flag
|
||||
owner_viewkey T.Text -- Viewing Key for payment confirmation
|
||||
owner_invoices Word8 -- Use zgo invoices
|
||||
owner_tips Word8 -- Activate tips
|
||||
owner_paid Word8 -- True if account is paid
|
||||
owner_expiration Int -- Expiration date-time
|
||||
UniqueOwnerId owner_id
|
||||
UniqueOwnerZcashAddr owner_zcaddress
|
||||
co_name T.Text
|
||||
firstname T.Text
|
||||
lastname T.Text
|
||||
email T.Text
|
||||
street T.Text
|
||||
city T.Text
|
||||
state T.Text
|
||||
zipcode T.Text
|
||||
phone T.Text
|
||||
country T.Text
|
||||
website T.Text
|
||||
currency T.Text
|
||||
zcaddress T.Text
|
||||
usezats Bool
|
||||
crmtoken T.Text
|
||||
usetax Bool
|
||||
taxvalue Double
|
||||
usevat Bool
|
||||
vat Double
|
||||
payconf Bool
|
||||
viewkey T.Text
|
||||
invoices Bool
|
||||
tips Bool
|
||||
paid Bool
|
||||
expiration UTCTime
|
||||
deriving Show Eq
|
||||
ZgoPayment
|
||||
payment_id Int -- Payment Id
|
||||
payment_delta Int -- Payment delta
|
||||
payment_done Word8 -- Payment done flag
|
||||
payment_zaddress T.Text -- Payment zcash address
|
||||
payment_session String default="" -- Payment session
|
||||
payment_blocktime Int default=0 -- Payment blocktime
|
||||
payment_amount Float default=0.0 -- Payment amount
|
||||
payment_txid String default ="" -- Payment transaction id
|
||||
payment_memo T.Text default="" -- Payment Memo
|
||||
UniquePaymentId payment_id
|
||||
delta Int
|
||||
done Bool
|
||||
zaddress T.Text
|
||||
session UuidDB
|
||||
blocktime Int default=0
|
||||
amount Double default=0.0
|
||||
txid HexStringDB
|
||||
memo T.Text
|
||||
deriving Show Eq
|
||||
ZgoPrice
|
||||
price_id Int -- Price Id
|
||||
price_delta Int default=0 -- Price delta
|
||||
price_done Word8 default=0 -- Price done flag
|
||||
price_zaddress T.Text default="" -- Price zcash address
|
||||
price_session String default="" -- Price session
|
||||
price_blocktime Int default=0 -- Price blocktime
|
||||
price_amount Float default=0.0 -- Price amount
|
||||
price_txid String default="" -- Price transaction id
|
||||
price_memo T.Text default="" -- Price Memo
|
||||
UniquePriceId price_id
|
||||
price_delta Int default=0
|
||||
price_done Bool default=0
|
||||
price_zaddress T.Text default=""
|
||||
price_session String default=""
|
||||
price_blocktime Int default=0
|
||||
price_amount Double default=0.0
|
||||
price_txid String default=""
|
||||
price_memo T.Text default=""
|
||||
deriving Show Eq
|
||||
ZgoProsession
|
||||
pro_id Int -- Prosession record id
|
||||
pro_zaddress T.Text default="" -- Prosession zcash address
|
||||
pro_expiration Int default=0 -- Prosession expiration date/time
|
||||
pro_closed Word8 default=0 -- Prosession closed flag
|
||||
UniqueProSesId pro_id
|
||||
UniqueProSesZad pro_zaddress
|
||||
zaddress T.Text default=""
|
||||
expiration UTCTime
|
||||
closed Bool
|
||||
deriving Show Eq
|
||||
ZgoTransaction
|
||||
tx_id Int -- Transaction ID
|
||||
tx_zaddress T.Text default="" -- Transaction Zcash Address
|
||||
tx_expiration Int default=0 -- Transaction Expiration Date/Time
|
||||
tx_closed Word8 default=0 -- Transaction Closed flag
|
||||
UniqueTxId tx_id
|
||||
zaddress T.Text default=""
|
||||
expiration Int default=0
|
||||
closed Word8 default=0
|
||||
deriving Show Eq
|
||||
ZgoUser
|
||||
user_id Int -- User Id
|
||||
user_zaddress T.Text -- User zcash address,
|
||||
user_session String -- User session id
|
||||
user_blocktime Int -- User block time
|
||||
user_pin String -- User pin
|
||||
user_validated Word8 default=0 -- User validated flag
|
||||
UniqueUserId user_id
|
||||
UniqueUserZad user_zaddress
|
||||
ZgoUser json
|
||||
owner ZgoOwnerId
|
||||
session UuidDB
|
||||
blocktime Int
|
||||
pin T.Text
|
||||
validated Bool
|
||||
deriving Show Eq
|
||||
ZgoXero
|
||||
xero_id Int -- Xero Id
|
||||
xero_client_id String default="" -- Xero client id
|
||||
xero_client_secret String default="" -- Xero client secret word
|
||||
UniqueXeroId xero_id
|
||||
UniqueXeroClientId xero_client_id
|
||||
client_id T.Text default=""
|
||||
client_secret T.Text default=""
|
||||
deriving Show Eq
|
||||
ZgoXeroToken
|
||||
xerotoken_id Int -- Xero account id
|
||||
xerotoken_zaddress T.Text -- Xero zcash address
|
||||
xerotoken_access_token T.Text -- Xero account access token
|
||||
xerotoken_expires Int -- Xero token expiration date/time
|
||||
xerotoken_refreshtoken String -- Xero refresh token
|
||||
xerotoken_accexpires Int -- Xero account expire date/time
|
||||
xerotoken_accCode String -- Xero account code
|
||||
xerotoken_refexpires Int -- Xero reference expire date/time
|
||||
UniqueXeroTokenId xerotoken_id
|
||||
zaddress T.Text
|
||||
access_token T.Text
|
||||
expires Int
|
||||
refreshtoken T.Text
|
||||
accexpires Int
|
||||
accCode T.Text
|
||||
refexpires Int
|
||||
deriving Show Eq
|
||||
|
||||
|]
|
||||
|
|
|
@ -33,6 +33,7 @@ library
|
|||
Xero
|
||||
ZGoBackend
|
||||
ZGoTx
|
||||
DB
|
||||
hs-source-dirs:
|
||||
src
|
||||
build-depends:
|
||||
|
@ -47,6 +48,10 @@ library
|
|||
, configurator
|
||||
, containers
|
||||
, crypto-rng
|
||||
, esqueleto
|
||||
, persistent
|
||||
, persistent-mysql
|
||||
, persistent-template
|
||||
, ghc-prim
|
||||
, hexstring
|
||||
, http-conduit
|
||||
|
@ -54,6 +59,7 @@ library
|
|||
, jwt
|
||||
, megaparsec
|
||||
, memory
|
||||
, monad-logger
|
||||
, mongoDB
|
||||
, network
|
||||
, quickcheck-instances
|
||||
|
|
Loading…
Reference in a new issue