Skip to content

Commit

Permalink
Merge pull request #43 from parassanghani6/stock-negative-qty
Browse files Browse the repository at this point in the history
enable checking for negative values for stock quntity
  • Loading branch information
saivineeth100 authored Apr 24, 2024
2 parents 0cfbb08 + 073be49 commit a30e0e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void ReadXml(XmlReader reader)
if (content != null && content != string.Empty)
{
content = content.Trim();
var matches = Regex.Matches(content, @"\b[0-9.]+\b");
var matches = Regex.Matches(content, @"-?\b[0-9.]+\b");
if (matches.Count == 2)
{
Number = decimal.Parse(matches[0].Value, CultureInfo.InvariantCulture);
Expand Down
17 changes: 17 additions & 0 deletions src/Tests/Converters/XMLConverterHelpers/TallyQuantityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ public void CheckTallyQuantity()
});
}

[Test]
public void CheckTallyNegativeQuantity()
{
string TallyQuantitytXml = "<QUANTITY> -50 Nos</QUANTITY>";

using TextReader reader = new StringReader(TallyQuantitytXml);
var quantity = (TallyQuantity)xmlSerializer.Deserialize(reader);

Assert.Multiple(() =>
{
Assert.That(quantity.Number, Is.EqualTo(-50));
Assert.That(quantity.PrimaryUnits.Number, Is.EqualTo(-50));
Assert.That(quantity.PrimaryUnits.Unit, Is.EqualTo("Nos"));
Assert.That(quantity.SecondaryUnits, Is.EqualTo(null));
});
}

[Test]
public void CheckTallyQuantitywithSecondaryUnit()
{
Expand Down

0 comments on commit a30e0e5

Please sign in to comment.