Added exchange rate tracking to db

This commit is contained in:
Rick Falkvinge
2014-12-05 21:44:00 +01:00
parent f14c7b3092
commit 53b730ad05
2 changed files with 74 additions and 5 deletions
+7 -5
View File
@@ -1,5 +1,7 @@
0001 - Initial baseline, Rick Falkvinge
0002 - Added functions for account plan maintenance and back/forward links to FinancialAccounts, Rick Falkvinge
0003 - Added 'Year' field for salary tax data, Rick Falkvinge
0004 - Added BankProfile tables and stored procs to insert/update, Rick Falkvinge
0005 - Changed PostalCodeLength for NO DK to 4; for GH to zero; added Country.Currency
0001 - Initial baseline. [Rick Falkvinge]
0002 - Added functions for account plan maintenance and back/forward links to FinancialAccounts. [Rick Falkvinge]
0003 - Added 'Year' field for salary tax data. [Rick Falkvinge]
0004 - Added BankProfile tables and stored procs to insert/update. [Rick Falkvinge]
0005 - Changed PostalCodeLength for NO DK to 4; for GH to zero; added Country.Currency. [Rick Falkvinge]
0006 - Added Memberships.LocalNumber and .FamilyNumber; added CurrencyExchangeRate tables/procs. [Rick Falkvinge]
+67
View File
@@ -0,0 +1,67 @@
ALTER TABLE `Memberships`
ADD COLUMN `MembershipNumberLocal` INT(11) NOT NULL DEFAULT 0 AFTER `MemberSince`,
ADD COLUMN `MembershipNumberFamily` INT(11) NOT NULL DEFAULT 0 AFTER `MembershipNumberLocal`,
ADD INDEX `Index_NumLocal` (`MembershipNumberLocal` ASC),
ADD INDEX `Index_NumFamily` (`MembershipNumberFamily` ASC)
#
ALTER TABLE `Organizations`
ADD COLUMN `GrandestparentOrganizationId` INT(11) NOT NULL DEFAULT 0 AFTER `ParentOrganizationId`,
ADD INDEX `Index_Parent` (`ParentOrganizationId` ASC),
ADD INDEX `Index_Family` (`GrandestparentOrganizationId` ASC)
#
CREATE TABLE `CurrencyExchangeRateSnapshots` (
`CurrencyExchangeRateSnapshotId` INT NOT NULL AUTO_INCREMENT,
`DateTime` DATETIME NOT NULL,
PRIMARY KEY (`CurrencyExchangeRateSnapshotId`),
INDEX `Ix_Date` (`DateTime` ASC))
#
CREATE TABLE `CurrencyExchangeRateSnapshotData` (
`CurrencyExchangeRateSnapshotId` INT NOT NULL AUTO_INCREMENT,
`CurrencyAId` INT(11) NOT NULL,
`CurrencyBId` INT(11) NOT NULL,
`APerB` DOUBLE NOT NULL,
PRIMARY KEY (`CurrencyExchangeRateSnapshotId`));
#
CREATE PROCEDURE `CreateExchangeRateSnapshot` (
IN dateTimeUtc DATETIME
)
BEGIN
INSERT INTO CurrencyExchangeRateSnapshots (DateTime)
VALUES (dateTimeUtc);
SELECT LAST_INSERT_ID() AS Identity;
END
#
CREATE PROCEDURE `InsertExchangeRateSnapshotData` (
IN currencyExchangeRateSnapshotId INTEGER,
IN currencyAId INTEGER,
IN currencyBId INTEGER,
IN aPerB DOUBLE
)
BEGIN
INSERT INTO CurrencyExchangeRateSnapshotData (CurrencyExchangeRateSnapshotId,CurrencyAId,CurrencyBId,APerB)
VALUES (currencyExchangeRateSnapshotId,currencyAId,currencyBId,aPerB);
END