Skip to content

Commit e78ad6f

Browse files
committed
chore: advanced map template files
1 parent f490f9a commit e78ad6f

5 files changed

Lines changed: 302 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<Template font="Calibri" FontSize="10" MarginTop="10">
2+
3+
<Data FontStyle="Bold" FontSize="11" TextWrap ="True" Align="Center">TEST COMPANY</Data>
4+
<Data TextWrap ="True" Align="Center">test@gmail.com</Data>
5+
<Data TextWrap ="True" Align="Center">Test Address</Data>
6+
<Data TextWrap ="True" Align="Center">+2547000000001</Data>
7+
8+
<LineBreak/>
9+
<Data FontStyle="Bold" FontSize="12" Align="Center">CUSTOMER PAYMENT RECEIPT</Data>
10+
11+
<LineBreak/>
12+
13+
<Data>Payment No #: 12719</Data>
14+
<Data>Ref No #: CP-20251029-14QH</Data>
15+
<Data>Payment Date: 29-Oct-2025 02:03 PM</Data>
16+
17+
<Line Style="Dash" />
18+
<Data FontStyle="Bold" Align="Right">PAYMENT TO</Data>
19+
<Data TextWrap ="True" Align="Right">MAIN BRANCH</Data>
20+
<Data TextWrap ="True" Align="Right">Account: Cash A/C</Data>
21+
<Data TextWrap ="True" Align="Right">Account Code: 1</Data>
22+
<LineBreak/>
23+
24+
<Line Style="Dash" />
25+
<Data FontStyle="Bold">PAYMENT FROM</Data>
26+
<Data TextWrap ="True">JOHN DOE ENTERPRISES</Data>
27+
<Data TextWrap ="True">Account Code: 54</Data>
28+
<Data TextWrap ="True">Paid By: JOHN DOE</Data>
29+
<LineBreak/>
30+
31+
<Line Style="Dash" />
32+
33+
<Grid ColumnWidths="2*1">
34+
<GridRow>
35+
<Data Grid.Column="0" FontStyle="Bold">AMOUNT</Data>
36+
<Data Grid.Column="1" FontStyle="Bold" FontSize="11" Align="Right">300.00</Data>
37+
</GridRow>
38+
</Grid>
39+
40+
<Data Align="Center" TextWrap="True"></Data>
41+
<Line Style="Dash" />
42+
43+
<LineBreak/>
44+
45+
<Data>Payment received by: George Waynne</Data>
46+
<LineBreak/>
47+
<Data Align="Center" TextWrap ="True">Customer Prev. Bal: 19,395.00, Current Bal: 19,095.00</Data>
48+
<LineBreak/>
49+
<LineBreak/>
50+
<Data Align="Center" FontSize="8">Powered By Semantic POS | www.semanticpos.com</Data>
51+
52+
</Template>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<Template font="Calibri" FontSize="10" MarginTop="10">
2+
3+
<Data FontStyle="Bold" FontSize="11" TextWrap ="True" Align="Center">{{ CompanyName }}</Data>
4+
<Data TextWrap ="True" Align="Center">{{ CompanyEmail }}</Data>
5+
<Data TextWrap ="True" Align="Center">{{ CompanyAddress }}</Data>
6+
<Data TextWrap ="True" Align="Center">{{ CompanyMobile }}</Data>
7+
8+
<LineBreak/>
9+
<Data FontStyle="Bold" FontSize="12" Align="Center">CUSTOMER PAYMENT RECEIPT</Data>
10+
11+
<LineBreak/>
12+
13+
<Data>Payment No #: {{ Id }}</Data>
14+
<Data>Ref No #: {{ ReferenceNo }}</Data>
15+
<Data>Payment Date: {{ PaymentDate:dd-MMM-yyyy hh:mm tt }}</Data>
16+
17+
<Line Style="Dash" />
18+
<Data FontStyle="Bold" Align="Right">PAYMENT TO</Data>
19+
<Data TextWrap ="True" Align="Right">{{ BranchName }}</Data>
20+
<Data TextWrap ="True" Align="Right">Account: {{ LedgerAccountName }}</Data>
21+
<Data TextWrap ="True" Align="Right">Account Code: {{ LedgerAccountId }}</Data>
22+
<LineBreak/>
23+
24+
<Line Style="Dash" />
25+
<Data FontStyle="Bold">PAYMENT FROM</Data>
26+
<Data TextWrap ="True">{{ CustomerName }}</Data>
27+
<Data TextWrap ="True">Account Code: {{ CustomerId }}</Data>
28+
<Data TextWrap ="True">Paid By: {{ PaidBy }}</Data>
29+
<LineBreak/>
30+
31+
<Line Style="Dash" />
32+
33+
<Grid ColumnWidths="2*1">
34+
<GridRow>
35+
<Data Grid.Column="0" FontStyle="Bold">AMOUNT</Data>
36+
<Data Grid.Column="1" FontStyle="Bold" FontSize="11" Align="Right">{{ Amount:N2 }}</Data>
37+
</GridRow>
38+
</Grid>
39+
40+
<Data Align="Center" TextWrap="True">{{ Narration }}</Data>
41+
<Line Style="Dash" />
42+
43+
<LineBreak/>
44+
45+
<Data>Payment received by: {{ RegisteredBy }}</Data>
46+
<LineBreak/>
47+
<Data Align="Center" TextWrap ="True">Customer Prev. Bal: {{ customer_prevBalance }}, Current Bal: {{ customer_currentBalance }}</Data>
48+
<LineBreak/>
49+
<LineBreak/>
50+
<Data Align="Center" FontSize="8">Powered By Semantic POS | www.semanticpos.com</Data>
51+
52+
</Template>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
3+
namespace ObjectSemantics.NET.Tests.MoqModels
4+
{
5+
public class CustomerPayment
6+
{
7+
public int Id { get; set; }
8+
public int CustomerId { get; set; }
9+
public double Amount { get; set; }
10+
public int LedgerAccountId { get; set; }
11+
public string ReferenceNo { get; set; }
12+
public string PaidBy { get; set; }
13+
public string PaidByMobile { get; set; }
14+
public DateTime PaymentDate { get; set; }
15+
public string PaymentStatus { get; set; }
16+
public string RegisteredBy { get; set; }
17+
public Customer Customer { get; set; }
18+
public string Narration { get; set; }
19+
public string CustomerName { get; set; }
20+
public string LedgerAccountName { get; set; }
21+
public LedgerAccount LedgerAccount { get; set; }
22+
public int CompanyBranchId { get; set; }
23+
public object CompanyBranch { get; set; }
24+
}
25+
26+
public class Customer
27+
{
28+
public int Id { get; set; }
29+
public string FirstName { get; set; }
30+
public string LastName { get; set; }
31+
public string CompanyName { get; set; }
32+
public string PrimaryMobile { get; set; }
33+
public string SecondaryMobile { get; set; }
34+
public string PrimaryEmail { get; set; }
35+
public string SecondaryEmail { get; set; }
36+
public string Address { get; set; }
37+
public double OpeningBalance { get; set; }
38+
public DateTime OpeningDate { get; set; }
39+
public double CurrentBalance { get; set; }
40+
public double CreditLimit { get; set; }
41+
public string TaxRefNo { get; set; }
42+
public string BankAccount { get; set; }
43+
public string RoutingNo { get; set; }
44+
public string MoreDetails { get; set; }
45+
public DateTime LastModified { get; set; }
46+
public int LastModifiedAtBranchId { get; set; }
47+
public string ModifiedBy { get; set; }
48+
public string DefaultPriceScheme { get; set; }
49+
public bool IsActive { get; set; }
50+
public string Status { get; set; }
51+
public string FullName { get; set; }
52+
}
53+
54+
public class LedgerAccount
55+
{
56+
public int Id { get; set; }
57+
public int LedgerAccountTypeId { get; set; }
58+
public string AccountCode { get; set; }
59+
public string AccountName { get; set; }
60+
public string Description { get; set; }
61+
public double OpeningBalance { get; set; }
62+
public DateTime OpeningDate { get; set; }
63+
public bool IsBankAccount { get; set; }
64+
public string BankAccountName { get; set; }
65+
public string BankAccountNumber { get; set; }
66+
public string AcCode { get; set; }
67+
public object LedgerAccountType { get; set; }
68+
}
69+
}

