Git Product home page Git Product logo

opentrans.net's Introduction

OpenTrans.net

.net library for reading and writing OpenTRANS orders and order responses.

The library has a sister library (https://github.com/stephanstapel/BMECat.net) which allows managing product catalogues.

Installation

You can get the library from nuget or from Visual Studio Package Manager under the name OpenTrans.net.

The URL of the package is here:

https://www.nuget.org/packages/OpenTrans.net/

Usage

Creating orders

For creating orders, you can simply create Order objects like this:

Order order = new Order()
            {
                Id = "MyOrderId",
                OrderDate = new DateTime(2020, 06, 21, 12, 20, 0),
                DesiredDeliveryDateStart = new DateTime(2020, 06, 21, 10, 0, 0),
                DesiredDeliveryDateEnd = new DateTime(2020, 06, 21, 10, 0, 0),
            };

with order id being the internal identifier for your order. You can then add parties to your order object where each party comes with specific roles like Buyer, Manufacturer, Supplier and its address and contact data:

order.Parties.Add(new Party(){
  Ids = new List<PartyId>() { new PartyId() { Id = "iln-no", Type = PartyIdTypes.ILN } },
  Roles = { PartyRoles.Buyer },
  Name = ....
});

make sure to add the appropriate party ids since the document needs to be used by both buyer and supplier and mapping of the ids needs to be possible on both ends.

Finally, you need to add the order items:

order.OrderItems.Add(new OrderItem()
            {
                LineItemId = "1",
                OrderUnit = QuantityCodes.C62,
                ProductId = new ProductId()
                {
                  SupplierPId = "...",
                  DescriptionShort = "..."
                },
                Quantity = 1.0m,
                LineAmount = 10,
                Remarks = new List<string>() { "Please deliver soon" }
            });

Again, make sure to use appropriate item ids and id reference to allow mapping on both ends of the comunication.

Finally, all you need is to save the order. You can write the order into a stream (open the stream before):

Stream s = ...
order.Save(s);

or into a file:

order.Save("order.xml");

Loading orders

Loading orders looks similar to saving orders. Again, you can use streams:

Stream s = ...
Order order = Order.Load(s);

and alternatively you can use file names to load orders:

Order order = Order.Load("order.xml");

Creating order responses

After the order is received by the supplier, the supplier answers the order by an order response, in order to acknowledge the order. Most information can be copied from the order object which is simple with this library since the exact same types (Party, OrderItem) are used for Order and OrderResponse.

OrderResponse response = new OrderResponse()
{
            Id = "Same id as in the order",
            OrderDate = DateTime(... same date as in the order ...),
            OrderChangeSequenceId = 0           
};

Then, add the parties (just like in the order):

response.Parties.Add(new Party(){
  ...
});

and finally, the order items:

response.OrderItems.Add(new OrderItem(){
  ...
});

Save the order response works just like saving orders:

Stream s = ...
response.Save(s);

or into a file:

response.Save("order-response.xml");

Loading order responses

As the buyer, you will receive the order response from the supplier. In order to read it, you just use:

Stream s = ...
OrderResponse response = OrderResponse.Load(s);

and alternatively you can use file names to load the order response:

OrderResponse response = OrderResponse.Load("order-response.xml");

The demo application contains some simple examples. Please see here for more details:

https://github.com/stephanstapel/OpenTrans.net/blob/master/OpenTrans.net-Test/Application.cs

Dispatch Notification, Receipt Acknowledgement

The other message types will be implemented when someone should require it.

More information

opentrans.net's People

Contributors

stephanstapel avatar jmu-horaios avatar patricksproll avatar guiohm avatar mitchvdl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.