Dbupgrade 0048 - procedure fix

This commit is contained in:
Rick Falkvinge
2017-10-09 09:04:19 +02:00
parent 24419c18a7
commit 35cf1438cd
3 changed files with 38 additions and 1 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Swarmops.Database
/// </summary>
public static int DbVersionExpected
{
get { return 47; }
get { return 48; }
}
+1
View File
@@ -45,3 +45,4 @@
0045 - VAT Report work [RF]
0046 - VatReports.Turnover=>TurnoverCents [RF]
0047 - Fix for null case in SetVatReportReleased [RF]
0048 - Fix for CreateVatReportItem, ForeignObjectId=>ForeignId [RF]
+36
View File
@@ -0,0 +1,36 @@
DROP PROCEDURE IF EXISTS `CreateVatReportItem`
#
CREATE PROCEDURE `CreateVatReportItem`(
vatReportId INT,
financialTransactionId INT,
foreignId INT,
financialDependencyType VARCHAR(64),
turnoverCents BIGINT,
vatInboundCents BIGINT,
vatOutboundCents BIGINT
)
BEGIN
DECLARE financialDependencyTypeId INTEGER;
SELECT 0 INTO financialDependencyTypeId;
IF ((SELECT COUNT(*) FROM FinancialDependencyTypes WHERE FinancialDependencyTypes.Name=financialDependencyType) = 0)
THEN
INSERT INTO FinancialDependencyTypes (Name)
VALUES (financialDependencyType);
SELECT LAST_INSERT_ID() INTO financialDependencyTypeId;
ELSE
SELECT FinancialDependencyTypes.FinancialDependencyTypeId INTO FinancialDependencyTypeId FROM FinancialDependencyTypes
WHERE FinancialDependencyTypes.Name=financialDependencyType;
END IF;
INSERT INTO VatReportItems (VatReportId, FinancialTransactionId, ForeignId, FinancialDependencyTypeId, TurnoverCents, VatInboundCents, VatOutboundCents)
VALUES (vatReportId, financialTransactionId, foreignId, financialDependencyTypeId, turnoverCents, vatInboundCents, vatOutboundCents);
END