Another fix for VAT reports

This commit is contained in:
Rick Falkvinge
2017-10-09 09:25:01 +02:00
parent 35cf1438cd
commit 37606a0f9f
5 changed files with 47 additions and 2 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Swarmops.Database
/// </summary>
public static int DbVersionExpected
{
get { return 48; }
get { return 49; }
}
+1 -1
View File
@@ -239,7 +239,7 @@ namespace Swarmops.Database
AddParameterWithName(command, "vatReportId", vatReportId);
AddParameterWithName(command, "financialTransactionId", financialTransactionId);
AddParameterWithName(command, "foreignObjectId", foreignObjectId);
AddParameterWithName(command, "foreignId", foreignObjectId);
AddParameterWithName(command, "financialDependencyType", financialDependencyType.ToString());
AddParameterWithName(command, "turnoverCents", turnoverCents);
AddParameterWithName(command, "vatInboundCents", vatInboundCents);
+1
View File
@@ -46,3 +46,4 @@
0046 - VatReports.Turnover=>TurnoverCents [RF]
0047 - Fix for null case in SetVatReportReleased [RF]
0048 - Fix for CreateVatReportItem, ForeignObjectId=>ForeignId [RF]
0049 - Another fix for CreateVatReportItem
+4
View File
@@ -33,4 +33,8 @@ BEGIN
INSERT INTO VatReportItems (VatReportId, FinancialTransactionId, ForeignId, FinancialDependencyTypeId, TurnoverCents, VatInboundCents, VatOutboundCents)
VALUES (vatReportId, financialTransactionId, foreignId, financialDependencyTypeId, turnoverCents, vatInboundCents, vatOutboundCents);
SELECT LAST_INSERT_ID() AS Identity;
END
+40
View File
@@ -0,0 +1,40 @@
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);
SELECT LAST_INSERT_ID() AS Identity;
END