From fd0a81d074d9f00a17126df115168abcf90469e2 Mon Sep 17 00:00:00 2001 From: viehlieb Date: Thu, 19 Jan 2023 17:33:00 +0100 Subject: [PATCH] initial commit --- .gitignore | 2 + CHANGELOG.md | 3 + Gemfile | 5 + Gemfile.lock | 33 + LICENSE | 644 ++++++++++ README.md | 12 + foodsoft_article_import.gemspec | 29 + lib/foodsoft_article_import.rb | 81 ++ lib/foodsoft_article_import/bioromeo.rb | 196 +++ lib/foodsoft_article_import/bnn.rb | 98 ++ lib/foodsoft_article_import/bnn_codes.yml | 1119 +++++++++++++++++ lib/foodsoft_article_import/dnb_codes.yml | 129 ++ lib/foodsoft_article_import/foodsoft.rb | 59 + lib/foodsoft_article_import/midgard_codes.yml | 294 +++++ lib/foodsoft_article_import/odin.rb | 89 ++ lib/foodsoft_article_import/utf8_encoder.rb | 9 + lib/foodsoft_article_import/version.rb | 3 + spec/files/bioromeo/bioromeo_flawless.csv | 12 + spec/files/bnn/bnn_bad_encoding.BNN | 3 + spec/files/bnn/bnn_flawless.BNN | 3 + spec/files/bnn/bnn_flawless_category.BNN | 3 + spec/files/bnn/bnn_flawless_special.BNN | 3 + spec/files/bnn/bnn_missing_entries.BNN | 3 + spec/files/bnn/bnn_missing_order_number.BNN | 3 + spec/files/custom_codes.yml | 8 + spec/files/foodsoft/foodsoft_flawless.csv | 3 + .../foodsoft_generate_order_number.csv | 3 + .../foodsoft/foodsoft_missing_entries.csv | 2 + spec/files/odin/odin_flawless.xml | 75 ++ .../odin/odin_flawless_custom_category.xml | 77 ++ spec/files/odin/odin_missing_entries.xml | 75 ++ spec/files/odin/odin_missing_order_number.xml | 75 ++ .../foodsoft_article_import_bioromeo_spec.rb | 24 + .../bnn/foodsoft_article_import_bnn_spec.rb | 71 ++ .../foodsoft_article_import_foodsoft_spec.rb | 57 + .../odin/foodsoft_article_import_odin_spec.rb | 67 + spec/spec_helper.rb | 100 ++ 37 files changed, 3472 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 LICENSE create mode 100644 README.md create mode 100644 foodsoft_article_import.gemspec create mode 100644 lib/foodsoft_article_import.rb create mode 100644 lib/foodsoft_article_import/bioromeo.rb create mode 100644 lib/foodsoft_article_import/bnn.rb create mode 100644 lib/foodsoft_article_import/bnn_codes.yml create mode 100644 lib/foodsoft_article_import/dnb_codes.yml create mode 100644 lib/foodsoft_article_import/foodsoft.rb create mode 100644 lib/foodsoft_article_import/midgard_codes.yml create mode 100644 lib/foodsoft_article_import/odin.rb create mode 100644 lib/foodsoft_article_import/utf8_encoder.rb create mode 100644 lib/foodsoft_article_import/version.rb create mode 100644 spec/files/bioromeo/bioromeo_flawless.csv create mode 100644 spec/files/bnn/bnn_bad_encoding.BNN create mode 100644 spec/files/bnn/bnn_flawless.BNN create mode 100644 spec/files/bnn/bnn_flawless_category.BNN create mode 100644 spec/files/bnn/bnn_flawless_special.BNN create mode 100644 spec/files/bnn/bnn_missing_entries.BNN create mode 100644 spec/files/bnn/bnn_missing_order_number.BNN create mode 100644 spec/files/custom_codes.yml create mode 100644 spec/files/foodsoft/foodsoft_flawless.csv create mode 100644 spec/files/foodsoft/foodsoft_generate_order_number.csv create mode 100644 spec/files/foodsoft/foodsoft_missing_entries.csv create mode 100644 spec/files/odin/odin_flawless.xml create mode 100644 spec/files/odin/odin_flawless_custom_category.xml create mode 100644 spec/files/odin/odin_missing_entries.xml create mode 100644 spec/files/odin/odin_missing_order_number.xml create mode 100644 spec/lib/bioromeo/foodsoft_article_import_bioromeo_spec.rb create mode 100644 spec/lib/bnn/foodsoft_article_import_bnn_spec.rb create mode 100644 spec/lib/foodsoft/foodsoft_article_import_foodsoft_spec.rb create mode 100644 spec/lib/odin/foodsoft_article_import_odin_spec.rb create mode 100644 spec/spec_helper.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..369ba8e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.gem +Gemfile.lock \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..00b5251 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog +## 1.0.0 (01-Oct-20) +* Initial release diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..ab62740 --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +# foodsoft_article_import/Gemfile + +source 'http://rubygems.org' + +gemspec \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..fdfc691 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,33 @@ +PATH + remote: . + specs: + foodsoft_article_import (1.0.0) + roo (~> 2.9.0) + +GEM + remote: http://rubygems.org/ + specs: + docile (1.4.0) + nokogiri (1.14.0-x86_64-linux) + racc (~> 1.4) + racc (1.6.2) + roo (2.9.0) + nokogiri (~> 1) + rubyzip (>= 1.3.0, < 3.0.0) + rubyzip (2.3.2) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + foodsoft_article_import! + simplecov + +BUNDLED WITH + 2.4.2 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e7023b1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,644 @@ +Copyright (C) 2022 Viehlieb + + +Comment: Most of the source code was originally written for https://github.com/foodcoops/sharedlists under the GNU License and therefore special credit is attributed to the contributors of the sharedlists application: + +Authors: Kidhab: https://github.com/kidhab, +Benjamin Meichsner: https://github.com/benni-as, Wvengen: https://github.com/wvengen, Robwa: https://github.com/robwa, 1resu: https://github.com/1resu, JuliusR: https://github.com/JuliusR + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + + + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e68041 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# FoodsoftArticleImport +This gem provides FoodsoftArticleImport integration for Ruby on Rails and allows to parse avariety of files containing article information. These article information are standardized or customly declared. Possible File Ending are: .bnn, .BNN, .csv, .CSV . It relies on [roo](https://github.com/roo-rb/roo) to read and parse the data + + +## Getting started +TODO: add bnn codes, explain how to add bnn codes +TODO: review GNU License + +For correct import of bnn files, please ensure the correct language setting. Your foodsoft account has to be settings set to german if you want to import articles from file. +To set this is imcrucial for guaranteeing the correct format of article prices. +### Requirements +This gem requires Ruby 2.7 \ No newline at end of file diff --git a/foodsoft_article_import.gemspec b/foodsoft_article_import.gemspec new file mode 100644 index 0000000..b3a02f9 --- /dev/null +++ b/foodsoft_article_import.gemspec @@ -0,0 +1,29 @@ +require File.expand_path('lib/foodsoft_article_import/version', __dir__) +Gem::Specification.new do |spec| + spec.name = 'foodsoft_article_import' + spec.version = FoodsoftArticleImport::VERSION + + spec.authors = ['Philipp Feuerbach, Wvengen'] + spec.email = ['pf@pragma-shift.net'] + + spec.summary = 'Import Files for Foodcoops for Ruby on Rails' + spec.description = 'This gem allows to import files containing article information to foodsoft. It was created to avoid code redundancy and is based on the sharedlist application https://github.com/foodcoops/sharedlists.' + spec.homepage = 'https://gitea.com/viehlieb/foodsoft-article_import' + + spec.license = 'MIT' + spec.platform = Gem::Platform::RUBY + + spec.required_ruby_version = '>= 2.7.0' + + spec.files = Dir['README.md', 'LICENSE', + 'CHANGELOG.md', 'lib/**/*.rb', + 'lib/foodsoft_article_import/bnn.rb', + 'lib/foodsoft_article_import.rb', + 'lib/**/*.rake', + 'foodsoft_article_import.gemspec', '.github/*.md', + 'Gemfile', 'Rakefile'] + spec.extra_rdoc_files = ['README.md'] + + spec.add_dependency 'roo', '~> 2.9.0' + spec.add_development_dependency 'simplecov' +end diff --git a/lib/foodsoft_article_import.rb b/lib/foodsoft_article_import.rb new file mode 100644 index 0000000..a2fa255 --- /dev/null +++ b/lib/foodsoft_article_import.rb @@ -0,0 +1,81 @@ +require 'digest/sha1' +require 'tempfile' +require 'csv' +require 'yaml' +require 'active_support/core_ext/hash/keys' +require_relative 'foodsoft_article_import/bioromeo' +require_relative 'foodsoft_article_import/bnn' +require_relative 'foodsoft_article_import/utf8_encoder' +require_relative 'foodsoft_article_import/odin' +require_relative 'foodsoft_article_import/foodsoft' +module FoodsoftArticleImport + + class ConversionFailedException < Exception; end + + # return list of known file formats + # each file_format module has + # #name return a human-readable file format name + # #outlist_unlisted if returns true, unlisted articles are outlisted + # #detect return a likelyhood (0-1) of being able to process + # #parse parse the data + # + def self.file_formats + @@file_formats ||= { + 'bnn' => FoodsoftArticleImport::Bnn, + 'foodsoft' => FoodsoftArticleImport::Foodsoft, + 'dnb_xml' => FoodsoftArticleImport::Odin, + 'odin' => FoodsoftArticleImport::Odin, + 'bioromeo' => FoodsoftArticleImport::Bioromeo, + }.freeze + end + + # Parse file by type (one of {.file_formats}) + # + # @param file [File, Tempfile] + # @option opts [String] type file format (required) (see {.file_formats}) + # @return [File, Roo::Spreadsheet] file with encoding set if needed + def self.parse(file, custom_file_path: nil, type: nil, **opts, &blk) + custom_file_path ||= nil + type ||= 'bnn' + + parser = file_formats[type] + if block_given? + parser.parse(file, custom_file_path: custom_file_path, **opts, &blk) + else + data = [] + parser.parse(file, custom_file_path: custom_file_path, **opts) { |a| data << a } + data + end + end + + + # Helper method to generate an article number for suppliers that do not have one + def self.generate_number(article) + # something unique, but not too unique + s = "#{article[:name]}-#{article[:unit_quantity]}x#{article[:unit]}" + s = s.downcase.gsub(/[^a-z0-9.]/,'') + # prefix abbreviated sha1-hash with colon to indicate that it's a generated number + article[:order_number] = ':' + Digest::SHA1.hexdigest(s)[-7..-1] + article + end + + # Helper method for opening a spreadsheet file + # + # @param file [File] file to open + # @param filename [String, NilClass] optional filename for guessing the file format + # @param encoding [String, NilClass] optional CSV encoding + # @param col_sep [String, NilClass] optional column separator + # @return [Roo::Spreadsheet] + def self.open_spreadsheet(file, filename: nil, encoding: nil, col_sep: nil, liberal_parsing: nil) + opts = {csv_options: {}} + opts[:csv_options][:encoding] = encoding if encoding + opts[:csv_options][:col_sep] = col_sep if col_sep + opts[:csv_options][:liberal_parsing] = true if liberal_parsing + opts[:extension] = File.extname(filename) if filename + begin + Roo::Spreadsheet.open(file, **opts) + rescue => e + raise "Failed to parse foodsoft file. make sure file format is correct: #{e.message}" + end + end +end \ No newline at end of file diff --git a/lib/foodsoft_article_import/bioromeo.rb b/lib/foodsoft_article_import/bioromeo.rb new file mode 100644 index 0000000..be076b4 --- /dev/null +++ b/lib/foodsoft_article_import/bioromeo.rb @@ -0,0 +1,196 @@ +# Module for import of BioRomeo products from their Excel sheet, from Aug 2014 onwards + +require 'roo' +require 'roo-xls' + +module FoodsoftArticleImport + class Bioromeo + + NAME = "BioRomeo (XLSX, XLS, CSV)" + OUTLIST = true + OPTIONS = { + encoding: "UTF-8", + col_sep: ";" + }.freeze + + RE_UNITS = /(kg|gr|gram|pond|st|stuks?|set|bos|bossen|bosjes?|bak|bakjes?|liter|ltr|[lL]\.|ml|bol|krop)(\s*\.)?/i + RES_PARSE_UNIT_LIST = [ + /\b((per|a)\s*)?([0-9,.]+\s*x\s*[0-9,.]+\s*#{RE_UNITS})/i, # 1x5 kg + /\b((per|a)\s*)?([0-9,.]+\s*#{RE_UNITS}\s+x\s*[0-9,.]+)/i, # 1kg x 5 + /\b((per|a)\s*)?(([0-9,.]+\s*,\s+)*[0-9,.]+\s+of\s+[0-9,.]+\s*#{RE_UNITS})/i, # 1, 2 of 5 kg + /\b((per|a)\s*)?([0-9,.]+\s*#{RE_UNITS})/i, # 1kg + /\b((per|a)\s*)?(#{RE_UNITS})/i # kg + ] + # first parse with dash separator at the end, fallback to less specific + RES_PARSE_UNIT = RES_PARSE_UNIT_LIST.map {|r| /-\s*#{r}\s*$/} + + RES_PARSE_UNIT_LIST.map {|r| /-\s+#{r}/} + + RES_PARSE_UNIT_LIST.map {|r| /#{r}\s*$/} + + RES_PARSE_UNIT_LIST.map {|r| /-#{r}/} + + def self.parse(file, custom_file_path: nil, **opts) + custom_file_path ||= nil + opts = OPTIONS.merge(opts) + opts[:liberal_parsing]=true + opts[:col_sep]="," + ss = FoodsoftArticleImport.open_spreadsheet(file, **opts) + header_row = true + sheet = ss.sheet(0).parse(clean: true, + order_number: /Artnr./, + name: /Product/, + skal: /Skal$/, + demeter: /Demeter$/, + unit_price: /prijs\b.*\beenh/i, + pack_price: /prijs\b.*\bcolli/i, + comment: /opm(erking)?/i, + ) + + linenum = 0 + category = nil + + sheet.each do |row| + linenum += 1 + row[:name].to_s.strip.empty? and next + # (sub)categories are in first two content cells - assume if there's a price it's a product + if row[:order_number].to_s.strip.empty? && row[:unit_price].to_s.strip.empty? + category = row[:name] + yield nil, nil, linenum + next + end + # skip products without a number + if row[:order_number].to_s.strip.empty? + yield nil, nil, linenum + next + end + # extract name and unit + errors = [] + notes = [] + unit_price = row[:unit_price].gsub("€","").to_s.strip.to_f + pack_price = row[:pack_price].gsub("€","").to_s.strip.to_f + number = row[:order_number] + name = row[:name] + unit = nil + manufacturer = nil + prod_category = nil + RES_PARSE_UNIT.each do |re| + m=name.match(re) + unless m + yield nil, nil, linenum + next + end + unit = self.normalize_unit(m[3]) + name = name.sub(re, '').sub(/\(\s*\)\s*$/,'').sub(/\s+/, ' ').sub(/\.\s*$/, '').strip + break + end + unit ||= '1 st' if name.match(/\bsla\b/i) + unit ||= '1 bos' if name.match(/\bradijs\b/i) + unit ||= '1 bosje' if category.match(/\bkruid/i) + if unit.nil? + unit = '?' + errors << "Cannot find unit in name '#{name}'" + end + # handle multiple units in one line + if unit.match(/\b(,\s+|of)\b/) + # TODO create multiple articles instead of taking first one + end + # sometimes category is also used to indicate manufacturer + m=category.match(/((eko\s*)?boerderij.*?)\s*$/i) and manufacturer = m[1] + # Ad-hoc fix for package of eggs: always take pack price + if name.match(/^eieren/i) + unit_price = pack_price + prod_category = 'Eieren' + end + prod_category = 'Kaas' if name.match(/^kaas/i) + # figure out unit_quantity + if unit.match(/x/) + unit_quantity, unit = unit.split(/\s*x\s*/i, 2) + unit,unit_quantity = unit_quantity,unit if unit_quantity.match(/[a-z]/i) + elsif (unit_price-pack_price).abs < 1e-3 + unit_quantity = 1 + elsif m=unit.match(/^(.*)\b\s*(st|bos|bossen|bosjes?)\.?\s*$/i) + unit_quantity, unit = m[1..2] + unit_quantity.blank? and unit_quantity = 1 + else + unit_quantity = 1 + end + # there may be a more informative unit in the line + if unit=='st' && !name.match(/kool/i) + RES_PARSE_UNIT.each do |re| + m=name.match(re) or next + unit = self.normalize_unit(m[3]) + name = name.sub(re, '').strip + end + end + # note from various fields + notes.append("Skal #{row[:skal]}") unless row[:skal].to_s.strip.empty? + notes.append(row[:demeter]) unless row[:skal].to_s.strip.empty? + notes.append("Demeter #{row[:demeter]}") unless row[:skal].to_s.strip.empty? && row[:demeter].is_a?(Fixnum) + notes.append "(#{row[:comment]})" unless row[:comment].to_s.strip.empty? + name.sub!(/(,\.?\s*)?\bDemeter\b/i, '') and notes.prepend("Demeter") + name.sub!(/(,\.?\s*)?\bBIO\b/i, '') and notes.prepend "BIO" + # unit check + errors << check_price(unit, unit_quantity, unit_price, pack_price) + # create new article + name.gsub!(/\s+/, ' ') + article = {:order_number => number, + :name => name.strip, + :note => notes.count > 0 && notes.map(&:strip).join("; "), + :manufacturer => manufacturer, + :origin => 'Noordoostpolder, NL', + :unit => unit, + :price => pack_price.to_f/unit_quantity.to_f, + :unit_quantity => unit_quantity, + :tax => 6, + :deposit => 0, + :article_category => prod_category || category + } + errors.compact! + if errors.count > 0 + yield article, errors.join("\n"), linenum + else + # outlisting not used by supplier + yield article, nil, linenum + end + end + end + + protected + + def self.check_price(unit, unit_quantity, unit_price, pack_price) + if (unit_price-pack_price).abs < 1e-3 + return if unit_quantity == 1 + return "price per unit #{unit_price} is pack price, but unit quantity #{unit_quantity} is not one" + end + + if m = unit.match(/^(.*)(#{RE_UNITS})\s*$/) + amount, what = m[1..2] + else + return "could not parse unit: #{unit}" + end + + # perhaps unit price is kg-price + kgprice = if what =~ /^kg/i + pack_price.to_f / amount.to_f + elsif what =~ /^gr/ + pack_price.to_f / amount.to_f * 1000 + end + unless kgprice.to_s.strip.empty? && (kgprice - unit_price.to_f).abs < 1e-2 + return + end + + unit_price_computed = pack_price.to_f/unit_quantity.to_i + if (unit_price_computed - unit_price.to_f).abs > 1e-2 + "price per unit given #{unit_price.round(3)} does not match computed " + + "#{pack_price.round(3)}/#{unit_quantity}=#{unit_price_computed.round(3)}" + + (kgprice ? " (nor is it a kg-price #{kgprice.round(3)})" : '') + end + end + + def self.normalize_unit(unit) + unit = unit.sub(/1\s*x\s*/, '') + unit = unit.sub(/,([0-9])/, '.\1').gsub(/^per\s*/,'').sub(/^1\s*([^0-9.])/,'\1').sub(/^a\b\s*/,'') + unit = unit.sub(/(bossen|bosjes?)/, 'bos').sub(/(liter|l\.|L\.)/,'ltr').sub(/stuks?/, 'st').sub('gram','gr') + unit = unit.sub(/\s*\.\s*$/,'').sub(/\s+/, ' ').strip + end + + end +end \ No newline at end of file diff --git a/lib/foodsoft_article_import/bnn.rb b/lib/foodsoft_article_import/bnn.rb new file mode 100644 index 0000000..c38e1cd --- /dev/null +++ b/lib/foodsoft_article_import/bnn.rb @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- + +# Module for translation and parsing of BNN-files (www.n-bnn.de) +# +module FoodsoftArticleImport + module Bnn + + private + @@codes = Hash.new + @@midgard = Hash.new + # Loads the codes_file config/bnn_codes.yml into the class variable @@codes + def self.load_codes(custom_file_path=nil) + @gem_lib = File.expand_path "../../", __FILE__ + dir = File.join @gem_lib, 'foodsoft_article_import' + begin + @@codes = YAML::load(File.open(File.join(dir,"bnn_codes.yml"))).symbolize_keys + if(custom_file_path) + custom_codes = YAML::load(File.open(custom_file_path)).symbolize_keys + custom_codes.keys.each do |key| + if @@codes.keys.include?(key) + custom_codes[key] =custom_codes[key].merge @@codes[key] + end + @@codes = @@codes.merge custom_codes + end + end + @@midgard = YAML::load(File.open(File.join(dir,"midgard_codes.yml"))).symbolize_keys + rescue => e + raise "Failed to load bnn_codes: #{dir}/{bnn,midgard}_codes.yml: #{e.message}" + end + end + + public + $missing_bnn_codes = Array.new + + # translates codes from BNN to foodsoft-code + def self.translate(key, value) + if @@codes[key][value] + return @@codes[key][value] + elsif @@midgard[key] + return @@midgard[key][value] + elsif value != nil + $missing_bnn_codes << value + return nil + end + end + + NAME = "BNN (CSV)" + OUTLIST = false + OPTIONS = { + encoding: "IBM850", + col_sep: ";" + }.freeze + + # parses a bnn-file + def self.parse(file, custom_file_path: nil, **opts) + custom_file_path ||= nil + encoding = opts[:encoding] || OPTIONS[:encoding] + col_sep = opts[:col_sep] || OPTIONS[:col_sep] + self.load_codes(custom_file_path) + CSV.foreach(file, {col_sep: col_sep, encoding: encoding, headers: true}).with_index(1) do |row, i| + # check if the line is empty + unless row[0] == "" || row[0].nil? + article = { + :name => UTF8Encoder.clean(row[6]), + :order_number => row[0], + :note => UTF8Encoder.clean(row[7]), + :manufacturer => self.translate(:manufacturer, row[10]), + :origin => row[12], + :article_category => self.translate(:category, row[16]), + :unit => row[23], + :price => row[37], + :tax => self.translate(:tax, row[33]), + :unit_quantity => row[22] + } + # TODO: Complete deposit list.... + article.merge!(:deposit => self.translate(:deposit, row[26])) if self.translate(:deposit, row[26]) + + # get scale prices if exists + # article.merge!(:scale_quantity => row[40], :scale_price => row[41]) unless row[40].nil? or row[41].nil? + + if row[62] != nil + # consider special prices + article[:note] = "Sonderpreis: #{article[:price]} von #{row[62]} bis #{row[63]}" + yield article, :special, i + + # Check now for article status, we only consider outlisted articles right now + # N=neu, A=Änderung, X=ausgelistet, R=Restbestand, + # V=vorübergehend ausgelistet, W=wiedergelistet + elsif row[1] == "X" || row[1] == "V" + yield article, :outlisted, i + else + yield article, nil, i + end + end + end + end + end +end diff --git a/lib/foodsoft_article_import/bnn_codes.yml b/lib/foodsoft_article_import/bnn_codes.yml new file mode 100644 index 0000000..dfb226e --- /dev/null +++ b/lib/foodsoft_article_import/bnn_codes.yml @@ -0,0 +1,1119 @@ +# BNN Codes +tax: + "1": 7.0 + "2": 19.0 + "3": 10.7 + +deposit: + "930190": 0.08 + "930200": 0.08 + "930205": 0.08 + "930210": 0.08 + "930230": 0.08 + "930260": 0.08 + "930270": 0.08 + "930280": 0.08 + "998010": 0.08 + "998016": 0.08 + "998350": 0.08 + "998360": 0.08 + "998427": 0.08 + "998440": 0.08 + "998460": 0.08 + "998470": 0.08 + "998500": 0.08 + "998510": 0.08 + "998700": 0.08 + "998710": 0.08 + "998725": 0.08 + "998730": 0.08 + "998750": 0.08 + "998760": 0.08 + "998790": 0.08 + "998800": 0.08 + "998810": 0.08 + "998840": 0.08 + "998860": 0.08 + "998880": 0.08 + "998887": 0.08 + "900010": 0.15 + "900020": 0.15 + "900030": 0.15 + "900040": 0.15 + "900050": 0.15 + "900070": 0.15 + "900075": 0.15 + "900085": 0.15 + "900089": 0.15 + "900850": 0.15 + "900860": 0.15 + "900870": 0.15 + "900890": 0.15 + "930010": 0.15 + "930020": 0.15 + "930030": 0.15 + "930035": 0.15 + "930050": 0.15 + "930090": 0.15 + "930110": 0.15 + "930120": 0.15 + "930130": 0.15 + "930320": 0.15 + "930325": 0.15 + "955230": 0.15 + "998000": 0.15 + "999983": 0.15 + "999985": 0.15 + "998040": 0.15 + "998060": 0.15 + "998070": 0.15 + "998080": 0.15 + "998100": 0.15 + "998110": 0.15 + "998300": 0.15 + "998310": 0.15 + "998320": 0.15 + "998330": 0.15 + "998340": 0.15 + "998352": 0.15 + "998370": 0.15 + "998380": 0.15 + "998390": 0.15 + "998405": 0.15 + "998417": 0.15 + "998450": 0.15 + "998480": 0.15 + "998520": 0.15 + "999200": 0.15 + "900892": 0.25 + "930290": 0.25 + "999980": 0.25 + "998020": 0.25 + "998030": 0.25 + "998090": 0.25 + "998366": 0.25 + "998420": 0.25 + "998437": 0.25 + "998740": 0.25 + "998770": 0.25 + "930450": 0.50 + "930440": 1.00 + "930460": 1.00 + "930256": 1.50 + "930257": 1.50 + "930250": 30.00 + "930252": 30.00 + "998720": 30.00 + "998830": 30.00 + "998870": 30.00 + +manufacturer: + bro: Brodowin + AAB: Azienda Agricola Bettili + ABD: Agro Bio Drom, Frankreich + ABM: Maintal GmbH + ABT: Albtal Naturkost GmbH + ACF: Arcada France S.A. + ACL: Achleitner Biohof GmbH + ADC: Coste Vincent & Francoise + ADM: Antersdorfer Mühle GmbH + ADR: Faan Zuidhorn + AFH: Doris Wallbaum & Co + agm: Angermeier Weinimport + AGR: Agrano GmbH & Co KG + AGX: Agrexco Ltd. + akr: Biohof Barnsen + ALB: Alber Pilzkonservenfabrik + alf: Bioland-Hof Altfeld + ALL: Allgäuland Käsereien GmbH + ALM: Allmendinger Metzgerei + ALN: AL Naturkost Handels GmbH + ALO: Allos-Walter Lang GmbH + ALR: Allerleirauh GmbH + ALS: Alsan Werk + ALT: Alberts-Tofuhaus + ALV: Alva + AMA: Amazonas Naturpr.Handels GmbH + AMS: Santa Fe Europe GmbH + AMW: AlmaWin GmbH + AND: Andechser Molkerei GmbH + ANF: Allgäu Natur GmbH + ANG: Angelmaier OHG + ANI: Anis de l' Abbaye + ANJ: Atelier Niedernjesa + ANL: Anderlbauer Frasdorf + ANN: AN, Ne Bienenwachskerzen + ANT: Antico Forno a Legna + APR: Apeiron + ARC: Arche Naturprodukte GmbH + ARG: ARGANDÓR + ARI: Aries Umweltprodukte + ARO: Aromabalance, Silvia Plum + art: Artesia + asc: Asch + ASS: Assindia - GmbH + ATX: Ute Arnswald + AUR: Auro Pflanzenchemie AG + BAB: Baba-Laffa, W. Maguid + BAC: Hof Backensholz + BAE: Biofarm A.E. + bai: Bioland-Hof Gerhard Baiker + bäj: Bärthele, Joachim + BAK: Bauckhof demeter Naturkost + BAL: Ballybrado, Cahir Co. + BAS: Bastiaansen Bio-Kaas B.V. + BAU: BioBauernmarkt Chiemgau eG + bba: Bäckerei Bahde + bbi: Bäckerei Bihn + BBN: Bio Bavaria Naturkost + BBO: Flemming Naturkost + BBR: Mineralbrunnen AG + BBW: Bioland Ba-Wü GmbH + bdh: Butendiek-Hof + bdp: Biodynaminska Produkter + BDW: Bio-Dienst Weiss GmbH + BEL: Bellenature + BER: Bergquell GmbH & Co.KG + BEU: Beutelsbacher GmbH + BFA: Biofarms s.r.l. + BFG: Burkhardt Feinkostwerke GmbH + BFR: Bioforce A.Vogel GbmH + BFS: Bruno Fischer GmbH Naturkost + bgb: Heinz Bursch + BGH: Burgunderhof digestif´s GmbH + BHÄ: Bäck. Härdtner + bhb: Bäckerei Höhenberg + bhc: Bioland-Hof Christiansen´s + bhk: Bioland-Hof Klauser + bhl: Bioland Hof Lesker KG + bhm: Bioland-Hof Hubert Merz + BHO: Barnhouse Naturprodukte GmbH + bhö: Bioland-Hof Hörz + bhr: Bioland-Hof Martin Häring + BIA: Bio Aras, ELAFOS + BIB: Bio Bärchen Vertriebs GmbH + bid: Imkerei Binder + BIF: Biofrisch GmbH + BIH: Markus Bihler GmbH + bil: BioHof Laurer + bim: Bieringer Mühle + BIN: Bingenheimer Saatgut AG + BIO: Bio Akademie + BIP: Bio Plus GmbH + BIR: Käserei H. Birkenstock GmbH + BIS: Bio Service SRL + BIT: Bioturm + BIV: BioVita Naturkost GmbH + BIZ: Biozyklische Produkte AG + BJS: Josef Schäfers + BKB: Bio Korn Biscuits + bkf: Bakenhus Biofleisch GmbH + bkh: Bauckhof OHG + BKM: Biokosma GmbH + bko: Bäckerei Kostner + BKP: Brava cv + BKT: Biokorntakt Vertriebs GmbH + BKW: Liane und Roman Wirth + BLA: biolare ? Pilzanbau + BLB: Blütenland Bienenh. + blg: Bollinger, Bernd + BLI: Holle Baby Food GmbH + BLL: Boller Fruchtsäfte + BLM: Binger Lammbräu GmbH + BLN: Bioland GmbH Nord + BLR: Ökofrost GmbH + BLS: Bioland Südtirol + BMA: BIOMAS + BMK: N.V. Biomilk S.A. + BML: Bio Molkerei Lembach + bms: Bioland-Milchschafhof + bmü: Bannmühle + bmw: Barbara Müller Handels GmbH + BND: Bionade GHmbH + BNE: Bionest + BOA: Bio-Obst Augustin KG + BOB: Bobalis + BOH: Boschenhof GbR + BOI: Bois Naturkost GmbH + BOK: Bodensee Kelterei GmbH + BOL: Bohlsener Mühle + böm: BÖMO + BON: Allos Walter Lang GmbH + bos: Biol-Dyn. Obstbau Seger + BOW: Gandha BV + BPL: F.J. Moog SARL + BPR: Bioprim + bra: Brack Kaffee + brb: Rüdiger Born + BRE: Gewürzmühle Brecht GmbH + BRI: Brio Spa + BRO: Jules Brocherin S.A. + brs: Asgaard + BRT: Candy Factory KG + bru: Biolandhof Brummer-Bange + bsh: Bioland Schleswig-Holstein + BSK: Wiggensbach GmbH + bsp: Bioland-Hof Speidel + bsw: Bioland-Hof Schulte-Walter + BTH: Biothek Handels-GmbH + btm: EZG Bioland-Südgetreide + BTR: Biotropic GmbH + BUC: Bucheckchen + BUF: Bodin & Fils + BÃœH: Metzgerei Bühler GmbH + BUK: Borghoff & Kötter Gbr + bup: Braun U. Partner + BUR: Burk's Fränkische Öko-Nudeln + BVE: Bio Vegan GmbH + bvg: Bioland Vermarktungs GmbH + BVI: abacco B.V. + BWH: Bornwiesenhof + BWL: Haya Lebensmittel GmbH + BYO: Byodo Naturkost GmbH + CAA: Coop.Agr. ARABIOS.a.r.l. + CAB: Erich Boden Delikatessen + CAL: Calendula Naturkost Backstube + CAM: Campobelle s.r.l. + can: Anthal Canadi + CAR: Care Naturkost GmbH & Co. + CAV: Cal Valls + CBR: C. Berger + CBU: Weingut Clemens Busch + CDO: Cha Do Teehandel + CES: Il Cesto + CGL: Castiglioni S.P.A. + CHE: Chemviron Carbon gmbH + CHI: Chiemgauer Naturfleisch GmbH + CHR: De Rit Handels GmbH + CLO: Clostermann + CMD: CMD Naturkosmetik + CNH: Chiemgauer Naturkosthandel + COL: Chocolat Schönenberger AG + COR: C&C Fine Foods, Niederlassung + COS: Cosmoveda, G. Eckerle + CTE: Castle Tea + CUM: Cumnatura + CVE: Campina Verde ecosol S.L. + DAG: De Dageraad + DAK: Die andere Konditorei + DAM: Dachswanger Hof + DAN: Danival + DAV: Davert GmbH + DBB: Die Beerenbauern + DBH: CW Öko Ei GmbH + DDC: Domain de Clairac, Frankreich + DDI: Demeter Dienste + DDM: Domaine du Midi GmbH + DEH: Bio-Hofmolkerei Dehlwes + DEN: dennree-Versorgungs GmbH + DET: Detmers Getreide GmbH + DFE: Demeter Felderzeugnisse GmbH + DFR: Daniel Frank + DGU: Dal Gustaio + DIE: Helmut Arendt + DIN: Alfons u. Franz Neumeier GbR + dio: Dionisio de Nova Garcia + dis: Schulze-Schleppinghoff + DIW: Weingut Hans Diwald + DKA: Dr. Klaus Karg + DKG: Geifertshofen GmbH + dko: Disselkoen Organics + dma: Demeterhof Massmann + dmä: Demeterhof Mäck + dnj: Danner, Johann Georg + DOT: Dottenfelder Hof + dpr: Demeterhof Preller + DRM: Dr. Martins da Cunha GmbH + DSE: Deutsche See + dsw: Dirk Schulze-Wethmar + DUN: Dunn's of Dublin + DWE: Dwersteg Destillerie + DWF: Dworschak-Fleischmann GbR + dwp: Dritte Welt Partner + DYF: Dynamis France + DZW: De Zwalm + EBR: Die Regionalen + ECO: Ecomel B.V. + ECP: ecopan-Naturkost GmbH + ecr: Ecoregion + ECV: ECOVER Products nv + EGG: Eggert´s Tiefkühl-Service + EGL: Wilhelm Egle GmbH + EGM: Ökoland GmbH + EIQ: Ei.Q. GmbH + EIS: Eisblümerl Naturkost + eit: Eitzinger Franz + ELK: Naturkost Elkershausen GmbH + EOG: EOS Getränke GmbH + EOS: Eosta International BV (NL) + EPI: epikouros + ERD: ErdmannHauser GmbH + ERH: Frank Erhardt + ERN: ERNTESEGEN Naturkost GmbH + EUH: Eurohealth AG + EUN: Euronat ? Bretagne + EVS: Evers Naturkost GmbH + EWE: Ernst Weber Naturkost + fah: FairHandeln + FAI: Frucht Agentur Iberia + FAL: Breisgaumilch GmbH, Fallers + FDO: Fattoria degli Orsi + fig: Fattoria degli Orsi + FIN: Finck + fis: Brauerei Rupert Fisch + FIT: Fitne GmbH + FKS: Hermann Stiefel + FKW: Fruchsaftkelterei Klaus Weber + FLA: Flamant Vert S.A.R.L. + FLC: Flockenhaus + fle: Fleckenbühler Landprodukte + FLN: Flemming-Naturkost + FLO: Florin, Angelika Trankle + FLP: Fleur Products BV + FON: Fontaine Nahrungsmittel GmbH + FOR: Forte + FÖR: Förster + FPF: Fahrenzhausen GmbH + fps: Franz Baumann + FRC: Francia Mozzarella + FRE: Hofladen Frey + FRH: Freiheithof + FRI: Frisetta GmbH + FRK: Frischkeim Naturkost GmbH + FRO: Fromin GmbH + FRT: Florentin-Mediterranean Food + FVG: FALA Verkaufsgesellschaft mbH + FZI: Feinkäserei Zimmermann + FZS: Sommer & Co.KG + gah: Gärtnerei Amaranth + gäh: Gärtnerei Halmberg + gäk: Gärtnerei Kienast + gal: Gallung´s Ziegenhof + GAR: Gärtnerei Landes + GBA: Gerald Bartke GmbH + gch: Gärtnerei Christian Hiss + gcl: Gut Clarenhof + gdi: Gärtnerei Distel + GDR: Graindrops + GEB: Martina Gebhardt GmbH + GEE: Lupina Handels GmbH + GEH: Georg Gehrsitz GmbH & Co.KG + GEP: GEPA + GFH: Mechthild & Andres Klose + GFR: Gebr. Franz GmbH + ggk: Burkhard Dreckel + gha: Gärtnerei Andreas Hankel + gho: Gärtnerei Horizont + gie: Giegold Hefefabrik + gip: Gilchinger Pilzzucht + gks: Gärtnerei Klein Sigi + GLG: Glafey-Lichte GmbH + gli: Glitz Ehringhausen + GLM: Gläserne Meierei GmbH + GOL: Golden Temple + GÖM: Grünsfelder GmbH & Co.KG. + gom: Gomille, Torsten + GOV: Govinda?s Naturkost GbR + gpb: Gerhard Preuschl Biolandhof + gpe: Gesa Petersen + GPN: Grüner Punkt Naturkost GmbH + GRE: C.F. Grell Nachf. + GRM: Grindsted Mejeri + GRN: Biotropic GmbH + GRU: Gruel Biolandhof + GSD: Gerhard Schürholz GmbH + GSE: GSE Vertrieb + gsi: Gregor Sing + gsl: Gärtnerei Schmälzle + gub: Gärtnerei Ulenburg + GUD: Gude GmbH + GUL: Gesund & Leben + GUR: Gurtmann, Christoph + GUT: Gute Zeiten GmbH + GUZ: Glahn & Zindl + GWF: GWF eG + HAA: Haaner Felsenquelle GmbH + hag: Hartmann Getränke + hal: Haldenhof + HAM: Hamfelder Hof + HAN: Handelskontor Willmann + HÄR: Härle + HAU: Dr. Hauschka ? Wala GmbH + HAW: hawo´s Getreidemühlen GmbH + HBG: Hornberger Lebensquell + hdk: Hof Dinkler + HEC: Heuck Landbäckerei + HEI: Heidelberger Naturfarben + hek: Hecker Naturkost + HER: Herbaria Kräuterparadies GmbH + HES: Weingut Heiner Sauer + HEU: Heuschrecke Naturkost GmbH + hex: Hexerküche + HFA: Hof Farrenau, Deimling GbR + hfm: Hofgemeinschaft Fischermühle + hfn: Hofgemeinschaft Fischermühle + hgo: Imkerei Oswald + hha: Hasso Hasbach + HIE: Hierl- Der Nudelmacher + HIN: Mathias Kloppenborg GmbH + HKH: Hofkäserei Heggelbach + hkk: Hekking + HLE: Holzlehner + HLW: Herrmannsdorfer Werkstätten + HMB: Humbel Brennerei + HMS: Handelsag. Rolf Schekerka + HMÃœ: Peter & Martina Linxweiler + HOC: Hoch GmbH Oblatenfabrik + hof: Hofmark Brauerei + hoh: Dorfgem. Hohenroth + hoi: Henri Willig B.V. + HOL: Holle Baby Food GmbH + HÖL: Höllensprudel + hom: Hoffmeier + HOR: Horizon Natuurvoeding B.V. + HÖR: Bäckerei Hörtling + HOV: H2Ovital oHG + HOY: Hoyer GmbH + HPG: Horn Papiergroßhandel + hse: Herbert Seitz + hst: Hof Steinrausch + hum: Huber, Martin + HUN: hanf & natur + HUZ: Huzo + hwi: Henri Willig, Kaasm. + HWL: Hawlik Pilzbrut GmbH + IAB: Imkerei (Reiner) Bienefeld + ibe: Imkerei Berrenrath + ilk: Imkerei Ludger Klinker + ILU: ILUMINA GmbH + imb: Imkerei Betz + IMF: Hain Celestial Europe BVBA + imm: Mohr + Müller Imkerei + irf: Imkerei Feldt + IRM: Imkerei Roland Maier + ISA: ISANA GmbH & Co.KG + ISE: Klaus Wolf + ISK: Isko Vertriebs GmbH + IUM: I&M Inge Stamm GmbH + jäh: Jähnke Naturkost + JAN: BioFleischerei Jansen + JAS: Jasci Donatello + JAT: Jatex Handels-GmbH + jbe: Beck Schafhof + JOP: Jogopur Yogoferm GmbH + JOR: Jordan Cereals Ltd. + KÄB: (Martin) Bauhofer Käserei + KÄL: Inntaler GmbH + KAM: KAMUT Association of Europe + KAN: Kanne Brottrunk GmbH & Co.KG + KAT: Karibu Trade + kbh: Kiebitzhof + KBW: Klosterbrauerei Weißenohe + kei: Keil, Sepp + KER: Keramik & Kerzen + kgg: Kelterei Gregor Greimel + KGÖ: Karl Gröner GmbH + KGV: Klostergut Volkenroda + KHA: Konrad Halder + KIL: Kilian + KIP: Kipepeo BIO & FAIR GmbH + KKL: KKL-Naturwaren + KKV: Vollwertbäckerei König + KLA: AlmaWin GmbH + KLD: Keimland + KLG: Keimling Naturkost GmbH + klk: Käserei Schlierbach + klo: Klotz, Martin + KMF: Käsemanufaktur, Lothar Müller + KNE: Getreidemühle Knecht KG + KNÖ: Robert Knöbel + KON: Engelhard GmbH & Co. KG + KOR: Kornblume, F.+ B.Brinkmann + KPL: Kräutergarten Pommernland + KRA: Kranichhof + KRÄ: KAULFUSS + KRE: Krämers Ernährung + krr: Fachkrankenhaus Ringgenhof + KTO: Kato + KUC: Kolla & Co + KWE: Köhlerei Wengert + LAB: Labroco Agrarconsult + LAF: Hofgut Algertshausen + LAL: La Luna del Rospo + läm: Lämmerhof + LAN: Landkrone GmbH + LAS: Lakhsmi + LAV: laverana GmbH + LBI: Do-it Dutsch + LEB: U. Walter GmbH - Lebensbaum + LHQ: St. Leonhardquelle + LIL: Legend International Ltd. + LIM: Lima NV + LIR: Lily Rose + LIW: Lichtwurzel, Imton + LJL: Johann Langgartner + LMC: Lammersiek & CO. + LNA: Grabower Süßwaren GmbH + LÖC: Löcke Bio-Pilzzucht + LOG: Logona Hans Hansel GmbH + LSP: La Spinosa ( Weingut) + LTA: Lauretana, Wasser Import GmbH + LUB: Lubs GmbH + lüp: Lübcke Papier GmbH & Co KG + LUV: Luvos Heilerde + MAB: Bio-Nahrungsmittel GmbH + mah: Hof Mahlitzsch + MAI: Maisch + map: Maple GmbH + MAR: Marschland NK GmbH + MÄR: Märkisches Landbrot GmbH + MAT: Martinshof GmbH + MÄU: Gebr. Grund GmbH & Co.KG + MAY: Mayka Naturbackwaren GmbH + MAZ: Mazer, Bernd + MCA: Mustiola International SRL + med: Medousa, Griechenland Importe + MEK: Weingut Meinklang + met: Metsä Tissue GmbH + MGN: Naturland-Bauern e.G. + mhb: Meyerhof Belm + mhh: ?Die Meierei? Hansfelder Hof + MID: Midi + mig: Migliore + mil: Miller GmbH & Co.KG Agnes + MKF: merkur frucht Freiburg GmbH + MKL: Makulaku Confectionery Ltd + MLL: Mollis Kinderprodukte GmbH + MMC: MM Cosmetic GmbH + MOA: MolenAartje B.V. Natudis + MOB: Frisetta GmbH & Co.KG + MOC: Wasserprinz; div. Anbieter + MOI: Moin BioTK-Bachwaren + MOK: Mokobella EU GmbH + MOL: Moltex Baby-Hygiene GmbH + MOR: EgeSun GmbH + MÖR: Mörk Naturkostprodukte + MOU: Wertform GmbH & Co + MSV: mesa verde + MTB: Mont´Albano + MUL: Multikost Vertriebs GmbH + MWO: Milchwerke Oberfranken + MZG: Sieben Zwerge GmbH + mzi: Mathias Zipf + NAB: Hubert Tempelmann e.K. + NAC: BodyWise (UK)Ltd. + NAG: Tofumanufaktur Nagel GmbH + NAM: Naturmaelk A.m.b.a. + NAP: Combu Cha + NAT: Naturata e.G. + nbm: Nußbaumer, Roman + NBO: Nürnberger Bio-Originale + NCO: Natur Compagnie GmbH + NEE: Neue Erde GmbH + NEG: Neu´s GmbH & Co. KG + NEU: Gebr. Ehrnsperger e.K. + nhb: Naturlandhof Biberger + NHU: Natur Hurtig (Himalaya Salz) + nlg: Nordland, Lebensgem. + NMA: NaturMarkt GmbH + nmd: Münzner + NNA: Mensch & Natur AG + NOK: Noka-Sojamanufaktur GmbH + NPG: Nette Papier GmbH + NSC: Naturkost Schuchardt + NTM: Natumi GmbH Produkte & Ideen + NTR: Naturian Ökoweine OHG + NTU: Naturion + NUR: IL NURAGHE GmbH + NUT: Nutrifors AG + NWA: Nikolaihof Wachau - Weingut + NWR: Öko-Norm GmbH + OAT: Ceba Foods AB + obb: Obsthof Bruno Brugger + obm: Obsthof Bernd Majer + OBS: Öko-Bauernhöfe Sachsen GmbH + ÖBW: Brodowin Ökodorf + OCB: OCB-Vertriebs-GmbH + ODE: Odenwald EKO Brood en Banket + ODI: ODIN Holland C.V. + ÖER: Öko Ernte GmbH + ÖFA: Öko Feinkost Andechs Gmbh + ÖFR: Ökofrost GmbH + ogh: Demeter Gärtnerei Obergrashof + ohc: Obsthof Cordes + OHE: Obsthof Heinrich + ohh: Obsthof Hermann Helde + OHL: Ohling, Andreas + ÖKB: ÖkoBo + ÖKH: Ökohum Vertriebs GmbH + ÖKL: Ökoland GmbH Nord + ÖKN: Ökonatur + ÖKU: Naturkosthandel Ökollus + ÖLI: Öko-Line + ÖMA: ÖMA- Beer GmbH + OML: Ostermühle Naturkost GmbH + ÖMS: Ölmühle Solling GmbH + ORG: Organix4U GmbH + ORH: Obsthof Robert Hartmann + ORO: Organic Oils S.P.A. + ort: Biofrucht Ortlieb GbR + osn: Osning-Getränke GmbH + ÖWK: Haus am Goldberg GmbH + ÖWR: Weingut Richard Schmidt + ÖWS: Öko-Weinimport Schmid + pab: Bacchini Roberto & C. S.n.c. + PAN: Pasta Nuova GmbH + pau: Bioland Gemüse Paul + PEM: PEMA Heinrich Leupoldt KG + PER: Perger Getränke GmbH + PET: Marcel Petite, Frankreich + PFH: Gabriele Gersdorf GmbH + PFO: Papierf. Oberschmitten GmbH + PID: MW BGL Chiemgau eG + PIM: Pinzgauer Molkerei + PIN: Pinkus Müller GmbH & Co.KG + PLA: Käserei Plangger Ges.m.b.H. + PLG: Peralge, Marciella Callegarie + PLO: div. Anbieter + PMI: Peterstaler Mineralquellen + PMP: Progeo Mangimi Petfood + PNA: Pro Natura S.A. + PÖB: Pötzelberger + pod: Poder GmbH + PÖS: PINGU-Öko-Tiefkühlservice + PRG: Provence Regime S.A. + PRN: Pro Natur GmbH + PRO: Probio Handelsgesellschaft + PRV: Provamel + PVL: Primavera Life GmbH + RAA: Raab + RAC: Rachelli Italia s.r.l. + rad: Radicula GmbH (Avalon) + ran: Randegger Ottilienquell + RAP: Rapunzel Naturkost AG + RBB: Michael Krieger KG + rde: Roman Denis Bioland-Gemüsebau + rds: Rudolf Schramm + RED: Redecker + rei: Reicheneder, Gerhard + rha: Hofgut Rengoldshausen + RHG: Rheinland-Höfe GmbH + RHÖ: Rhöner (Brauerei) + RIE: Peter Riegel Weinimport GmbH + RIN: Ringenwalde Werkhof + RIS: Ristic + RIT: De Rit Handels GmbH + RLG: Metzgerei Rieblinger + ROB: Geflügelhof RoBert?s + rog: Söbbeke GmbH & Co. KG + ROH: Geflügelhof Rothäusle + ROL: C. F. Rolle Mühle GmbH + ROM: Rosmarin Ingo Karrasch GbR + ROS: Hubmann- Rosengarten + RÖS: Georg Rösner Vertriebs GmbH + ROT: Rother Bräu + rsh: Rösslerhof + RTE: Manfred und Christine Rothe + RUH: Riensch & Held GmbH & Co. KG + RUN: Runge Nahrungsmittel GmbH + RUS: Ruschin Makrobiotik GmbH + RZO: Rzollhäusle, H.R. Hauser + SAB: SANBEAM Gesunde Produkte GmbH + SAC: Petersilchen Sanchon GmbH + säh: Karla u. Sebastian Schäfer + SAL: Salomon + SAN: Sante Naturkosmetik GmbH + SAO: Gsund & Schön Sanoll + SAR: Sanatur GmbH + SAS: S´Atra Sardigna Coop A.r.l. + SAV: Santaverde GmbH + sbä: Steinofen Bäcker + SBG: Mol Hohenlohe-Franken e.G. + SBH: Matthias Höfflin + SBM: Saarpfälzische Bio-Höfe GmbH + SCH: Naturkost Schramm GmbH + SCK: Walter Rau GmbH & Co. KG + SDE: Robert Schindele GesmbH + SDL: Siegfried Schedel + SEE: Weingut W. Seeber + SEG: Sennerei Walchsee GmbH + SEK: Sekowa Seibold KG + SEL: La Selva Vertriebs-GmbH + SFE: Hof Mühlenberg E. Schiffers + sfm: Schäfer, Martin (Michaelshof) + SFO: Sinfo Naturkost & Naturwaren + SHE: Weingut Schäfer-Heinrich + shh: Max Fischer + SIN: Singer + SJF: Sojafarm + sjh: Metzgerei Schojohann + sjs: Schaut, Josef + SKA: Schönegger Käse-Alm GmbH + SLC: Svenska LantChips AB + sle: Schilling, Erich + slm: Salm, Elvira (Limberger) + SMA: Sana-Mare + SND: Weingut Sander + SNF: Sanoflore + SNI: Weingut Stortz-Nicolaus + snn: Monika u. Thomas Sannmann + SNT: Sonett OHG + SNZ: Schnitzer Bräu + SOB: SOBO Naturkost + SÖB: Söbbeke GmbH & Co. KG + SOD: Sodasan GmbH + SOE: Salamita Soc. Coop. A.r.l. + SOF: Soto Feinkost, Oskar Schramm + SOJ: Triballat Noyal + SON: Sonne GmbH + SOT: Allgäuland + SPA: Spaichinger Nudelmacher GmbH + spe: Speckhan, Rudolf + SPH: Spreewälder Hirsemühle + SPI: Spielberger KG Naturata e.G. + SPL: Silver Plastic GmbH & Co. KG + SPR: B & G Sprossenparadies GmbH + sqn: St. Nikolaus Quelle + SRH: Scharein, Hubert + SSC: Sural-Sacicc + SSI: Santisi Vollkornnudeln + STB: Seitenbacher GmbH Naturkost + STE: Steck + sth: Scholtenhof + STN: Sonnentor GmbH + STY: Teebaumöl Kosmetik + STZ: Schnitzer OHG + SUN: Sunval Nahrungsmittel GmbH + SVA: Svadesha Naturkost- Vertrieb + SVE: Svenska Lant Chips + svm: Hof von der Mehden + SWE: Schuldt & Weber + swo: Schwollener Sprudel + sww: Karin u. Corney Weimeijer + SWZ: Schweizer GmbH + SYM: Sympakorn + tag: Tagwerk + TAI: Life Food GmbH + TAP: TAPIR Wachswaren GmbH + TAR: Tarpa Naturkost + TAU: Tautropfen GmbH + TDP: Terra di Puglia + TEL: Hakle GmbH + TER: Terrasana Naturvoeding BV + TES: Terra Soleil + TEU: Teutoburger Ölmühle + TFO: Faan Zuidhorn BV. F.Andringa + TIL: Tilouche Fruchtimport GmbH + TLI: CV Ter Linde + TMJ: Thise Mejeri + TOF: Ökofrost GmbH + TOP: ToPas GmbH + tph: T.Port Hamburg GmbH & Co. + TRA: Tradin Organic B.V. + tro: Tropenfruchtimport GmbH + TUC: Tra Terra e Cielo + ubm: Upländer Bauernmolkerei GmbH + uhe: Uta Helberg + ulh: Ulmenhof + una: Uli Natterer + uns: Unseld´s Backstube + unt: Ulrich u. Monika Unterweger + URD: Uni-Vert + URT: Urtekram A/S + VAV: Vallée-Verte Handelsges. mbH + vbr: Vollkornbäckerei Rasche + VEN: eco cosmetics GmbH & Co. KG + VGB: Bioland Schleswig Holstein + VGE: Verlag gesund essen GmbH + VGF: Hansen & Koschmieder GmbH + VIA: Viana Naturkost GmbH + VIB: Fattoria VIB + VIV: S.A. Viver, Frankreich + VIZ: Vino Zero + VLV: VivoLo Vin, Ökoweinhandel + vms: Traitteur Villemin GmbH + VNI: L. Weinrich GmbH & Co.KG + VOE: voelkel GmbH + VOL: Volvic, Frankreich + VUN: Velazquez Universal s.L. + VVE: Viola Verde GmbH + vzw: Hüser van Zwoll GmbH & Co. KG + waa: Gartenbau Waas + wal: Walter, J. + WAT: Walter Thies Zellglas + WBT: WBT SRL + WDL: Milchkoop Wendland GmbH + WDM: Windmill Organics Foods Ltd. + WDN: Großbäckerei Wendeln + web: Weber GmbH + WEG: Weingut O. Gottschalk + WEH: Peter Werth + WEL: Weleda AG + WEN: Wilhelm Weber GmbH + WER: Werz GmbH & Co. KG + WGP: Wagner Tiefkühlprodukte GmbH + who: Westhof GmbH + WHS: Deutsche Parmalat GmbH + WIE: Weingut Stephanshof + WLM: Ecover Belgium n.v. + wmr: Richard Wirthmüller + WOB: Bäckerei Wolfgruber OHG + WOL: Verlag Fred Wollner GbR + WOO: woodshade organics ApS + WPA: Wepa P. Krengel GmbH & Co. KG + WRK: Weingut Friedhelm Rinklin + WSB: Battenfeld-Spanier + wsq: Wittenseer Quelle + WTI: WTI GmbH + WUN: Wunderland e.V. + WUR: Wurzel Fachgroßhandel + WÃœR: Prima Käse, Jürgen Würth + wwb: Westerwald Bio GmbH + wwi: Weber, Wilhelm + WYS: KAMO, Peter Wyssling + wzb: Wenzelburger GbR. + YAK: Faan Zuidhorn BV. F. Andringa + YAR: Yarrah Food/Vink Sales BV + ZAN: Zann Bio-Center + ZAP: Zapparoli + ZEL: Zellertaler Kellerei GmbH + ZIM: E. Zimmermann GmbH & Co + ZLN: Pastificio Zanellini spa + ZNL: Zagler´s Naturladen + zsl: Ziegenhof Schlatt + ZWE: Zwergenwiese Naturkost GmbH + ZWI: E. Zwicky (Deutschland) GmbH + ZWÖ: Weingut im Zwölberich + +category: + "01": Brot und Backwaren + "02": Milch, Milchprodukte, Eier, Tofu + "03": Obst, Gemüse, Sprossen, Pilze + "04": Fleisch, Wurst, Snacks + "05": Getreide, Ölsaaten, Nußkerne + "06": Nudeln, Trockenfrüchte, Müsli + "07": Brotaufstriche, Honig, Nußmuse + "08": Würzmittel, Öle, Fette + "09": Süßwaren, Gebäck, Pudding + "10": Spezialsortimente + "11": Tee, Kaffee, Kakao + "12": Getränke + "13": Kräuter, Heilmittel, Ätherische Öle + "14": Körperpflege und Kosmetik + "15": Wasch- und Reinigungsmittel + "16": Haushaltsgeräte + "17": Bücher und Zeitschriften + "18": Papier, Schreibwaren, Spielzeug + "19": Textilien und Schuhe + "20": Farben, Bau- u. Wohnmaterial + "0101": Brot + "0102": Brötchen, Semmeln, Brezen + "0103": Spezialitäten + "0111": Standardgebäck + "0112": Saisongebäck + "0113": Kuchen, Torten + "0121": Pikantes Gebäck + "0131": Sonstiges vom Bäcker + "0201": Milch + "0202": Sauermilchprodukte + "0203": Quark + "0204": Joghurt + "0205": Pudding + "0206": Sahne, Butter, Sonstiges + "0211": Ziegen-/Schafsmilchprodukte + "0221": Frischkäse + "0222": Weichkäse + "0223": Halbfester Schnittkäse + "0224": Schnittkäse + "0225": Hartkäse + "0231": Ziegen-/Schafskäse + "0241": Eier + "0251": Tofu, Tempeh + "0252": Soja-Frischprodukte + "0253": Soja- und Reisgetränke + "0254": Sojapudding + "0301": Obst, heimisch + "0302": Südfrüchte + "0303": Beeren + "0304": Exoten + "0311": Kartoffeln + "0312": Wurzelgemüse + "0313": Salate + "0314": Blatt- und Zwiebelgemüse + "0315": Kohlgemüse + "0316": Fruchtgemüse und Spezialitäten + "0321": Kräuter + "0331": Keime und Sprossen + "0341": Pilze + "0351": Nüsse in Schale + "0399": Div. Frischprodukte + "0401": Fleisch + "0402": Geflügel + "0411": Wurst + "0421": Fisch + "0422": Fischerzeugnisse + "0431": Burger, Kroketten + "0441": Sonstige Snacks + "0501": Getreide + "0502": Hülsenfrüchte + "0511": Ölsaaten + "0521": Nußkerne + "0531": Keimsaaten + "0601": Getreideprodukte + "0602": Flocken + "0603": Nudeln + "0611": Sojaerzeugnisse + "0621": Trockenfrüchte + "0631": Müsli + "0632": Krunchy + "0701": Würzige Aufstriche + "0702": Fruchtaufstriche + "0711": Honig + "0712": Honigprodukte + "0721": Nußmuse + "0801": Salz und Kräutersalz + "0802": Essig + "0803": Senf + "0804": Suppen und Soßen + "0805": Sojasoße und Miso + "0806": Würzmittel + "0811": Gewürze + "0812": Gewürzmischungen + "0813": Gewürzöle + "0821": Speiseöle + "0822": Margarine + "0831": Pikante Konserven + "0832": Süße Konserven + "0841": Fertiggerichte + "0842": Halbfertiggerichte + "0901": Frucht- und Knusperriegel + "0902": Bonbons und Lutscher + "0903": Schokolade + "0904": Pralinen + "0911": Dauergebäck + "0912": Waffeln + "0913": Kekse + "0914": Knabbergebäck + "0921": Süßmittel + "0922": Obstdicksäfte + "0923": Carob + "0931": Pudding + "0932": Back- und Geliermittel + "0933": Kochhilfen, Fermente + "1001": Säuglingsbreie + "1002": Babykost + "1011": Makrobiotische Spezialitäten + "1021": 3. Welt-Solidaritätswaren + "1031": Tiefkühlkost + "1051": Tiernahrung + "1101": Früchtetee + "1102": Kräutertee + "1103": Kräutertee-Mischungen + "1104": Rooibos + "1105": Gewürztee + "1111": Schwarzer Tee + "1112": Grüner Tee + "1113": Aromatisierter Tee + "1121": Bohnenkaffee + "1122": Ersatzkaffee + "1131": Kakao + "1132": Schokoladengetränke + "1201": Wasser + "1211": Fruchtsäfte + "1212": Fruchtnektare, Limonade, Schorle + "1213": Gemüsesäfte + "1215": Kwaszgetränke, Getreidegetränke, Diätgetränke + "1221": Bier + "1231": Rotwein + "1232": Rosé-Wein + "1233": Weißwein + "1241": Cidre + "1242": Schaumwein + "1251": Spirituosen + "1301": Heilkräuter + "1302": Kräutermischungen + "1311": Freiverkäufliche Arzneimittel + "1312": Kur- und Heilmittel + "1321": Ätherische Öle + "1322": Ätherische Ölmischungen + "1331": Duftlampen und Rauchgefäße + "1332": Zubehör für Duftwerk + "1341": Räucherwerk + "1401": Seife + "1402": Gesichtsreinigung und -pflege + "1403": Körperöl und Körperpflege + "1404": Haarpflege + "1405": Zahn- und Mundpflege + "1406": Handcreme + "1407": Fußpflege + "1411": Badezusätze und Duschpräparate + "1412": Deo, Eau de Toilette + "1413": Rasierzubehör + "1414": Sonnenschutz + "1415": Baby- und Kinderpflege + "1421": Dekorativkosmetik + "1422": Parfum + "1423": Sonstige Kosmetik + "1431": Zahnbürsten + "1432": Bürsten und Kämme + "1433": Kosmetikzubehör + "1441": Hygiene + "1451": Tierpflege + "1501": Waschmittel + "1502": Spülmittel + "1503": Reinigungsmittel + "1511": Dosierhilfsmittel + "1521": Schuhcreme + "1531": Insektenschutz, Düngemittel + "1601": Handmühlen + "1602": Elektromühlen + "1603": Kombi-Maschinen + "1604": Zubehör für Kombigeräte + "1611": Sonstige Haushaltsgeräte + "1612": Keimgeräte, Dörrapparate, Gärtöpfe + "1621": Küchenhelfer + "1622": Kaffee- und Teefilter + "1631": Haushaltswaren + "1701": Kochen und Backen + "1702": Ernährung und Gesundheit + "1703": Landwirtschaft und Garten + "1704": Ökologie und Ergänzendes + "1705": Baubiologie + "1706": Esoterisches + "1707": Sonstige Bücher + "1711": Zeitschriften + "1801": Schmuckpapier + "1802": Schulpapier + "1803": Neutrales Papier + "1804": Formdrucke + "1805": Geschenkpapier + "1806": Sonstiges Papier + "1811": Stifte + "1812": Malbedarf + "1813": Knetwachs + "1821": Kerzen + "1831": Spielzeug + "1832": Bastelbedarf + "1841": Edelsteine + "1851": CD's + "1852": MC's + "1901": Windeln + "1902": Baby- und Kinderwäsche + "1903": Erwachsenenwäsche + "1904": Oberbekleidung + "1905": Strümpfe + "1911": Schuhe und Einlegesohlen + "2001": Imprägnierung, Lasur, Balsame + "2002": Lacke + "2003": Wandfarben + "2004": Kleber + "2009": Sonstige Farben, Lösemittel + "2011": Tapeten + "2012": Bodenbeläge + "2013": Dämmstoffe + "2019": Sonstige Baumaterialien + "2021": Mobiliar + "2022": Matratzen + "2023": Heimtextilien + "2029": Sonstige Wohnmaterialien + "2031": Werkzeug, Hilfsmittel \ No newline at end of file diff --git a/lib/foodsoft_article_import/dnb_codes.yml b/lib/foodsoft_article_import/dnb_codes.yml new file mode 100644 index 0000000..b7cf5b0 --- /dev/null +++ b/lib/foodsoft_article_import/dnb_codes.yml @@ -0,0 +1,129 @@ + +# from http://www.nieuweband.nl/producten/groepen/ +indeling: + 1: Verswaren + 50: Kaas + 62: Schapenkaas + + 2: Basisproducten + 850: Noten + 855: Noten grootverbruik + 700: Peulvruchten + 705: Peulvruchten grootverbruik + 340: Rijst + 341: Rijst grootverbruik + 450: Vlokken + 455: Vlokken grootverbruik + 800: Zaden en pitten + 805: Zaden en pitten grootverbruik + 603: Melen grootverbruik + + 3: Ontbijt en lunch + 943: Marmelade + 1272: Muesli en poppies + 1000: Notenpasta + 1276: Ontbijtmelen + 1295: Rijstwafels + 1290: Roggebrood + 1270: Sandwichspread + 940: Vruchtenbeleg + 942: Vruchtenjam + 944: Vruchtenstroop + 1300: Knäckebröd, toast en beschuit + + 4: Warme maaltijd + 1820: Mosterd + 1610: Olijfolie + 1600: Olijven + 1451: Peulvruchtenconserven + 1957: Pindasaus + 1960: Sambal, ketjap en pittige smaakmakers + 2170: Seitan + 2260: Siropen + 2248: Smaakmakers + 1500: Soepen en bouillon + 1515: Soepstengels + 2000: Sojasauzen + 2250: Suiker + 1452: Tafelzuren + 1590: Tamme-kastanje-producten + 1975: Thaise keuken + 1900: Tomatenproducten + 1670: Vetten + 1930: Visconserven + 2175: Vleesvervangers + 1360: Vruchtencompote + 1400: Vruchtenconserven + 1350: Vruchtenmoes en -puree + 2249: Zout en kruidenzout + + 5: Sappen en dranken + 2605: Rode wijn Oostenrijk + 2604: Rode wijn Portugal + 2602: Rode wijn Spanje + 2608: Rode wijn Zuid-Afrika + 2612: Rosé Spanje + 2617: Rosé Zuid-Afrika + 2420: Smoothies + 2455: Sojamelkproducten + 2505: Speciaalbieren + 2400: Vruchtensappen + 2490: Waterijs + 2637: Witte wijn Argentinië + 2630: Witte wijn Frankrijk + 2634: Witte wijn Griekenland + 2631: Witte wijn Italië + 2635: Witte wijn Oostenrijk + 2632: Witte wijn Spanje + 2638: Witte wijn Zuid-Afrika + + 6: Warme dranken en theekruiden + 3102: Kruidenthee builtjes + 3100: Kruidenthee los + 3020: Kruidenthee met geneeskrachtige werking + 3009: Rooibosthee + 3010: Thee grootverpakking + 3052: Theekruiden + 3008: Witte thee + 3011: Yogi spice tea + 3012: Yogi tao tea + 3000: Zwarte thee + + 7: Versnaperingen + 3552: Lollies + 3470: Nougat en fudge + 3570: Raw Food + 3360: Rozijntjes in kinderverpakking + 3410: Snijkoek + 3555: Snoep met suiker + 3550: Snoep zonder suiker + 3405: Stroopwafels + 3350: Tortillachips en salsa + 3358: Zoete chips + 3540: Zoethoutstokjes + 3365: Zoutjes, hartige bites en popcorn + 3530: Laurierdrop + + 8: Persoonlijke verzorging en cosmetica + 5036: Lavera + 5037: Namaste + 5040: Natracare + 5042: Odylique + 5049: Sonett + 5055: Urtekram + 5065: Weleda + + 9: Natuurtherapeutisch + 5455: Kruidentincturen + 5420: Propolis-producten + 5245: Zelfzorgmiddelen + 5280: Huid- en massage-olie + + 10: Non Food + 5517: Luiers en babydoekjes + 5510: Maandverband en tampons + 5520: Toiletpapier e.d. + 5890: Voor kinderen (en volwassenen) + 5650: Was- en schoonmaakmiddelen + 5515: Watten + 5610: Luchtverfrissers diff --git a/lib/foodsoft_article_import/foodsoft.rb b/lib/foodsoft_article_import/foodsoft.rb new file mode 100644 index 0000000..76fe45d --- /dev/null +++ b/lib/foodsoft_article_import/foodsoft.rb @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Module for Foodsoft-file import +# The Foodsoft-file is a CSV-file, with semicolon-separated columns, or ODS/XLS/XLSX + +require 'roo' +require 'roo-xls' + +module FoodsoftArticleImport::Foodsoft + + NAME = "Foodsoft (CSV, ODS, XLS, XLSX)" + OUTLIST = false + OPTIONS = { + encoding: "UTF-8", + col_sep: ";" + }.freeze + + # Parses Foodsoft file + # the yielded article is a simple hash + def self.parse(file, custom_file_path: nil, **opts) + custom_file_path ||= nil + opts = OPTIONS.merge(opts) + + ss = FoodsoftArticleImport.open_spreadsheet(file, **opts) + + header_row = true + ss.sheet(0).each.with_index(1) do |row, i| + # skip first header row + if header_row + header_row = false + next + end + # skip empty lines + if row[2].to_s.strip.empty? + # raise no order number given + yield nil, nil, i + next + end + + article = {:order_number => row[1], + :name => row[2], + :note => row[3], + :manufacturer => row[4], + :origin => row[5], + :unit => row[6], + :price => row[7], + :tax => row[8], + :unit_quantity => row[10], + :article_category => row[13]} + article.merge!(:deposit => row[9]) unless row[9].nil? + FoodsoftArticleImport.generate_number(article) if article[:order_number].to_s.strip.empty? + if row[6].nil? || row[7].nil? or row[8].nil? + yield article, "Error: unit, price and tax must be entered", i + else + yield article, (row[0]=='x' ? :outlisted : nil), i + end + end + end + +end \ No newline at end of file diff --git a/lib/foodsoft_article_import/midgard_codes.yml b/lib/foodsoft_article_import/midgard_codes.yml new file mode 100644 index 0000000..8777e2e --- /dev/null +++ b/lib/foodsoft_article_import/midgard_codes.yml @@ -0,0 +1,294 @@ +manufacturer: + "61": Maintal + AB: Agrobioservice + AD: Anita Dehnert + AH: Phyto Treasures e.K. + AO: Arganöl + AR: ARIES + AS: Abraham Schinken + Ad: Molkerei Andechs + An: Frans Andringa + Ap: Apfeltraum + Ar: Provamel über Arche + Ay: Aytem + BA: BauckHof Amelinghausn + BB: Bakenhus Biofleisch GmbH + BC: Bio-Bäckerei Bucco + BD: Biosa + BF: Bruno Fischer + BG: Bauers Garten + BH: Bauck Hof + BHA: Bauck Hof Amelinghausen + BI: Biofarben + BK: Burger Knäcke + BKO: BioKräuterei Oberhavel + BL: Beumer & Lutum + BM: Bohlsener Mühle + BN: Brochenin + BOD: Bode Naturkost + BR: Luchs Bier + BT: Beltane Naturkost GmbH + BU: Baumschule am Butzelberg + BV: BIO VITA + BZ: Biozeit + Ba: Bauck demeter Produkte + Bb: Beutelsbacher + Bd: Biosa Danmark Aps + Be: Behncken + Bf: Backforum + Bg: Butzelberg + Bh: Barnhouse + Bj: Milchschafhof Brünjes + Bk: Blank + Bm: Biomax + Bn: Bentele + Bo: Bobalis + Bt: Bretti's + Bu: Biogärtnerei Bauer + By: Byodo + CA: Care + CF: CLUB Feinkost + CI: CIDRERIE + CV: Cosmoveda + Ca: Campo + Cl: Obsthof Clostermann + Co: Obsthof Cordes (Heinrich) + Cp: Campobello + Cs: Cosmoveda + Ct: cbet GmbH + DA: Danival + DE: DEMETER-Erzeugergemeinschaft + DH: Dieter Hein Wurstwaren + DM: Dr. Martins + DN: Hof Dannwisch + DO: Donath-Mühle + DR: De Rit + DV: Davert + DW: Vovic / Evian + De: Dennree + Dk: Dinkula + EB: Erich Boden + EH: Engemann Handel + EI: Natürlich Eistert + ELM: BIONADE + EN: Provence Regime + EO: Eosta + ER: Euresis + Eb: Eisblümerl + Eh: Erhardt Meerrettichprodukte + Ei: Eiland + El: Kelterei Elm + En: Eichhorn + Er: Erdmannhauser Brezelfabrik + Es: Erntesegen + FB: Flensburger Brauerei + FE: Frucht-Express + FF: Schiffers + FI: Fromi GmbH + FL: Florian Kerzen + FR: I Frutti del Sole + FU: Future 3000 + Fh: Florahof + Fq: Fläming-Quelle + Fr: Frunet + Ft: Fontaine + GA: Bio-Gärtnerei Altglobsow + GG: Naturhof Günter Gaßmann + GH: Gutshöfe + GN: Nesse Gewürze + GO: Der Georgshof + GS: Gut Schmerwitz + GT: Gut Temmen + Gb: Grabower + Gl: Glaciar + Go: Golden Temple + Gr: Grützdorfer + Gw: Gwidon Zastawa + Gä: Gärtnerei am Bauerngut + GÖ: Stadtgut Görlitz + HA: Haaner Felsenquelle + HB: Hof Bockum + HF: Hühnerhof Falkenthal + HK: Heinz Ketchup + HM: Hof Marienhöhe + HO: Hoffmann + HS: Obstbau H. Schalkau + Ha: Hake + Hc: Hoch Oblatenfabrik + He: Hennicke + Hk: Natur Obsthof Hauke + Hl: Heidehof + Ho: Holle + Hu: Humanopolis + Hü: Hütterman + IC: Japan Grüntee + IN: Isola della Natura + IOC: IOC + IS: Isana + Ib: Iberia + Il: Il Nuraghe + Is: ISANA + JH: Beerenobst + JS: Juers Fruchtchips + Je: Jelitta Käse + KD: Kristdyn + KG: Kräuter Gut + KK: 74271 + KN: Öko-Gartenbau + KP: Kräutergarten Pommerland + Ka: Kanne + Kg: Karg Brotgenuß + Kä: Kärrners + Kö: Obsthof König + LB: Lammsbräu + LE: LEEB Schaf- und Ziegenmolkerei + LI: Legend Organics + LM: LeMar + LS: La Selva + La: Lahmann + Lb: Lebensbaum + Le: Leuchtenberg Sauerkrautfabrik + Lh: Lindenhof + Li: Lima Belgien + Lk: Landkrone + Ln: Land in Sicht + Ls: Lubs GmbH + Lu: Luvos Heilerde + Lw: Gärtnerei Löwenzahn + MA: Mack + MB: Mabutake + ME: Martin Evers + MH: Märkische Heide + MI: Martin Ibele + MII: Katal. Olivenöl + ML: Märkisches Landbrot + MM: Bioland Imkerei + MT: Maintal + MV: MegaVega Limited + MY: Mayka Brezel + Ma: Marschland + Mg: MIDGARD + Mh: Melchhof + Mn: Mosna + Mo: Mosaikwerkstätten + My: MAYKA, Brezelfabrik + Mü: Hofmolkerei GmbH Münchehofe + MÖ: Märkischer Ökovertrieb + NE: Natürlich Eistert + NM: + NO: Nürnberger Bio Originale + NQ: Pineo Wasser + Na: NATURATA + Nt: Natumi + OTC: OTC + Od: ODIN Holland + PB: Peter Bentele + PG: Pilzgarten + PH: Biopilzhof + PM: Pinkus Müller + PN: Pro Natura + Pi: Piding + Pt: Port International + QB: Panettoncino + RB: Rother Bräu + RP: Rheinsberger Preussenquelle + RS: rosmarin BIOBACK + RZ: Ranch Zempow + Ra: Raab + Rb: Rabenhorst + Re: Rebgarten + Rg: Rosengarten + Rh: Rotenhäusler + Ro: Geflügelhof Robert + RoL: Robert´s LOSE + Rt: Rottstock + Rö: Römerquelle + SB: Sabines Bauernhof + SBP: Stiftelsen Bananen + SC: Sommer & Co. + SF: Sprossen + SH: Spreewälder Hirse + SI: SINFO + SK: Spargelhof Kreienbaum + SL: St. Leonhardsquelle + SM: Seenlan Müritz + SO: Sonett + SR: Sprossenmanufaktur GbR + STN: Sonnentor + SV: SANTAVERDE ALOE VERA + Sa: Salamita + Sb: Hans Hermann Soetbeer + Sc: Schulz-Deetz + Sch: Hof Schütte + Sd: Savid + Se: Sekem, Ägypten + Sf: Sauerkonservenfabrik Schweizer + Sh: Kombucha + Si: Land in Sicht + Sk: Schock Ludwigsburg + Sm: Schramm + So: Sophienhof + Sp: Spielberger + Sr: Sanmar + St: Steck Senf + StB: Stralsunder Brauerei + Su: Sun,Backwaren aus Norwegen + Sv: Sunval demeter-Produkte + Sw: Szilleweit + Sy: Synanon + Sz: Schrozberg + Sü: Südasien + TB: Team Blue + TF: Terra Frischdienst + TN: Tofu Nagel + TR: Teltower Rübchen + Ta: Tarpa + Te: Teutoburger Ölmühle + Ti: Tiedemann + Tm: Tillmann + Tr: tri d´Aix + Tt: Tautropfen + Tö: Töpfer Rohrzucker + UK: Udo Kolm Bananen + UL: Gärtnerei Ulenburg + UV: Uni-Vert + Ul: Ulenburg Bioland Gemüse + VA: Kleingenossenschaft VENUSTA + VD: V & D + VE: Vega e.K. + VG: Biolog. Vollwertgetränke + VT: Vogt + VV: Vallé Käse + Vi: Viana Tofu + VlV: Vivo Lo Vin + Vo: Voelkel + WB: Weber + WD: Werder Feinkost GmbH + WH: Weide-Hardebek + WK: BioCompany Kaffee + WL: Wendland Storchenmilch + WP: Plosewasser + WR: Speickwerke + WS: Weingut Sander + Wa: Watzkendorf + We: Wendts + Wh: Molkerei Weißenhorn + Wz: Werz Heidenheim + ZA: Bio-Center Zann + ZF: Obsthof zum Felde + ZG: Zwergenwiese + ZI: Biolandhof Zielke + ZK: Ziegenkäserei Karolinenhof + ZP: Bioland Ranch Zempow + ZW: Zellertaler Wein + bF: bio Frische + bi: biosanica + dB: ÖMA-d`Beers, Kisslegg im Algäu + eu: felicia + fa: familia Müsli + ha: Hawlik + vL: v.d.Linden + öG: Öko-Gartenbau + öh: ökohum Blumenerde + ÖL: Öko-Line + ÖS: Ölmühle Solling \ No newline at end of file diff --git a/lib/foodsoft_article_import/odin.rb b/lib/foodsoft_article_import/odin.rb new file mode 100644 index 0000000..bb9992d --- /dev/null +++ b/lib/foodsoft_article_import/odin.rb @@ -0,0 +1,89 @@ +# Article import for De Nieuw Band XML file +# +# Always contains full assortment, including recently outlisted articles. +# To make sure we don't keep old articles when a number of updates was missed, +# +OUTLIST+ is set to +true+ to remove articles not present in the file. +# +require 'nokogiri' + +module FoodsoftArticleImport + class Odin + + NAME = "De Nieuwe Band (XML)" + OUTLIST = true + OPTIONS = {}.freeze + + # parses a string or file + def self.parse(file, custom_file_path: nil, **opts) + custom_file_path ||= nil + xml = File.open(file) + doc = Nokogiri.XML(xml, nil, nil, + Nokogiri::XML::ParseOptions::RECOVER + + Nokogiri::XML::ParseOptions::NONET + + Nokogiri::XML::ParseOptions::COMPACT # do not modify doc! + ) + self.load_codes(custom_file_path) + doc.search('product').each.with_index(1) do |row, i| + # create a new article + unit = row.search('eenheid').text + unit = case(unit.strip) + when '' then 'st' + when 'stuk' then 'st' + when 'g' then 'gr' # need at least 2 chars + when 'l' then 'ltr' + else unit + end + inhoud = row.search('inhoud').text + inhoud.to_s.strip.empty? or (inhoud.to_f-1).abs > 1e-3 and unit = inhoud.gsub(/\.0+\s*$/,'') + unit + deposit = row.search('statiegeld').text + deposit.to_s.strip.empty? and deposit = 0 + category = [ + @@codes[:indeling][row.search('indeling').text.to_i], + @@codes[:indeling][row.search('subindeling').text.to_i] + ].compact.join(' - ') + + status = row.search('status').text == "Actief" ? nil : :outlisted + article = {} + unless row.search('bestelnummer').text == "" + article = {:order_number => row.search('bestelnummer').text, + #:ean => row.search('eancode').text, + :name => row.search('omschrijving').text, + :note => row.search('kwaliteit').text, + :manufacturer => row.search('merk').text, + :origin => row.search('herkomst').text, + :unit => unit, + :price => row.search('prijs inkoopprijs').text, + :unit_quantity => row.search('sve').text, + :tax => row.search('btw').text, + :deposit => deposit, + :article_category => category} + end + yield article, status, i + end + end + + private + + @@codes = Hash.new + + def self.load_codes(custom_file_path=nil) + @gem_lib = File.expand_path "../../", __FILE__ + dir = File.join @gem_lib, 'foodsoft_article_import' + begin + @@codes = YAML::load(File.open(File.join(dir, "dnb_codes.yml"))).symbolize_keys + if(custom_file_path) + custom_codes = YAML::load(File.open(custom_file_path)).symbolize_keys + custom_codes.keys.each do |key| + if @@codes.keys.include?(key) + custom_codes[key] =custom_codes[key].merge @@codes[key] + end + @@codes = @@codes.merge custom_codes + end + end + @@codes + rescue => e + raise "Failed to load dnb_codes: #{dir}/dnb_codes.yml: #{e.message}" + end + end + end +end \ No newline at end of file diff --git a/lib/foodsoft_article_import/utf8_encoder.rb b/lib/foodsoft_article_import/utf8_encoder.rb new file mode 100644 index 0000000..0715a7e --- /dev/null +++ b/lib/foodsoft_article_import/utf8_encoder.rb @@ -0,0 +1,9 @@ +module UTF8Encoder + def self.clean(string) + if string.nil? + string + else + string.encode('UTF-8') + end + end +end diff --git a/lib/foodsoft_article_import/version.rb b/lib/foodsoft_article_import/version.rb new file mode 100644 index 0000000..e4b8866 --- /dev/null +++ b/lib/foodsoft_article_import/version.rb @@ -0,0 +1,3 @@ +module FoodsoftArticleImport + VERSION = '1.0.0' +end \ No newline at end of file diff --git a/spec/files/bioromeo/bioromeo_flawless.csv b/spec/files/bioromeo/bioromeo_flawless.csv new file mode 100644 index 0000000..950d3dd --- /dev/null +++ b/spec/files/bioromeo/bioromeo_flawless.csv @@ -0,0 +1,12 @@ +,,,,,, +,Bestelling plaatsen via info@bioromeo.nl,,,,, +,Op maandag bestellen.,,,,, +,Uitleveren. ,,,,, +Zwijnsweg 5,Prijzen blablabla,,,,, +8307 PP Ens,"En nog meer wat €0,- kosten",,,,, +skal 012345,bla in overleg,,,,, +Vragen: bel iemand 01-23456789,,,,,, +,,,,,, +Artnr.,Product,Skal,Demeter, Prijs per eenh. , Prijs per colli ,Bestelling,opm. +,"Aardappels ""nieuwe oogst""",,,,,, +1,Wilde aardappels - 5kg,1234,123456, € 1.00 , € 5.00 ,,Kopervrij diff --git a/spec/files/bnn/bnn_bad_encoding.BNN b/spec/files/bnn/bnn_bad_encoding.BNN new file mode 100644 index 0000000..0b7cb14 --- /dev/null +++ b/spec/files/bnn/bnn_bad_encoding.BNN @@ -0,0 +1,3 @@ +BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1 +64721;A;;;4280001958081;4280001958203;Greek Dressing - Kräuter Mix;Oregano, Basilikum und Minze;;;med;;GR;C%;DE-ÖKO-001;120;1302;10;55;;1;6 x35g;6;35g;1;N;930190;99260;;1,41;;;;1;;;4,49;2,89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;; +;;99 \ No newline at end of file diff --git a/spec/files/bnn/bnn_flawless.BNN b/spec/files/bnn/bnn_flawless.BNN new file mode 100644 index 0000000..1c5ac61 --- /dev/null +++ b/spec/files/bnn/bnn_flawless.BNN @@ -0,0 +1,3 @@ +BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1 +64721;X;;;4280001958081;4280001958203;Greek Dressing - Kr„uter Mix;Oregano, Basilikum und Minze;;;med;;GR;C%;DE-™KO-001;120;1302;10;55;;1;6 x35g;6;35g;1;N;930190;99260;;1,41;;;;1;;;4,49;2,89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;; +;;99 \ No newline at end of file diff --git a/spec/files/bnn/bnn_flawless_category.BNN b/spec/files/bnn/bnn_flawless_category.BNN new file mode 100644 index 0000000..6f09dbf --- /dev/null +++ b/spec/files/bnn/bnn_flawless_category.BNN @@ -0,0 +1,3 @@ +BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1 +64721;A;;;4280001958081;4280001958203;Greek Dressing - Kr„uter Mix;Oregano, Basilikum und Minze;;;med;;GR;C%;DE-™KO-001;120;4000;10;55;;1;6 x35g;6;35g;1;N;930190;99260;;1,41;;;;1;;;4,49;2,89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;; +;;99 \ No newline at end of file diff --git a/spec/files/bnn/bnn_flawless_special.BNN b/spec/files/bnn/bnn_flawless_special.BNN new file mode 100644 index 0000000..0f285f6 --- /dev/null +++ b/spec/files/bnn/bnn_flawless_special.BNN @@ -0,0 +1,3 @@ +BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1 +64721;A;;;4280001958081;4280001958203;Greek Dressing - Kr„uter Mix;Oregano, Basilikum und Minze;;;med;;GR;C%;DE-™KO-001;120;1302;10;55;;1;6 x35g;6;35g;1;N;930190;99260;;1,41;;;;1;;;4,49;2,89;J;;2;3;;;;;;;;;;;;;;;;;;;A;;20230101;20230201;;Kg;28,571;; +;;99 diff --git a/spec/files/bnn/bnn_missing_entries.BNN b/spec/files/bnn/bnn_missing_entries.BNN new file mode 100644 index 0000000..6c8dafe --- /dev/null +++ b/spec/files/bnn/bnn_missing_entries.BNN @@ -0,0 +1,3 @@ +BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1 +64721;A;;;4280001958081;4280001958203;Greek Dressing - Kr„uter Mix;Oregano, Basilikum und Minze;;;HDE;;GR;C%;DE-™KO-001;120;1100;10;55;;1;6 x35g;6;35g;1;N;;99260;;1,41;;;;1;;;4,49;2,89;J;;;;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;; +;;99 diff --git a/spec/files/bnn/bnn_missing_order_number.BNN b/spec/files/bnn/bnn_missing_order_number.BNN new file mode 100644 index 0000000..aadcb9b --- /dev/null +++ b/spec/files/bnn/bnn_missing_order_number.BNN @@ -0,0 +1,3 @@ +BNN;3;0;Naturkost Nord, Hamburg;T;Angebot Nr. 0922;EUR;20220905;20221001;20220825;837;1 +;A;;;4280001958081;4280001958203;Greek Dressing - Kr„uter Mix;Oregano, Basilikum und Minze;;;HDE;;GR;C%;DE-™KO-001;120;1100;10;55;;1;6 x35g;6;35g;1;N;;99260;;1,41;;;;1;;;4,49;2,89;J;;;;;;;;;;;;;;;;;;;;;;A;;;;;Kg;28,571;; +;;99 diff --git a/spec/files/custom_codes.yml b/spec/files/custom_codes.yml new file mode 100644 index 0000000..5e9020f --- /dev/null +++ b/spec/files/custom_codes.yml @@ -0,0 +1,8 @@ +# BNN Codes +category: + "4000": "Schuhe" +additional: + "additional": "value" +indeling: + 11: Test Indeling + 111: Test Subindeling \ No newline at end of file diff --git a/spec/files/foodsoft/foodsoft_flawless.csv b/spec/files/foodsoft/foodsoft_flawless.csv new file mode 100644 index 0000000..a9a94c2 --- /dev/null +++ b/spec/files/foodsoft/foodsoft_flawless.csv @@ -0,0 +1,3 @@ +status;number;name;note;manufacturer;origin;unit ;clear price;tax;deposit;unit quantity;scale quantity;scale price;category +;1;product;bio;someone;eu;1 kg;1.23;6;0;10;;;coolstuff +;12;other product;bio;someone;eu;2 kg;3.45;6;0;10;;;coolstuff \ No newline at end of file diff --git a/spec/files/foodsoft/foodsoft_generate_order_number.csv b/spec/files/foodsoft/foodsoft_generate_order_number.csv new file mode 100644 index 0000000..a50dde3 --- /dev/null +++ b/spec/files/foodsoft/foodsoft_generate_order_number.csv @@ -0,0 +1,3 @@ +status;number;name;note;manufacturer;origin;unit ;clear price;tax;deposit;unit quantity;scale quantity;scale price;category +;;product;bio;someone;eu;1 kg;1.23;6;0;10;;;coolstuff +;;other product;bio;someone;eu;2 kg;3.45;6;0;10;;;coolstuff \ No newline at end of file diff --git a/spec/files/foodsoft/foodsoft_missing_entries.csv b/spec/files/foodsoft/foodsoft_missing_entries.csv new file mode 100644 index 0000000..560c11a --- /dev/null +++ b/spec/files/foodsoft/foodsoft_missing_entries.csv @@ -0,0 +1,2 @@ +status;number;name;note;manufacturer;origin;unit ;clear price;tax;deposit;unit quantity;scale quantity;scale price;category +;12;product;bio;;eu;1 kg;1.23;;0;10;;;coolstuff \ No newline at end of file diff --git a/spec/files/odin/odin_flawless.xml b/spec/files/odin/odin_flawless.xml new file mode 100644 index 0000000..5b5a28f --- /dev/null +++ b/spec/files/odin/odin_flawless.xml @@ -0,0 +1,75 @@ + + + +1039 +1.08 +Estafette Associatie C.V. +Geldermalsen + + +8719325207668 +nucli rose +Nucli rose + +0 +0 +0 +750 +g +Stuk +0 +NELEMAN +Biologisch + + +ES + +21 +1017515 +0109 +6 +Actief +druiven* +0 +0 +2 +2 +0 +0 +0 +2 +2 +0 +2 +0 +2 +0 +2 +2 +2 +2 +1 +0 +2 +0 +2 +2 + + + +0 +0 +0 +0 +1 + +2 +0 + +adviesprijs +2022-08-18 +4.52 +7.95 + + + \ No newline at end of file diff --git a/spec/files/odin/odin_flawless_custom_category.xml b/spec/files/odin/odin_flawless_custom_category.xml new file mode 100644 index 0000000..460da24 --- /dev/null +++ b/spec/files/odin/odin_flawless_custom_category.xml @@ -0,0 +1,77 @@ + + + +1039 +1.08 +Estafette Associatie C.V. +Geldermalsen + + +8719325207668 +nucli rose +Nucli rose + +0 +0 +0 +750 +g +Stuk +0 +NELEMAN +Biologisch + + +ES + +21 +1017515 +0109 +11 +111 +6 +Actief +druiven* +0 +0 +2 +2 +0 +0 +0 +2 +2 +0 +2 +0 +2 +0 +2 +2 +2 +2 +1 +0 +2 +0 +2 +2 + + + +0 +0 +0 +0 +1 + +2 +0 + +adviesprijs +2022-08-18 +4.52 +7.95 + + + \ No newline at end of file diff --git a/spec/files/odin/odin_missing_entries.xml b/spec/files/odin/odin_missing_entries.xml new file mode 100644 index 0000000..5089b91 --- /dev/null +++ b/spec/files/odin/odin_missing_entries.xml @@ -0,0 +1,75 @@ + + + +1039 +1.08 +Estafette Associatie C.V. +Geldermalsen + + +8719325207668 +nucli rose +Nucli rose + +0 +0 +0 +750 + +Stuk +0 + +Biologisch + + +ES + +21 +1017515 +0109 +6 +Non Actief +druiven* +0 +0 +2 +2 +0 +0 +0 +2 +2 +0 +2 +0 +2 +0 +2 +2 +2 +2 +1 +0 +2 +0 +2 +2 + + + +0 +0 +0 +0 +1 + +2 +0 + +adviesprijs +2022-08-18 +4.52 +7.95 + + + \ No newline at end of file diff --git a/spec/files/odin/odin_missing_order_number.xml b/spec/files/odin/odin_missing_order_number.xml new file mode 100644 index 0000000..d43a943 --- /dev/null +++ b/spec/files/odin/odin_missing_order_number.xml @@ -0,0 +1,75 @@ + + + +1039 +1.08 +Estafette Associatie C.V. +Geldermalsen + + +8719325207668 +nucli rose +Nucli rose + +0 +0 +0 +750 +g +Stuk +0 +NELEMAN +Biologisch + + +ES + +21 +1017515 + +6 +Actief +druiven* +0 +0 +2 +2 +0 +0 +0 +2 +2 +0 +2 +0 +2 +0 +2 +2 +2 +2 +1 +0 +2 +0 +2 +2 + + + +0 +0 +0 +0 +1 + +2 +0 + +adviesprijs +2022-08-18 +4.52 +7.95 + + + \ No newline at end of file diff --git a/spec/lib/bioromeo/foodsoft_article_import_bioromeo_spec.rb b/spec/lib/bioromeo/foodsoft_article_import_bioromeo_spec.rb new file mode 100644 index 0000000..63bd522 --- /dev/null +++ b/spec/lib/bioromeo/foodsoft_article_import_bioromeo_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' +require_relative '../../../lib/foodsoft_article_import' + +describe FoodsoftArticleImport do + + files_path = File.expand_path '../../files', __dir__ + bioromeo_files_path = File.join(files_path, 'bioromeo') + + dummy_article = {:order_number=>"1", :name => "Wilde aardappels",:article_category => "Aardappels \"nieuwe oogst\"", :deposit => 0, :manufacturer => nil, :origin => "Noordoostpolder, NL", :price => 5.0, :tax => 6, :unit => "5kg", :unit_quantity => 1, :note => "Skal 1234; 123456; Demeter 123456; (Kopervrij)"} + + + empty = {} + + context "bioromeo" do + it 'parses file correctly with type parameter bioromeo' do + FoodsoftArticleImport.parse(File.open(File.join(bioromeo_files_path, 'bioromeo_flawless.csv')), type: 'bioromeo') do |new_attrs, status, line| + if new_attrs==nil + next + end + expect(new_attrs).to eq dummy_article + end + end + end +end diff --git a/spec/lib/bnn/foodsoft_article_import_bnn_spec.rb b/spec/lib/bnn/foodsoft_article_import_bnn_spec.rb new file mode 100644 index 0000000..42c60ef --- /dev/null +++ b/spec/lib/bnn/foodsoft_article_import_bnn_spec.rb @@ -0,0 +1,71 @@ +require 'spec_helper' +require_relative '../../../lib/foodsoft_article_import' + +describe FoodsoftArticleImport do + + files_path = File.expand_path '../../files', __dir__ + bnn_files_path = File.join(files_path, 'bnn') + + dummy_article = { name: 'Greek Dressing - Kräuter Mix', order_number: '64721', note: 'Oregano, Basilikum und Minze', + manufacturer: 'Medousa, Griechenland Importe', origin: 'GR', article_category: 'Kräutermischungen', unit: '35g', price: '2,89', tax: 7.0, unit_quantity: '6'} + + article = dummy_article.merge({ deposit: 0.08}) + article_special = article.merge(note: 'Sonderpreis: 2,89 von 20230101 bis 20230201') + + article_2 = dummy_article.merge({manufacturer: nil, article_category: nil}) + + article_custom_code = article.merge(article_category: "Schuhe") + + empty = {} + + context 'bnn' do + it 'parses bnn file correctly without type parameter' do + FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless.BNN'))) do |new_attrs, status, line| + expect(new_attrs).to eq article + expect(status).to eq :outlisted + end + end + it 'parses file correctly with type parameter' do + FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless.BNN')), type: 'bnn') do |new_attrs, status, line| + expect(new_attrs).to eq article + expect(status).to eq :outlisted + end + end + it 'raises error wenn wrong type (except dnb_xml) specified' do + expect{FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless.BNN')),type: 'foodsoft')}.to raise_error(RuntimeError) + expect{FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless.BNN')),type: 'bioromeo')}.to raise_error(RuntimeError) + + expect(FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless.BNN')),type: 'dnb_xml')).to eq [] + end + it 'parses article with special correctly' do + FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless_special.BNN')), type: 'bnn') do |new_attrs, status, line| + expect(new_attrs).to eq article_special + expect(status).to eq :special + end + end + it 'parses missing entries correctly' do + FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_missing_entries.BNN')), type: 'bnn') do |new_attrs, status, line| + expect(new_attrs).to eq article_2 + expect(status).to eq nil + end + end + it 'skips rows without order_number' do + FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_missing_order_number.BNN')), type: 'bnn') do |new_attrs, status, line| + expect(new_attrs).to eq empty + end + end + it 'joins custom_codes file' do + custom_file_path = File.join(files_path, 'custom_codes.yml').to_s + FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_flawless_category.BNN')), custom_file_path: custom_file_path, type: 'bnn') do |new_attrs, status, line| + expect(new_attrs).to eq article_custom_code + end + end + it 'parses file with different encoding' do + #the bnn file is loaded with encoding ibm850. If file is not ibm850 encoded, some characters might look weird + FoodsoftArticleImport.parse(File.open(File.join(bnn_files_path, 'bnn_bad_encoding.BNN')), type: 'bnn') do |new_attrs, status, line| + expect(new_attrs[:order_number]).to eq("64721") + expect(new_attrs[:name]).to eq("Greek Dressing - Kräuter Mix") + end + end + end +end diff --git a/spec/lib/foodsoft/foodsoft_article_import_foodsoft_spec.rb b/spec/lib/foodsoft/foodsoft_article_import_foodsoft_spec.rb new file mode 100644 index 0000000..59b4404 --- /dev/null +++ b/spec/lib/foodsoft/foodsoft_article_import_foodsoft_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' +require_relative '../../../lib/foodsoft_article_import' + +describe FoodsoftArticleImport do + + files_path = File.expand_path '../../files', __dir__ + foodsoft_files_path = File.join(files_path, 'foodsoft') + + dummy_article = {:order_number=>"1", :name=>"product", :note=>"bio", :manufacturer=>"someone", :origin=>"eu", :unit=>"1 kg", :price=>"1.23", :tax=>"6", :unit_quantity=>"10", :article_category=>"coolstuff", :deposit=>"0"} + + + dummy_article_2 = {:order_number=>"12", :name=>"other product", :note=>"bio", :manufacturer=>"someone", :origin=>"eu", :unit=>"2 kg", :price=>"3.45", :tax=>"6", :unit_quantity=>"10", :article_category=>"coolstuff", :deposit=>"0"} + + articles=[dummy_article, dummy_article_2] + + dummy_article_3 = dummy_article.merge({ order_number: ":d8df298"}) + dummy_article_4 = dummy_article_2.merge({ order_number: ":1f37e39"}) + articles_number_generated= [dummy_article_3, dummy_article_4] + empty = {} + + context "foodsoft" do + it 'parses file correctly with type parameter foodsoft' do + count =0 + FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_flawless.csv')), type: 'foodsoft') do |new_attrs, status, line| + expect(new_attrs).to eq articles[count] + expect(status).to eq nil + count+=1 + end + end + it 'raises error wenn wrong type specified' do + expect{FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_flawless.csv')),type: 'bioromeo')}.to raise_error(Roo::HeaderRowNotFoundError) + expect(FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_flawless.csv')),type: 'odin')).to eq [] + + expect(FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_flawless.csv')),type: 'bnn')).to eq [] + end + it 'parses missing entries correctly' do + FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_missing_entries.csv')), type: 'foodsoft') do |new_attrs, status, line| + expect(status).to eq 'Error: unit, price and tax must be entered' + expect(new_attrs[:unit]).to eq "1 kg" + expect(new_attrs[:manufacturer]).to eq nil + end + end + it 'generates order numbers for articles without order number' do + count=0 + FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_generate_order_number.csv')), type: 'foodsoft') do |new_attrs, status, line| + expect(new_attrs).to eq articles_number_generated[count] + count+=1 + end + end + xit 'joins custom_codes file' do + custom_file_path = File.join(files_path, 'custom_codes.yml').to_s + FoodsoftArticleImport.parse(File.open(File.join(foodsoft_files_path, 'foodsoft_flawless_custom_category.csv')), custom_file_path: custom_file_path, type: 'foodsoft') do |new_attrs, status, line| + expect(new_attrs[:article_category]).to eq "Test Indeling - Test Subindeling" + end + end + end +end diff --git a/spec/lib/odin/foodsoft_article_import_odin_spec.rb b/spec/lib/odin/foodsoft_article_import_odin_spec.rb new file mode 100644 index 0000000..bdac2ae --- /dev/null +++ b/spec/lib/odin/foodsoft_article_import_odin_spec.rb @@ -0,0 +1,67 @@ +require 'spec_helper' +require_relative '../../../lib/foodsoft_article_import' + +describe FoodsoftArticleImport do + + files_path = File.expand_path '../../files', __dir__ + odin_files_path = File.join(files_path, 'odin') + + dummy_article = {:order_number=>"0109", :name=>"nucli rose", :note=>"Biologisch", :manufacturer=>"NELEMAN", :origin=>"ES", :unit=>"750gr", :price=>"4.52", :unit_quantity=>"6", :tax=>"21", :deposit=>"0", :article_category=>""} + + + empty = {} + + context "odin/dnb_xml" do + it 'parses file correctly with type parameter dnb_xml' do + FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless.xml')), type: 'dnb_xml') do |new_attrs, status, line| + expect(new_attrs).to eq dummy_article + expect(status).to eq nil + end + end + it 'parses file correctly with type parameter odin' do + FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless.xml')), type: 'odin') do |new_attrs, status, line| + expect(new_attrs).to eq dummy_article + expect(status).to eq nil + end + end + it 'raises error wenn wrong type specified' do + expect{FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless.xml')),type: 'foodsoft')}.to raise_error(RuntimeError) + expect{FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless.xml')),type: 'bioromeo')}.to raise_error(RuntimeError) + + expect{FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless.xml')),type: 'bnn')}.to raise_error(CSV::MalformedCSVError) + end + it 'parses missing entries correctly' do + FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_missing_entries.xml')), type: 'odin') do |new_attrs, status, line| + expect(status).to eq :outlisted + expect(new_attrs[:unit]).to eq "750st" + expect(new_attrs[:manufacturer]).to eq "" + end + end + it 'skips rows without order_number' do + FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_missing_order_number.xml')), type: 'odin') do |new_attrs, status, line| + expect(new_attrs).to eq empty + end + end + it 'joins custom_codes file' do + custom_file_path = File.join(files_path, 'custom_codes.yml').to_s + FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'odin_flawless_custom_category.xml')), custom_file_path: custom_file_path, type: 'odin') do |new_attrs, status, line| + expect(new_attrs[:article_category]).to eq "Test Indeling - Test Subindeling" + end + end + + xit 'parses dummy_article with special correctly' do + #TODO: find out whether there are special prices for odin files + FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'bnn_flawless_special.BNN')), type: 'bnn') do |new_attrs, status, line| + expect(new_attrs.manufacturer).to eq nil + expect(new_attrs.unit).to eq "750st" + end + end + xit 'parses file with different encoding' do + #the bnn file is loaded with encoding ibm850. If file is not ibm850 encoded, some characters might look weird + FoodsoftArticleImport.parse(File.open(File.join(odin_files_path, 'bnn_bad_encoding.BNN')), type: 'bnn') do |new_attrs, status, line| + expect(new_attrs[:order_number]).to eq("64721") + expect(new_attrs[:name]).to eq("Greek Dressing - Kräuter Mix") + end + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..03990c4 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,100 @@ +require 'simplecov' +SimpleCov.start +# This file was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode + config.disable_monkey_patching! + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end