Skip to content

Commit

Permalink
Add invoice item code
Browse files Browse the repository at this point in the history
  • Loading branch information
dalrankov committed Mar 10, 2024
1 parent 41ff800 commit 53403cc
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 20 deletions.
1 change: 1 addition & 0 deletions InvoiceService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public async Task<CreateInvoiceResult> CreateInvoiceAsync(
var resultItem = new Item
{
Code = item.Code,
Name = item.Name,
Unit = item.Unit,
UnitPrice = item.UnitPrice.RoundTo(4),
Expand Down
1 change: 1 addition & 0 deletions Models/InvoiceItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public sealed class InvoiceItem
{
public string? Code { get; set; }
public string Name { get; set; }
public string Unit { get; set; }
public decimal UnitPrice { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Models/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace OpenMicroFiscal.Models;
[XmlType("I")]
public sealed class Item
{
[XmlAttribute("C")] public string? Code { get; set; }
[XmlAttribute("N")] public string Name { get; set; }
[XmlAttribute("U")] public string Unit { get; set; }
[XmlAttribute("UPB")] public decimal UnitPrice { get; set; }
Expand Down
78 changes: 58 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var invoiceService = new InvoiceService(

----

### Upotreba
### Izdavanje računa

````csharp
var request = new CreateInvoiceRequest
Expand All @@ -133,56 +133,94 @@ var request = new CreateInvoiceRequest
{
new InvoiceItem
{
Code = "#guma",
Name = "Guma za automobil",
Unit = "komad",
UnitPrice = 75.00M,
Quantity = 4
},
new InvoiceItem
{
Code = "#burger",
Name = "Burger",
Unit = "komad",
UnitPrice = 5.00M,
Quantity = 2,
Vat = new InvoiceItem.VatDetails
Vat = new InvoiceItem.VatSpec
{
Rate = 7.00M
}
},
...
}
},
Note = "Molimo vas da račun platite u navedenom roku. Hvala."
};
````

### Storniranje računa

````csharp
var request = new CreateInvoiceRequest
{
Type = InvoiceType.Corrective,
OrderNumber = 16,
PaymentMethod = PaymentMethodType.BankTransfer,
PaymentDeadline = new DateTime(2022, 02, 25),
Buyer = new Buyer
{
IdType = TaxIdType.Tin,
IdNumber = "12345678",
Name = "TOP BUYER DOO",
Address = "4 JULA BB",
City = "PODGORICA",
Country = "MNE"
},
Items = new[]
{
new InvoiceItem
{
Name = "Inostrana usluga",
Code = "#guma",
Name = "Guma za automobil",
Unit = "komad",
UnitPrice = 5.00M,
Quantity = 2,
Vat = new InvoiceItem.VatDetails
{
Rate = 0.00M,
ExemptionReason = "VAT_CL17" // Razlog izbjegavanja PDV-a
}
UnitPrice = 75.00M,
Quantity = -4
},
...
new InvoiceItem
{
Name = "Pogrešna stavka",
Code = "#burger",
Name = "Burger",
Unit = "komad",
UnitPrice = 5.00M,
Quantity = -2 // U slučaju storniranja
Quantity = -2,
Vat = new InvoiceItem.VatSpec
{
Rate = 7.00M
}
}
},
Note = "Molimo vas da račun platite u navedenom roku. Hvala.",
// U slučaju storniranja računa neophodno je poslati identifikator originalnog računa
//Type = InvoiceType.Corrective,
OriginalInvoice = new CreateInvoiceRequest.OriginalInvoiceDetails
Note = "Kupac je odustao od kupovine.",
Original = new CreateInvoiceRequest.OriginalInvoice
{
Id = "0AE36859887129D6363C40F662FF9AE4",
Id = "0AE36859887129D6363C40F662FF9AE4", // IIC
IssuedAt = DateTime.Parse("2024-03-09T17:43:33Z")
}
};
````

### Izuzeće od plaćanja PDV-a stavke

````csharp
Vat = new InvoiceItem.VatSpec
{
ExemptionReason = "VAT_CL17" // Razlog izuzeća
}
````

### Rezultat

````csharp
var result = await invoiceService.CreateInvoiceAsync(request);

Console.WriteLine($"XML: {result.EnvelopedRequestXmlText}");
Console.WriteLine($"Invoice Number: {result.InvoiceNumber}");
Console.WriteLine($"Total Price: {result.TotalPrice} EUR");
Console.WriteLine($"IIC: {result.Iic}");
Expand Down

0 comments on commit 53403cc

Please sign in to comment.