Skip to content

Commit 894781b

Browse files
committed
Some maintenance work:
* Fixed some Intellisense warnings. * Corrected some comments. * Obsoleted `InvoiceDescriptor::AddTradeeCharge`, because there's an identical function `InvoiceDescriptor::AddTradeCharge`. (Note the typo in "Tradee".)
1 parent 6da18e0 commit 894781b

9 files changed

+5258
-5230
lines changed

ZUGFeRD.Test/XRechnungUBLTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public void TestSkippingOfAllowanceChargeBasisAmount()
235235

236236
InvoiceDescriptor loadedInvoice = InvoiceDescriptor.Load(ms);
237237

238-
Tax tax = loadedInvoice.Taxes.FirstOrDefault(t => t.TypeCode == TaxTypes.LOC);
238+
Tax? tax = loadedInvoice.Taxes.FirstOrDefault(t => t.TypeCode == TaxTypes.LOC);
239239
Assert.IsNotNull(tax);
240240
Assert.AreEqual(basisAmount, tax.BasisAmount);
241241
Assert.AreEqual(percent, tax.Percent);

ZUGFeRD.Test/ZUGFeRDCrossVersionTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,8 @@ public void TestGrossPriceRepresentationForXRechnungAndNotXRechnungPositiveCase(
545545
{
546546
decimal grossPrice = 10.1m;
547547
decimal netPrice = 10.0m;
548-
decimal discountPercent = 10.0m;
548+
// Is currently unused, therefore commented out.
549+
//decimal discountPercent = 10.0m;
549550
decimal discountAmount = 0.1m;
550551

551552
InvoiceDescriptor desc = this._InvoiceProvider.CreateInvoice();
@@ -980,8 +981,9 @@ public void TestWithoutGrossQuantity(ZUGFeRDVersion version, ZUGFeRDFormats form
980981
[DataRow(ZUGFeRDVersion.Version23, ZUGFeRDFormats.CII, Profile.Extended)]
981982
public void TestNulledGlobalIDScheme(ZUGFeRDVersion version, ZUGFeRDFormats format, Profile profile)
982983
{
983-
decimal? desiredNetUnitQuantity = 20.0m;
984-
decimal? desiredGrossUnitQuantity = 23.0m;
984+
// Is currently unused, therefore commented out.
985+
//decimal? desiredNetUnitQuantity = 20.0m;
986+
//decimal? desiredGrossUnitQuantity = 23.0m;
985987

986988
InvoiceDescriptor desc = new InvoiceProvider().CreateInvoice();
987989

ZUGFeRD/InvoiceDescriptor.cs

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,9 @@ public void SetContractReferencedDocument(string contractNo, DateTime? contractD
10341034
ID = contractNo,
10351035
IssueDateTime = contractDate
10361036
};
1037-
} // !SetContractReferencedDocument()
1038-
1039-
1037+
} // !SetContractReferencedDocument()
1038+
1039+
10401040
internal void _AddLogisticsServiceCharge(decimal amount, string description, TaxTypes? taxTypeCode, TaxCategoryCodes? taxCategoryCode, decimal taxPercent)
10411041
{
10421042
this.ServiceCharges.Add(new ServiceCharge()
@@ -1095,7 +1095,7 @@ public void AddTradeAllowance(decimal? basisAmount, CurrencyCodes currency, deci
10951095
internal void _AddTradeAllowance(decimal? basisAmount, CurrencyCodes currency, decimal actualAmount,
10961096
string reason, TaxTypes? taxTypeCode, TaxCategoryCodes? taxCategoryCode, decimal taxPercent,
10971097
AllowanceReasonCodes? reasonCode = null)
1098-
{
1098+
{
10991099
this.TradeAllowanceCharges.Add(new TradeAllowance()
11001100
{
11011101
Reason = reason,
@@ -1142,7 +1142,7 @@ internal void _AddTradeCharge(decimal? basisAmount, CurrencyCodes currency, deci
11421142
decimal? chargePercentage,
11431143
string reason, TaxTypes? taxTypeCode, TaxCategoryCodes? taxCategoryCode, decimal taxPercent,
11441144
ChargeReasonCodes? reasonCode = null)
1145-
{
1145+
{
11461146
this.TradeAllowanceCharges.Add(new TradeCharge()
11471147
{
11481148
Reason = reason,
@@ -1169,8 +1169,8 @@ internal void _AddTradeCharge(decimal? basisAmount, CurrencyCodes currency, deci
11691169
/// </summary>
11701170
/// <param name="basisAmount">Base amount for calculation</param>
11711171
/// <param name="currency">Currency code</param>
1172-
/// <param name="actualAmount">Actual amount of allowance/charge</param>
1173-
/// <param name="reason">Reason for allowance/charge</param>
1172+
/// <param name="actualAmount">Actual amount of charge</param>
1173+
/// <param name="reason">Reason for charge</param>
11741174
/// <param name="taxTypeCode">Type of tax</param>
11751175
/// <param name="taxCategoryCode">Tax category</param>
11761176
/// <param name="taxPercent">Tax percentage</param>
@@ -1213,11 +1213,11 @@ internal void _AddTradeCharge(decimal? basisAmount, CurrencyCodes currency, deci
12131213
/// </summary>
12141214
/// <param name="basisAmount">Base amount (basis of allowance)</param>
12151215
/// <param name="currency">Curency of the allowance</param>
1216-
/// <param name="actualAmount">Actual allowance charge amount</param>
1217-
/// <param name="chargePercentage">Actual allowance charge percentage</param>
1216+
/// <param name="actualAmount">Actual allowance amount</param>
1217+
/// <param name="chargePercentage">Actual allowance percentage</param>
12181218
/// <param name="reason">Reason for the allowance</param>
1219-
/// <param name="taxTypeCode">VAT type code for document level allowance/ charge</param>
1220-
/// <param name="taxCategoryCode">VAT type code for document level allowance/ charge</param>
1219+
/// <param name="taxTypeCode">VAT type code for document level allowance</param>
1220+
/// <param name="taxCategoryCode">VAT type code for document level allowance</param>
12211221
/// <param name="taxPercent">VAT rate for the allowance</param>
12221222
/// <param name="reasonCode">Reason code for the allowance</param>
12231223
public void AddTradeAllowance(decimal? basisAmount, CurrencyCodes currency, decimal actualAmount, decimal? chargePercentage, string reason, TaxTypes taxTypeCode, TaxCategoryCodes taxCategoryCode, decimal taxPercent, AllowanceReasonCodes? reasonCode = null)
@@ -1227,7 +1227,7 @@ public void AddTradeAllowance(decimal? basisAmount, CurrencyCodes currency, deci
12271227

12281228

12291229
internal void _AddTradeAllowance(decimal? basisAmount, CurrencyCodes currency, decimal actualAmount, decimal? chargePercentage, string reason, TaxTypes? taxTypeCode, TaxCategoryCodes? taxCategoryCode, decimal taxPercent, AllowanceReasonCodes? reasonCode = null)
1230-
{
1230+
{
12311231
this.TradeAllowanceCharges.Add(new TradeAllowance()
12321232
{
12331233
Reason = reason,
@@ -1253,21 +1253,22 @@ internal void _AddTradeAllowance(decimal? basisAmount, CurrencyCodes currency, d
12531253
/// BG-21
12541254
/// Allowance represents a discount whereas charge represents a surcharge.
12551255
/// </summary>
1256-
/// <param name="basisAmount">Base amount (basis of allowance)</param>
1257-
/// <param name="currency">Curency of the allowance</param>
1258-
/// <param name="actualAmount">Actual allowance charge amount</param>
1259-
/// <param name="chargePercentage">Actual allowance charge percentage</param>
1260-
/// <param name="reason">Reason for the allowance</param>
1261-
/// <param name="taxTypeCode">VAT type code for document level allowance/ charge</param>
1262-
/// <param name="taxCategoryCode">VAT type code for document level allowance/ charge</param>
1263-
/// <param name="taxPercent">VAT rate for the allowance</param>
1264-
/// <param name="reasonCode">Reason code for the allowance</param>
1256+
/// <param name="basisAmount">Base amount (basis of charge)</param>
1257+
/// <param name="currency">Curency of the charge</param>
1258+
/// <param name="actualAmount">Actual charge amount</param>
1259+
/// <param name="chargePercentage">Actual charge percentage</param>
1260+
/// <param name="reason">Reason for the charge</param>
1261+
/// <param name="taxTypeCode">VAT type code for document level charge</param>
1262+
/// <param name="taxCategoryCode">VAT type code for document level charge</param>
1263+
/// <param name="taxPercent">VAT rate for the charge</param>
1264+
/// <param name="reasonCode">Reason code for the chargee/param>
1265+
[Obsolete("This function has a typo in the function name. Please use `AddTradeCharge` instead.", true)]
12651266
public void AddTradeeCharge(decimal? basisAmount, CurrencyCodes currency, decimal actualAmount, decimal? chargePercentage, string reason, TaxTypes taxTypeCode, TaxCategoryCodes taxCategoryCode, decimal taxPercent, ChargeReasonCodes? reasonCode = null)
12661267
{
12671268
_AddTradeCharge(basisAmount, currency, actualAmount, chargePercentage, reason, taxTypeCode, taxCategoryCode, taxPercent, reasonCode);
1268-
} // !AddTradeCharge()
1269-
1270-
1269+
} // !AddTradeCharge()
1270+
1271+
12711272
/// <summary>
12721273
/// Returns all existing trade allowances
12731274
///
@@ -1302,6 +1303,7 @@ public IList<TradeCharge> GetTradeCharges()
13021303
/// <param name="percentage">Optional percentage</param>
13031304
/// <param name="baseAmount">Optional base amount</param>
13041305
/// <param name="actualAmount">Optional actual amount</param>
1306+
/// <param name="maturityDate">Optional `DateTime?`</param>
13051307
public void AddTradePaymentTerms(string description, DateTime? dueDate = null,
13061308
PaymentTermsType? paymentTermsType = null, int? dueDays = null,
13071309
decimal? percentage = null, decimal? baseAmount = null, decimal? actualAmount = null, DateTime? maturityDate = null)
@@ -1517,6 +1519,7 @@ private static IInvoiceDescriptorWriter _SelectInvoiceDescriptorWriter(ZUGFeRDVe
15171519
/// <param name="version">ZUGFeRD version to use</param>
15181520
/// <param name="profile">ZUGFeRD profile to use</param>
15191521
/// <param name="format">Output format (CII or UBL)</param>
1522+
/// <param name="options">Optional `InvoiceFormatOptions`</param>
15201523
public void Save(Stream stream, ZUGFeRDVersion version = ZUGFeRDVersion.Version23, Profile profile = Profile.Basic, ZUGFeRDFormats format = ZUGFeRDFormats.CII, InvoiceFormatOptions options = null)
15211524
{
15221525
this.Profile = profile;
@@ -1532,6 +1535,7 @@ public void Save(Stream stream, ZUGFeRDVersion version = ZUGFeRDVersion.Version2
15321535
/// <param name="version">ZUGFeRD version to use</param>
15331536
/// <param name="profile">ZUGFeRD profile to use</param>
15341537
/// <param name="format">Output format (CII or UBL)</param>
1538+
/// <param name="options">Optional `InvoiceFormatOptions`</param>
15351539
public void Save(string filename, ZUGFeRDVersion version = ZUGFeRDVersion.Version23, Profile profile = Profile.Basic, ZUGFeRDFormats format = ZUGFeRDFormats.CII, InvoiceFormatOptions options = null)
15361540
{
15371541
this.Profile = profile;
@@ -1598,9 +1602,9 @@ public TradeLineItem AddTradeLineCommentItem(string lineID, string comment, stri
15981602
}
15991603

16001604
item.AssociatedDocument.Notes.Add(new Note(
1601-
content: comment
1602-
// no subjectcode
1603-
// no contentcode
1605+
content: comment
1606+
// no subjectcode
1607+
// no contentcode
16041608
));
16051609

16061610
this.TradeLineItems.Add(item);
@@ -1640,7 +1644,7 @@ public TradeLineItem AddTradeLineCommentItem(string lineID, string comment, stri
16401644
public TradeLineItem AddTradeLineItem(string name,
16411645
decimal netUnitPrice,
16421646
QuantityCodes unitCode,
1643-
string description = null,
1647+
string description = null,
16441648
decimal? unitQuantity = null,
16451649
decimal? grossUnitPrice = null,
16461650
decimal billedQuantity = 0,
@@ -1715,7 +1719,7 @@ public TradeLineItem AddTradeLineItem(string lineID,
17151719
string name,
17161720
decimal netUnitPrice,
17171721
QuantityCodes unitCode,
1718-
string description = null,
1722+
string description = null,
17191723
decimal? unitQuantity = null,
17201724
decimal? grossUnitPrice = null,
17211725
decimal billedQuantity = 0,
@@ -1777,7 +1781,7 @@ internal TradeLineItem _AddTradeLineItem(string lineID,
17771781
string buyerOrderLineID = "", string buyerOrderID = "", DateTime? buyerOrderDate = null,
17781782
DateTime? billingPeriodStart = null, DateTime? billingPeriodEnd = null
17791783
)
1780-
{
1784+
{
17811785
if (String.IsNullOrWhiteSpace(lineID))
17821786
{
17831787
throw new ArgumentException("LineID cannot be Null or Empty");
@@ -2045,9 +2049,9 @@ public List<BankAccount> GetDebitorFinancialAccounts()
20452049
public bool AnyDebitorFinancialAccount()
20462050
{
20472051
return this.DebitorBankAccounts?.Any() == true;
2048-
} // !AnyDebitorFinancialAccount()
2049-
2050-
2052+
} // !AnyDebitorFinancialAccount()
2053+
2054+
20512055
/// <summary>
20522056
/// Adds a receivable specified trade accounting account with ID and type code
20532057
///
@@ -2171,11 +2175,11 @@ public List<Note> GetNotes()
21712175

21722176
private string _getNextLineId()
21732177
{
2174-
int? highestLineId = this.GetTradeLineItems()?.Select(i =>
2178+
int? highestLineId = this.GetTradeLineItems()?.Select(i =>
21752179
{
21762180
if (Int32.TryParse(i.AssociatedDocument?.LineID, out int id) == true)
21772181
return id;
2178-
else return 0;
2182+
else return 0;
21792183
}
21802184
).DefaultIfEmpty(0).Max() ?? 0;
21812185
return highestLineId == null ? "1" : (highestLineId + 1).ToString();

0 commit comments

Comments
 (0)