Skip to content

Commit

Permalink
Merge pull request #627 from openpetra/TP-2021.10-merge-release
Browse files Browse the repository at this point in the history
Tp 2021.10 merge release
  • Loading branch information
tpokorra committed Oct 27, 2021
2 parents 9dfca7f + 20e2e8e commit 2e992c9
Show file tree
Hide file tree
Showing 58 changed files with 2,881 additions and 426 deletions.
4 changes: 2 additions & 2 deletions appveyor.yml
Expand Up @@ -2,7 +2,7 @@
image: Ubuntu2004
version: 1.0.{build}
platform: x86
stack: mysql, node 10
stack: mysql, node 14
clone_depth: 1
init: []
environment:
Expand All @@ -14,7 +14,7 @@ install:
#- sudo -E ln -s `which npm` /usr/bin/npm
#- sudo -E chown -R 1001:1001 "/home/appveyor/.npm"
#- sudo sed -i "s/\[mysqld\]/[mysqld]\nskip-name-resolve/g" /etc/mysql/my.cnf && sudo systemctl restart mysql
- curl https://get.openpetra.org > getopenpetra.sh && chmod a+x getopenpetra.sh && sudo -E ./getopenpetra.sh devenv
- curl https://get.openpetra.org > getopenpetra.sh && chmod a+x getopenpetra.sh && sudo -E ./getopenpetra.sh devenv --iknowwhatiamdoing=yes
build_script:
- echo "building was already done in install section"
test_script:
Expand Down
3 changes: 2 additions & 1 deletion csharp/ICT/Common/DB/MySQL.cs
Expand Up @@ -4,7 +4,7 @@
// @Authors:
// timop
//
// Copyright 2004-2020 by OM International
// Copyright 2004-2021 by OM International
//
// This file is part of OpenPetra.org.
//
Expand Down Expand Up @@ -163,6 +163,7 @@ public String FormatQueryRDBMSSpecific(String ASqlQuery)
ReturnValue = ReturnValue.Replace("true AS ", "1 AS ");
ReturnValue = ReturnValue.Replace("false AS ", "0 AS ");
ReturnValue = ReturnValue.Replace("SUM (", "SUM(");
ReturnValue = ReturnValue.Replace("COUNT (", "COUNT(");

