Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support negative article amounts lead to errors [Epson RT Printer] #301

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private static void GenerateItems(List<ItemAndMessage> itemAndMessages, ChargeIt
itemAndMessages.Add(new() { PrintRecItem = printRecItem, PrintRecMessage = printRecMessage });
}
else if (i.IsSingleUseVoucher() && i.Amount < 0)
{
{
var printRecItemAdjustment = new PrintRecItemAdjustment
{
Description = i.Description,
Expand All @@ -352,6 +352,17 @@ private static void GenerateItems(List<ItemAndMessage> itemAndMessages, ChargeIt
};
itemAndMessages.Add(new() { PrintRecItem = printRecItem });
}
else if (i.Amount < 0)
{
var printRecItemAdjustment = new PrintRecItemAdjustment
{
Description = i.Description,
Amount = Math.Abs(i.Amount),
AdjustmentType = 3,
Department = i.GetVatGroup(),
};
itemAndMessages.Add(new() { PrintRecItemAdjustment = printRecItemAdjustment });
}
else
{
var printRecItem = new PrintRecItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,42 @@ public async Task ProcessPosReceipt_0x4954_2000_0000_0001_SingleUseVoucher_Redee
result.ReceiptResponse.ftSignatures.Should().Contain(x => x.ftSignatureType == (ITConstants.BASE_STATE | (long) SignatureTypesIT.RTDocumentType));
}

[Fact]
public async Task ProcessPosReceipt_0x4954_2000_0000_0001_Cash_WithNegativeAmount()
{
var itsscd = GetSUT();
var result = await itsscd.ProcessReceiptAsync(new ProcessRequest
{
ReceiptRequest = ReceiptExamples.Cash_WithNegativeAmount(),
ReceiptResponse = _receiptResponse
});

using var scope = new AssertionScope();
result.ReceiptResponse.ftSignatures.Should().Contain(x => x.ftSignatureType == (ITConstants.BASE_STATE | (long) SignatureTypesIT.RTSerialNumber));
result.ReceiptResponse.ftSignatures.Should().Contain(x => x.ftSignatureType == (ITConstants.BASE_STATE | (long) SignatureTypesIT.RTZNumber));
result.ReceiptResponse.ftSignatures.Should().Contain(x => x.ftSignatureType == (ITConstants.BASE_STATE | (long) SignatureTypesIT.RTDocumentNumber));
result.ReceiptResponse.ftSignatures.Should().Contain(x => x.ftSignatureType == (ITConstants.BASE_STATE | (long) SignatureTypesIT.RTDocumentMoment));
result.ReceiptResponse.ftSignatures.Should().Contain(x => x.ftSignatureType == (ITConstants.BASE_STATE | (long) SignatureTypesIT.RTDocumentType));
}

[Fact]
public async Task ProcessPosReceipt_0x4954_2000_0000_0001_Cash_WithNegativeAmount_Void()
{
var itsscd = GetSUT();
var result = await itsscd.ProcessReceiptAsync(new ProcessRequest
{
ReceiptRequest = ReceiptExamples.Cash_WithNegativeAmount_Void(),
ReceiptResponse = _receiptResponse
});

using var scope = new AssertionScope();
result.ReceiptResponse.ftSignatures.Should().Contain(x => x.ftSignatureType == (ITConstants.BASE_STATE | (long) SignatureTypesIT.RTSerialNumber));
result.ReceiptResponse.ftSignatures.Should().Contain(x => x.ftSignatureType == (ITConstants.BASE_STATE | (long) SignatureTypesIT.RTZNumber));
result.ReceiptResponse.ftSignatures.Should().Contain(x => x.ftSignatureType == (ITConstants.BASE_STATE | (long) SignatureTypesIT.RTDocumentNumber));
result.ReceiptResponse.ftSignatures.Should().Contain(x => x.ftSignatureType == (ITConstants.BASE_STATE | (long) SignatureTypesIT.RTDocumentMoment));
result.ReceiptResponse.ftSignatures.Should().Contain(x => x.ftSignatureType == (ITConstants.BASE_STATE | (long) SignatureTypesIT.RTDocumentType));
}

[Fact]
public async Task ProcessPosReceipt_0x4954_2000_0000_0001_SingleUseVoucher_Redeem_MultipleVatRates()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ public static ReceiptRequest CashWithSingleUseVoucherRedeem()
return JsonConvert.DeserializeObject<ReceiptRequest>(receipt);
}

public static ReceiptRequest Cash_WithNegativeAmount()
{
var current_moment = DateTime.UtcNow.ToString("o");
var receipt = File.ReadAllText(Path.Combine("ReceiptRequests", "PosReceipts", "0x0001_Cash_WithNegativeAmount.json")).Replace("{{current_moment}}", current_moment);
return JsonConvert.DeserializeObject<ReceiptRequest>(receipt);
}

public static ReceiptRequest Cash_WithNegativeAmount_Void()
{
var current_moment = DateTime.UtcNow.ToString("o");
var receipt = File.ReadAllText(Path.Combine("ReceiptRequests", "PosReceipts", "0x0001_Cash_WithNegativeAmount_Void.json")).Replace("{{current_moment}}", current_moment);
return JsonConvert.DeserializeObject<ReceiptRequest>(receipt);
}

public static ReceiptRequest CashWithSingleUseVoucherPurchase()
{
var current_moment = DateTime.UtcNow.ToString("o");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"ftCashBoxID": "4038ca6d-fe63-46d0-95d6-a1fce0f98258",
"ftQueueID": "910347dc-a5fc-44bf-9ef0-2ec5fda824ca",
"ftPosSystemId": "e0c014d5-44de-4eec-886f-02dde5ec2d3a",
"cbTerminalID": "1",
"cbReceiptReference": "926804fa-f185-4d48-809c-b73c6b3297e1",
"cbReceiptMoment": "2024-05-09T10:03:22.7Z",
"cbChargeItems": [
{
"Position": 100,
"Quantity": 1.0000,
"Description": "Felsenkeller",
"Amount": 4.80000000000000000000000000,
"VATRate": 10.0000,
"ftChargeItemCase": 5283883447184523281,
"ftChargeItemCaseData": "",
"VATAmount": 0.4363636363636363636363636364,
"CostCenter": "4",
"ProductGroup": "Biere",
"ProductNumber": "5009",
"ProductBarcode": "",
"Unit": "Stk",
"Moment": "2024-05-09T10:03:11.233Z"
},
{

"Position": 200,
"Quantity": 1.0000,
"Description": "Klein",
"Amount": -2.00000000000000000000000000,
"VATRate": 10.0000,
"ftChargeItemCase": 5283883447184523281,
"ftChargeItemCaseData": "",
"VATAmount": -0.1818181818181818181818181818,
"CostCenter": "4",
"ProductGroup": "Pizza",
"ProductNumber": "40041",
"ProductBarcode": "",
"Unit": "Stk",
"Moment": "2024-05-09T10:03:17.173Z"
}
],
"cbPayItems": [
{
"Quantity": 1.0,
"Description": "Bar",
"Amount": 2.8000,
"ftPayItemCase": 5283883447184523265,
"ftPayItemCaseData": "",
"CostCenter": "4",
"MoneyGroup": "1",
"MoneyNumber": ""
}
],
"ftReceiptCase": 5283883447318740993,
"cbReceiptAmount": 2.80,
"cbUser": "Chef",
"cbArea": "53"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"ftCashBoxID": "4038ca6d-fe63-46d0-95d6-a1fce0f98258",
"ftQueueID": "910347dc-a5fc-44bf-9ef0-2ec5fda824ca",
"ftPosSystemId": "e0c014d5-44de-4eec-886f-02dde5ec2d3a",
"cbTerminalID": "1",
"cbReceiptReference": "926804fa-f185-4d48-809c-b73c6b3297e1",
"cbReceiptMoment": "2024-05-09T10:03:22.7Z",
"cbChargeItems": [
{
"Position": 100,
"Quantity": -1.0000,
"Description": "Felsenkeller",
"Amount": -4.80000000000000000000000000,
"VATRate": 10.0000,
"ftChargeItemCase": 5283883447184523281,
"ftChargeItemCaseData": "",
"VATAmount": -0.4363636363636363636363636364,
"CostCenter": "4",
"ProductGroup": "Biere",
"ProductNumber": "5009",
"ProductBarcode": "",
"Unit": "Stk",
"Moment": "2024-05-09T10:03:11.233Z"
},
{

"Position": 200,
"Quantity": 1.0000,
"Description": "Klein",
"Amount": 2.00000000000000000000000000,
"VATRate": 10.0000,
"ftChargeItemCase": 5283883447184523281,
"ftChargeItemCaseData": "",
"VATAmount": 0.1818181818181818181818181818,
"CostCenter": "4",
"ProductGroup": "Pizza",
"ProductNumber": "40041",
"ProductBarcode": "",
"Unit": "Stk",
"Moment": "2024-05-09T10:03:17.173Z"
}
],
"cbPayItems": [
{
"Quantity": 1.0,
"Description": "Bar",
"Amount": -2.8000,
"ftPayItemCase": 5283883447184523265,
"ftPayItemCaseData": "",
"CostCenter": "4",
"MoneyGroup": "1",
"MoneyNumber": ""
}
],
"ftReceiptCase": 5283883447318740993,
"cbReceiptAmount": -2.80,
"cbUser": "Chef",
"cbArea": "53"
}
Loading