Encodes and decodes GTIN numbers (EAN-8 and EAN-13) with support for products having variable weight and price.
Each member country of GS1 have their own specification for products with variable weight and price, magazines and coupons. This is handled by this library by defining encoding rules in "locales".
Currently only the Sweden
locale is implemented.
Start by creating an entity:
Kekos.Gs1.Entity.WeightProduct entity = new Kekos.Gs1.Entity.WeightProduct(sku, weight);
Kekos.Gs1.Entity.PriceProduct entity = new Kekos.Gs1.Entity.PriceProduct(sku, price);
Kekos.Gs1.Entity.Publication entity = new Kekos.Gs1.Entity.Publication(sku, price);
Kekos.Gs1.Entity.Coupon entity = new Kekos.Gs1.Entity.Coupon(id, discount);
Use GtinFactory
class by specifying which locale to use:
Kekos.Gs1.Gtin.Gtin code = Kekos.Gs1.GtinFactory.Get("Sweden", entity);
Console.WriteLine(code);
Create a GTIN entity:
Kekos.Gs1.Gtin.Gtin13 gtin = new Kekos.Gs1.Gtin.Gtin13(code);
Kekos.Gs1.Gtin.Gtin8 gtin = new Kekos.Gs1.Gtin.Gtin8(code);
Use EntityFactory
class by specifying which locale to use:
Kekos.Gs1.Entity.AbstractEntity entity = Kekos.Gs1.EntityFactory.Get("Sweden", gtin);
if (entity is Kekos.Gs1.Entity.WeightProduct)
{
Console.WriteLine("Weight: " + entity.Weight);
}
Kekos.Gs1.Entity.Product product = new Kekos.Gs1.Entity.Product(string sku, string company_prefix);
// Properties
product.Sku;
product.CompanyPrefix;
Kekos.Gs1.Entity.WeightProduct product = new Kekos.Gs1.Entity.WeightProduct(string sku, float weight);
// Properties
product.Sku;
product.Weight;
Kekos.Gs1.Entity.PriceProduct product = new Kekos.Gs1.Entity.PriceProduct(string sku, float price);
// Properties
product.Sku;
product.Price;
Kekos.Gs1.Entity.Coupon coupon = new Kekos.Gs1.Entity.Coupon(string id, float value);
// Properties
coupon.Id;
coupon.Value;
Kekos.Gs1.Entity.Publication publication = new Kekos.Gs1.Entity.Publication(string sku, float price);
// Properties
publication.Sku;
publication.Price;
When setting the code you don't have to specify the checksum (digit 8 or 13).
The Gtin
classes will add the checksum automatically if needed.
Kekos.Gs1.Gtin.Gtin8 gtin = new Kekos.Gs1.Gtin.Gtin8(string code);
// ...or
Kekos.Gs1.Gtin.Gtin13 gtin = new Kekos.Gs1.Gtin.Gtin13(string code);
// Properties
gtin.Code;
// Methods
gtin.IsValid(); // returns int
gtin.GetChecksum(); // returns bool
gtin.ToString();
Report bugs in GitHub issues or feel free to make a pull request :-)
MIT