if (ReturnValue.Contains(" AS usage"))
{
Expand Down
11 changes: 8 additions & 3 deletions csharp/ICT/Common/IO/Csv2Xml.cs
Expand Up @@ -371,8 +371,12 @@ public static bool CSV2ExcelStream(string ACSVData, MemoryStream AStream, string

IRow wsrow = null;
ICell wscell = null;
Int32 rowCounter = 1;
Int16 colCounter = 1;
Int32 rowCounter = 0;
Int16 colCounter = 0;

ICellStyle wsstyle_dateformat = workbook.CreateCellStyle();
ICreationHelper createHelper = workbook.GetCreationHelper();
wsstyle_dateformat.DataFormat = createHelper.CreateDataFormat().GetFormat("dd/mm/yyyy");

// we don't have headers for the columns

Expand Down Expand Up @@ -401,6 +405,7 @@ public static bool CSV2ExcelStream(string ACSVData, MemoryStream AStream, string
else if (v.TypeVariant == eVariantTypes.eDateTime)
{
wscell.SetCellValue(v.ToDate());
wscell.CellStyle = wsstyle_dateformat;
}
else
{
Expand All @@ -411,7 +416,7 @@ public static bool CSV2ExcelStream(string ACSVData, MemoryStream AStream, string

LineCounter++;
rowCounter++;
colCounter = 1;
colCounter = 0;
}

workbook.Write(AStream);
Expand Down
11 changes: 10 additions & 1 deletion csharp/ICT/Common/IO/Yml2Xml.cs
Expand Up @@ -4,7 +4,7 @@
// @Authors:
// timop
//
// Copyright 2004-2019 by OM International
// Copyright 2004-2021 by OM International
//
// This file is part of OpenPetra.org.
//
Expand Down Expand Up @@ -756,6 +756,8 @@ private void ParseNode(XmlNode parent, int ADepth)
}

PrintedOriginalError = true;

throw new Exception("Problem in line " + currentLine.ToString() + " " + line);
}

throw;
Expand Down Expand Up @@ -929,6 +931,13 @@ public XmlDocument ParseYML2XML()
{
// recursive parsing of the yml document
ParseNode(root, 0);

if (GetAbsoluteIndentationNext(currentLine) > 0)
{
string line = GetNextLine();
TLogging.Log("Problem in line " + currentLine.ToString() + " " + line);
throw new Exception("Problem in line " + currentLine.ToString() + " " + line);
}
}
catch (Exception e)
{
Expand Down
22 changes: 21 additions & 1 deletion csharp/ICT/Common/Printing/Html2Pdf.cs
Expand Up @@ -33,6 +33,26 @@ namespace Ict.Common.Printing
/// usw wkhtmltopdf to print HTML to PDF
public class Html2Pdf
{
/// get the path to the wkhtmltopdf binary
public static string GetWkHTMLToPDFPath()
{
// Debian
string wkhtmltopdf = TAppSettingsManager.GetValue("wkhtmltopdf.Path", "/usr/bin/wkhtmltopdf");

if (!File.Exists(wkhtmltopdf))
{
// CentOS
wkhtmltopdf = "/usr/local/bin/wkhtmltopdf";
}

if (!File.Exists(wkhtmltopdf))
{
throw new Exception("Cannot find wkhtmltopdf. Please set wkhtmltopdf.Path in the config file");
}

return wkhtmltopdf;
}

/// <summary>
/// Create a PDF file from the HTML
/// </summary>
Expand Down Expand Up @@ -78,7 +98,7 @@ public static bool HTMLToPDF(string AHtmlText, string AOutputPDFFilename)
}

Process process = new Process();
process.StartInfo.FileName = TAppSettingsManager.GetValue("wkhtmltopdf.Path", "/usr/local/bin/wkhtmltopdf");
process.StartInfo.FileName = GetWkHTMLToPDFPath();
process.StartInfo.Arguments = HTMLFile + " " + AOutputPDFFilename;
process.Start();
process.WaitForExit();
Expand Down
24 changes: 21 additions & 3 deletions csharp/ICT/Common/Session/Session.cs
Expand Up @@ -94,8 +94,23 @@ public static void InitThread(string AThreadDescription, string AConfigFileName,

TDataBase db = null;

// avoid dead lock on parallel logins
FDeleteSessionMutex.WaitOne();
try
{
// avoid dead lock on parallel logins
if (!FDeleteSessionMutex.WaitOne(5000))
{
throw new Exception("Server is too busy");
}
}
catch(AbandonedMutexException ex)
{
TLogging.Log("Mutex was abandoned");

// Whether or not the exception was thrown, the current
// thread owns the mutex, and must release it.
if (ex.Mutex != null) ex.Mutex.ReleaseMutex();
throw new Exception("AbandonedMutex has been cleared");
}

try
{
Expand Down Expand Up @@ -132,7 +147,10 @@ public static void InitThread(string AThreadDescription, string AConfigFileName,
}
finally
{
db.CloseDBConnection();
if (db != null)
{
db.CloseDBConnection();
}

FDeleteSessionMutex.ReleaseMutex();
}
Expand Down
18 changes: 14 additions & 4 deletions csharp/ICT/Petra/Server/app/WebService/SessionManager.cs
Expand Up @@ -94,19 +94,29 @@ public TOpenPetraOrgSessionManager() : base()
/// </summary>
private static bool Init()
{
string ConfigFileName = string.Empty;

// make sure the correct config file is used
string Instance = HttpContext.Current.Request.Url.ToString().Replace("http://", "").Replace("https://", "");
Instance = Instance.Substring(0, Instance.IndexOf(".")).Replace("op_","op").Replace("op", "op_");
Instance = Instance.Substring(0, Instance.IndexOf(".")).Replace("openpetra", "OPENPETRA").Replace("op_","op").Replace("op", "op_").ToLower();

// for demo etc
if (!Instance.StartsWith("op_"))
{
Instance = "op_" + Instance;
}

ConfigFileName = "/home/" + Instance + "/etc/PetraServerConsole.config";
string ConfigFileName = "/home/" + Instance + "/etc/PetraServerConsole.config";

if (!File.Exists(ConfigFileName))
{
// multi tenant on shared hosting
ConfigFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "instances") + "/" + Instance + "/etc/PetraServerConsole.config";
}

if (!File.Exists(ConfigFileName))
{
// single tenant on shared hosting
ConfigFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), Instance) + "/etc/PetraServerConsole.config";
}

if (File.Exists(ConfigFileName))
{
Expand Down
Expand Up @@ -2949,12 +2949,13 @@ public static GLBatchTDS CreateABatch(Int32 ALedgerNumber, TDataBase ADataBase,

#endregion Validate Data

ABatchRow NewRow = MainDS.ABatch.NewRowTyped(true);
GLBatchTDSABatchRow NewRow = MainDS.ABatch.NewRowTyped(true);
NewRow.LedgerNumber = ALedgerNumber;
MainDS.ALedger[0].LastBatchNumber++;
NewRow.BatchNumber = MainDS.ALedger[0].LastBatchNumber;
NewRow.BatchPeriod = MainDS.ALedger[0].CurrentPeriod;
NewRow.BatchYear = MainDS.ALedger[0].CurrentFinancialYear;
NewRow.TransactionCurrency = MainDS.ALedger[0].BaseCurrency;

if (AWithGLJournal)
{
Expand Down
Expand Up @@ -4,7 +4,7 @@
// @Authors:
// wolfgangu, christophert, timop
//
// Copyright 2004-2019 by OM International
// Copyright 2004-2021 by OM International
//
// This file is part of OpenPetra.org.
//
Expand Down Expand Up @@ -561,6 +561,12 @@ public static decimal GetCorporateExchangeRate(string ACurrencyFrom, string ACur
out decimal AExchangeRateToFind,
TDataBase ADataBase = null)
{
if (ACurrencyFrom == ACurrencyTo)
{
AExchangeRateToFind = 1.0M;
return true;
}

AExchangeRateToFind = decimal.MinValue;
decimal ExchangeRateToFind = AExchangeRateToFind;

Expand Down
21 changes: 19 additions & 2 deletions csharp/ICT/Petra/Server/lib/MFinance/GL/GL.Importing.cs
Expand Up @@ -23,6 +23,7 @@
//
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Globalization;
using System.IO;
Expand Down Expand Up @@ -219,6 +220,7 @@ public class TGLImporting
// Go round a loop reading the file line by line
ImportMessage = Catalog.GetString("Parsing first line");
FImportLine = sr.ReadLine();
FNewLine = String.Empty;

Int32 TextProcessedLength = 0;

Expand Down Expand Up @@ -961,6 +963,7 @@ public class TGLImporting

// Go round a loop reading the file line by line
FImportLine = sr.ReadLine();
FNewLine = String.Empty;

while (FImportLine != null)
{
Expand All @@ -972,7 +975,14 @@ public class TGLImporting
// skip empty lines and commented lines
if ((FImportLine.Trim().Length > 0) && !FImportLine.StartsWith("/*") && !FImportLine.StartsWith("#"))
{
int numberOfElements = StringHelper.GetCSVList(FImportLine, FDelimiter).Count + 1;
StringCollection csvlist = StringHelper.GetCSVList(FImportLine, FDelimiter);

if (csvlist == null)
{
throw new Exception("wrong delimiter");
}

int numberOfElements = csvlist.Count + 1;

if (numberOfElements < 8)
{
Expand Down Expand Up @@ -1362,7 +1372,14 @@ public class TGLImporting
NewTransaction.TransactionAmount = CreditAmount;
}

NewTransaction.AmountInBaseCurrency = GLRoutines.Divide(NewTransaction.TransactionAmount, ANewJournalRow.ExchangeRateToBase);
if (ANewJournalRow.ExchangeRateToBase > 0)
{
NewTransaction.AmountInBaseCurrency = GLRoutines.Divide(NewTransaction.TransactionAmount, ANewJournalRow.ExchangeRateToBase);
}
else
{
NewTransaction.AmountInBaseCurrency = NewTransaction.TransactionAmount;
}

// If we know the international currency exchange rate we can set the value for the transaction amount
if (AIntlRateFromBase > 0.0m)
Expand Down

0 comments on commit 2e992c9

Please sign in to comment.