ObjectSemantics.NET.Tests/ObjectSemantics.NET.Tests.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@
1010
<FileVersion>3.0.1.1</FileVersion>
1111
</PropertyGroup>
1212

13+
<ItemGroup>
14+
<None Remove="MoqFiles\PaymentTemplate.result.xml" />
15+
<None Remove="MoqFiles\PaymentTemplate.xml" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<Content Include="MoqFiles\PaymentTemplate.result.xml">
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
21+
</Content>
22+
<Content Include="MoqFiles\PaymentTemplate.xml">
23+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
24+
</Content>
25+
</ItemGroup>
26+
1327
<ItemGroup>
1428
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
1529
<PackageReference Include="xunit" Version="2.4.1" />
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
using ObjectSemantics.NET.Tests.MoqModels;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Text;
6+
using Xunit;
7+
8+
namespace ObjectSemantics.NET.Tests
9+
{
10+
public class TemplateFileMappingTests
11+
{
12+
[Fact]
13+
public void Should_Map_Large_File_Template()
14+
{
15+
string template = File.ReadAllText("MoqFiles/PaymentTemplate.xml", Encoding.UTF8);
16+
string expectedResult = File.ReadAllText("MoqFiles/PaymentTemplate.result.xml", Encoding.UTF8);
17+
18+
19+
var payment = new CustomerPayment
20+
{
21+
Id = 12719,
22+
CustomerId = 54,
23+
Amount = 300.0,
24+
LedgerAccountId = 1,
25+
ReferenceNo = "CP-20251029-14QH",
26+
PaidBy = "JOHN DOE",
27+
PaidByMobile = "N/A",
28+
PaymentDate = DateTime.Parse("2025-10-29T14:03:19.4147588"),
29+
PaymentStatus = null,
30+
RegisteredBy = "George Waynne",
31+
Customer = new Customer
32+
{
33+
Id = 54,
34+
FirstName = "JOHN DOE",
35+
LastName = "ENTERPRISES",
36+
CompanyName = "John Doe Enterprises",
37+
PrimaryMobile = "N/A",
38+
SecondaryMobile = null,
39+
PrimaryEmail = "",
40+
SecondaryEmail = null,
41+
Address = "",
42+
OpeningBalance = 0.0,
43+
OpeningDate = DateTime.Parse("2023-11-13T00:00:00"),
44+
CurrentBalance = 19095.0,
45+
CreditLimit = 0.0,
46+
TaxRefNo = "",
47+
BankAccount = null,
48+
RoutingNo = null,
49+
MoreDetails = "",
50+
LastModified = DateTime.Parse("2024-06-18T18:11:41.7819616"),
51+
LastModifiedAtBranchId = 1,
52+
ModifiedBy = "Joe Maina",
53+
DefaultPriceScheme = "SELLING PRICE",
54+
IsActive = true,
55+
Status = "ACTIVE",
56+
FullName = "Afrique"
57+
},
58+
Narration = null,
59+
CustomerName = "JOHN DOE ENTERPRISES",
60+
LedgerAccountName = "Cash A/C",
61+
LedgerAccount = new LedgerAccount
62+
{
63+
Id = 1,
64+
LedgerAccountTypeId = 4,
65+
AccountCode = "82187",
66+
AccountName = "Cash A/C",
67+
Description = "Current Cash",
68+
OpeningBalance = 0.0,
69+
OpeningDate = DateTime.Parse("2020-03-20T10:39:12"),
70+
IsBankAccount = false,
71+
BankAccountName = null,
72+
BankAccountNumber = null,
73+
AcCode = "82187",
74+
LedgerAccountType = null
75+
},
76+
CompanyBranchId = 1,
77+
CompanyBranch = null
78+
};
79+
80+
81+
//additional headers
82+
var additionalParams = new Dictionary<string, object>
83+
{
84+
["BranchId"] = "1",
85+
["BranchName"] = "MAIN BRANCH",
86+
["BranchMobile"] = "Default",
87+
["BranchEmail"] = "Default",
88+
["BranchAddress"] = "Default",
89+
["customer_name"] = "Afrique",
90+
["customer_email"] = "",
91+
["customer_mobile"] = "N/A",
92+
["customer_address"] = "",
93+
["customer_taxrefno"] = "",
94+
["customer_prevBalance"] = "19,395.00",
95+
["customer_currentBalance"] = "19,095.00",
96+
["CompanyAddress"] = "Test Address",
97+
["CompanyBusinessType"] = "RETAIL & WHOLESALE STORE",
98+
["CompanyEmail"] = "test@gmail.com",
99+
["CompanyMobile"] = "+2547000000001",
100+
["CompanyName"] = "TEST COMPANY",
101+
["CompanyTaxNo"] = "P000000001",
102+
["ReportsDeliveryEmailAddresses"] = "",
103+
["CompanyLogo"] = "logo.jpg",
104+
["footer"] = "!Thank you and Come Again!"
105+
};
106+
107+
108+
//map
109+
var result = payment.Map(template, additionalParams);
110+
111+
Assert.Equal(result, expectedResult);
112+
}
113+
114+
}
115+
}

0 commit comments

Comments
 (0)