Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cs8898 committed Oct 17, 2024
1 parent ff81a5b commit 9e993bd
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 1 deletion.
27 changes: 27 additions & 0 deletions roqqio/POSLog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,33 @@ func TestRetoureWithLinkXml(t *testing.T) {
assertThat(t, lineItems[0].Sale.TransactionLink.BusinessDayDate, "2024-10-15")
}

func TestPosStorno(t *testing.T) {
posLog := handleXmlFile(t, "testdata/sale_with_posStorno.xml")
assertNil(t, posLog.Transaction.RetailTransaction.Customer)
assertNil(t, posLog.GetCustomer())
assertNil(t, posLog.GetLoyaltyAccount())

assertNotNil(t, posLog.GetLineItems())
assertThat(t, len(*posLog.GetLineItems()), 3)

lineItems := *posLog.GetLineItems()
assertThat(t, lineItems[0].GetType(), LineTypeSale)
assertThat(t, lineItems[0].IsSale(), true)
assertThat(t, lineItems[0].IsTender(), false)
assertThat(t, lineItems[0].IsTenderChange(), false)

assertThat(t, lineItems[1].GetType(), LineTypeSale)
assertThat(t, lineItems[1].IsSale(), true)
assertThat(t, lineItems[1].IsTender(), false)
assertThat(t, lineItems[1].IsTenderChange(), false)

assertThat(t, lineItems[2].GetType(), LineTypeTender)
assertThat(t, lineItems[2].IsSale(), false)
assertThat(t, lineItems[2].IsTender(), true)
assertThat(t, lineItems[2].IsTenderChange(), false)
assertThat(t, lineItems[2].Tender.TypeCode, TenderTypeCodeSale)
}

func assertNotNil[C any](t *testing.T, a *C) {
t.Helper()
if a == nil {
Expand Down
2 changes: 1 addition & 1 deletion roqqio/testdata/retoure_with_link.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@
<BusinessDayDate>2024-10-15</BusinessDayDate>
<BeginDateTime>2024-10-15T09:26:27.433Z</BeginDateTime>
<EndDateTime>2024-10-15T09:27:02.649Z</EndDateTime>
<fu:Hashcode>LNK/S2/V6:3569/ba39f79318d327b4e732eef6444a4c2122c89ac7fd36a2c05b44e41abdd50a6a6cab9d6a586922c4fa6d932cbbfb91dfe20b6e99ca3a949e304d81ee80ffa5f6</fu:Hashcode>
<fu:Hashcode>LNK/S2/V6:3569/[invalid]</fu:Hashcode>
</Transaction>
</POSLog>
69 changes: 69 additions & 0 deletions roqqio/testdata/sale_with_posStorno.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<POSLog xsi:schemaLocation="http://www.nrf-arts.org/IXRetail/namespace/ ../POSLogV6.0.0.xsd" xmlns="http://www.nrf-arts.org/IXRetail/namespace/" xmlns:fu="http://www.futura4retail.com/pos/namespace/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="6" MinorVersion="0" FixVersion="0">
<Transaction>
<BusinessUnit>
<UnitID Name="Christian Schmied IT">100</UnitID>
</BusinessUnit>
<WorkstationID TypeCode="POS">10001</WorkstationID>
<SequenceNumber>3617</SequenceNumber>
<POSLogDateTime>2024-10-15T14:11:12.214</POSLogDateTime>
<OperatorID OperatorName="NullPerson NullPerson" OperatorType="Cashier">0</OperatorID>
<ReceiptDateTime>2024-10-15T14:11:12.214</ReceiptDateTime>
<ReceiptNumber>3617</ReceiptNumber>
<RetailTransaction>
<LineItem>
<Sale>
<ItemID Name="BULL'S B-Star Flights, -,MEHRFARBIGES MOTIV,011">4022847518216</ItemID>
<RegularSalesUnitPrice Currency="EUR">1.490</RegularSalesUnitPrice>
<ActualSalesUnitPrice Currency="EUR">1.490</ActualSalesUnitPrice>
<ExtendedAmount Currency="EUR">1.490</ExtendedAmount>
<ExtendedDiscountAmount Currency="XXX">0</ExtendedDiscountAmount>
<Quantity UnitOfMeasureCode="EA">1.0000</Quantity>
<Rounding Currency="EUR">0.000</Rounding>
<fu:SalesMode>MODE_NORMAL</fu:SalesMode>
<fu:LineType>ITEM_SALE</fu:LineType>
<fu:Dimension1>-</fu:Dimension1>
<fu:Dimension2>MEHRFARBIGES MOTIV</fu:Dimension2>
<fu:Dimension3>011</fu:Dimension3>
<fu:ProductGroup>8091115</fu:ProductGroup>
</Sale>
<SequenceNumber>11</SequenceNumber>
</LineItem>
<LineItem>
<Sale>
<ItemID Name="BULL'S Motex Flights, -,MEHRFARBIGES MOTIV,011">4022847522022</ItemID>
<RegularSalesUnitPrice Currency="EUR">1.290</RegularSalesUnitPrice>
<ActualSalesUnitPrice Currency="EUR">1.290</ActualSalesUnitPrice>
<ExtendedAmount Currency="EUR">1.290</ExtendedAmount>
<ExtendedDiscountAmount Currency="XXX">0</ExtendedDiscountAmount>
<Quantity UnitOfMeasureCode="EA">1.0000</Quantity>
<Rounding Currency="EUR">0.000</Rounding>
<fu:SalesMode>MODE_NORMAL</fu:SalesMode>
<fu:LineType>ITEM_SALE</fu:LineType>
<fu:Dimension1>-</fu:Dimension1>
<fu:Dimension2>MEHRFARBIGES MOTIV</fu:Dimension2>
<fu:Dimension3>011</fu:Dimension3>
<fu:ProductGroup>8091115</fu:ProductGroup>
</Sale>
<SequenceNumber>12</SequenceNumber>
</LineItem>
<LineItem>
<Tender TenderType="Cash" TypeCode="Sale">
<Amount Currency="EUR">2.780</Amount>
<Rounding>0.000</Rounding>
<fu:PaymentTypeExternalId>1</fu:PaymentTypeExternalId>
<fu:PaymentTypeDescription>Bar</fu:PaymentTypeDescription>
</Tender>
<SequenceNumber>14</SequenceNumber>
</LineItem>
<Total TotalType="TransactionGrandAmount" CurrencyCode="EUR">2.780</Total>
<Total TotalType="TransactionNetAmount" CurrencyCode="EUR">2.330</Total>
<Total TotalType="TransactionTaxAmount" CurrencyCode="EUR">0.440</Total>
<Total TotalType="TransactionGrossAmount" CurrencyCode="EUR">2.780</Total>
</RetailTransaction>
<BusinessDayDate>2024-10-15</BusinessDayDate>
<BeginDateTime>2024-10-15T12:09:02.775Z</BeginDateTime>
<EndDateTime>2024-10-15T12:11:12.214Z</EndDateTime>
<fu:Hashcode>LNK/S2/V6:3616/[invalid]</fu:Hashcode>
</Transaction>
</POSLog>

0 comments on commit 9e993bd

Please sign in to comment.