|
| 1 | +This directory contains infrastructure/tooling/data concerning the ordering of drinks for the space. |
| 2 | + |
| 3 | +The primary aim is to be able to : |
| 4 | + |
| 5 | +- Have a place to store invoices |
| 6 | +- Have a way to have invoice-data be parseable |
| 7 | +- Have a way to have an analysis of each order (costs/income/etc) |
| 8 | +- Have a way to use the data to create informational graphs/overviews |
| 9 | + |
| 10 | + |
| 11 | +The structure of this directory is as follows: |
| 12 | + |
| 13 | +- order_info/ All INPUT files are located here |
| 14 | +- order_info/csv/ CSV files describing an order |
| 15 | +- order_info/source_material/ Original source-material of order documentation |
| 16 | +- order_info/order-summary A file containing order totals of each order (ex VAT, INC vat) |
| 17 | +- order_info/pricing-history-notes Lists changes in prices for drinks |
| 18 | +- utils/ Contains tools that do all the work |
| 19 | +- analysis_info/ Contains CSV files built by analysis tool |
| 20 | +- gnuplot_scripts/ Graphing tools <NOT WORKING YET> |
| 21 | +- archive/ Store random old stuff here. |
| 22 | + |
| 23 | +================================= |
| 24 | +Syntax/structure of files: |
| 25 | +================================= |
| 26 | + |
| 27 | +====== |
| 28 | +order_info/csv/order_* |
| 29 | +====== |
| 30 | + |
| 31 | +Filenames in order_info/csv is as follows: |
| 32 | + |
| 33 | +'order_$deliverydate-$invoicenumber' |
| 34 | + |
| 35 | +For example: order_20170327-17700810 |
| 36 | +This is an order delivered on 2017-03-27 with invoice 17700810 associated to it. |
| 37 | + |
| 38 | +The order_info/csv/ files have the following syntax: |
| 39 | + |
| 40 | +supplier|nme|amount_per_batch|batches|price_per_batch(ex vat)|sale_price |
| 41 | + |
| 42 | +The 'Suppler|Name' combo can be anything, but for existing products, please adhere to the list already used; added in appendix A at the end of this text-file. |
| 43 | + |
| 44 | +amount_per_batch = bottles per crate, in most cases. Single bottles or Statiegeld-crates have a amount_per_batch of 1 |
| 45 | +batches = Amount of crates |
| 46 | +price_per_batch(ex vat) = The price per crate, ex VAT, as listed on the invoice |
| 47 | +sale_price = The price 1 unit (bottle) is sold for in the space. |
| 48 | + |
| 49 | + |
| 50 | +====== |
| 51 | +order_info/source_material/order_* |
| 52 | +====== |
| 53 | + |
| 54 | +This directory contains (at least) a /pdfs dir that contains all the raw PDF's of the invoices, under their original name. |
| 55 | +There are symlinks in this directory pointing into the /pdfs/ dir that use the same filename-structure as described above for the orders_info/csv/ files. |
| 56 | + |
| 57 | +The purpose here is to be able to have a place to store raw invoices and be able to match each csv with it's original pdf afterwards and do an automatic sanity-check during analysis. |
| 58 | + |
| 59 | +====== |
| 60 | +order_info/order_summary |
| 61 | +====== |
| 62 | + |
| 63 | +This is is a csv file using | as a separator. |
| 64 | +It's purpose is to keep track of all the amounts paid for each order as listed on the invoice. |
| 65 | +The format is as follows: |
| 66 | + |
| 67 | +order_file|ex_vat|inc_vat |
| 68 | + |
| 69 | +An example would be: |
| 70 | +order_20160609-20154286|442.10|468.04 |
| 71 | + |
| 72 | +This entry implies that there is a order_info/csv/order_20160609-20154286 file and a /order_info/source_material/order_20160609-20154286 symlink that links to the PDF containing the invoice. The invoice listed that the EX VAT cost was 442.10 euro and the INC VAT cost was 468.04 for this order. |
| 73 | + |
| 74 | + |
| 75 | +====== |
| 76 | +analysis_info/order_* |
| 77 | +====== |
| 78 | + |
| 79 | +These files are created automatically and are the result of using the analysis tools to parse the order_info/csv files. |
| 80 | +The format of these files is an extension of the CSV format used for the order_info/csv files. |
| 81 | +There is an EXTRA line at the end of each of these CSV files which contains a special-format summary of the entire invoice. |
| 82 | + |
| 83 | + |
| 84 | +The first 6 fields are *copied* from the order_info/order* files. They are not modified in any way. |
| 85 | + |
| 86 | + |
| 87 | +supplier See above |
| 88 | +name "" |
| 89 | +batch_size "" |
| 90 | +batches "" |
| 91 | +price_per_batch(ex vat) "" |
| 92 | +sale_price "" |
| 93 | +price_per_batch(inc vat) This is price_per_batch(ex vat) multiplied by the VAT factor (default = 1.06) |
| 94 | +total_items batch_size * batches |
| 95 | +item_cost (inc vat) price of each bottle |
| 96 | +item_profit sale_price - item_cost = item_profit |
| 97 | +item_profit_percentage Same, expressed in percentage |
| 98 | +order_cost (inc vat) Cost of this product in this order, inc. vat |
| 99 | +order_income (inc vat) What we would expect to get in as income from this order if every sale is paid for |
| 100 | +order_profit (inc vat) Difference between total order_income and order_cost for this product |
| 101 | +order_profit_percentage The above, expressed as a percentage |
| 102 | +vat_factor The VAT factor used in the calculations of this particular item (default 1.06 for everything except statiegeld) |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | +An example: |
| 107 | +Club-Mate|Original|20|2|18.00|1.50|19.08|40|0.954|0.546|57.2327044025157|38.16|60|21.84|57.2327044025157|1.06 |
| 108 | + |
| 109 | +Which reads, in english: |
| 110 | +2 crates of Original Club-Mate bottles (20 bottles/crate), costing 18.00 per crate; sold for 1.50 a piece |
| 111 | + |
| 112 | +Each crate costs us 19.08 inc VAT. |
| 113 | +The total order is 40 bottles and each bottle costs us 0.954 inc vat |
| 114 | +This works out to 0.546 euro profit per bottle; which is %57.232... percent profit per bottle. |
| 115 | +The total order of this product costs us 38.16 inc VAT. |
| 116 | +Selling each of the 40 bottles for 1.50 should bring in 60 euros. |
| 117 | +The difference between cost/profit is 21.84 euros for this product, which is 57.232...% profit |
| 118 | +The VAT factor used to calculate the analysis is 1.06 |
| 119 | + |
| 120 | + |
| 121 | +The format of the last line in each of these files is a total summary of everything contained in the invoice and follows the same syntax as each individual item, but has some specifics and is best explained using an example: |
| 122 | + |
| 123 | +ORDER|TOTAL||38|651.6|1.58379888268156|693.456|716|0.968513966480447|0.615284916201117|63.5287602962553|1134|440.544|1.06 |
| 124 | + |
| 125 | +In plain english: |
| 126 | +The ORDER TOTAL of the whole invoice contained 38 batches (crates). |
| 127 | +It cost us 651.6 ex VAT (this should correspond to the TOTAL figure in the invoice) |
| 128 | +The average sales-price of each item 1.583.. |
| 129 | +The total cost INC vat was 693.45 (and should correspond to the TOTAL INC VAT on the invoice) |
| 130 | +The order contains 716 discrete items (batches * batch-size) |
| 131 | +The average COST per item is 0.9685... |
| 132 | +The average PROFIT per item is 0.61528... |
| 133 | +The avarage PROFIT PERCENTAGE is then 63.528..% |
| 134 | +If every item gets sold for it's sales_price, this order should result in 1134 of income |
| 135 | +The total pfofit on this order is then 440.544 |
| 136 | +The VAT factor supplied when running this tool was 1.06 |
| 137 | + |
| 138 | + |
| 139 | +================================= |
| 140 | +Processing a new invoice |
| 141 | +================================= |
| 142 | + |
| 143 | +1) Copy the invoice PDF to order_info/source_material/pdfs |
| 144 | +2) Make a symlink in order_info/source_material/ to the PDF of the invoice |
| 145 | + *use filename format as described above!* |
| 146 | +3) Add an entry in order_info/order_summary for the new order; add the ex VAT and inc VAT totals as listed in the invoice |
| 147 | +4) Create a new file in order_info/csv with the same file-name as used for the symlink. |
| 148 | + - For each entry in the invoice, create a line with the syntax as described above |
| 149 | + - Special care should be taken with 'Statiegeld' items: |
| 150 | + - A Statiegeld item always has a batch-size of 1 |
| 151 | + -- When we PAY a deposit on a crate, it has a POSITIVE cost/item |
| 152 | + -- When we get deposit RETURNED, it has a NEGATIVE cost/item. |
| 153 | + -- Do not use negative batch-sizes. |
| 154 | + -- Use Statiegeld|<description> combinations as listed in Appendix A whenever possible |
| 155 | + - NOTE: Statiegeld items are special in that they: |
| 156 | + -- Do not have VAT applied to them |
| 157 | + -- Do not count towards total ITEMS purchased. |
| 158 | + |
| 159 | +5) When finished, run ./parse_all.sh |
| 160 | +6) The analysis_info/ dir will now have been updated. |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | +================================= |
| 166 | +Appendix A: Commonly used supplier|name combos: |
| 167 | +================================= |
| 168 | +Bundaberg|Ginger |
| 169 | +Bundaberg|Pink Grapefruit |
| 170 | +Bundaberg|Root |
| 171 | +Charitea|Mate |
| 172 | +Club-Mate|Granat |
| 173 | +Club-Mate|Kraftstof |
| 174 | +Club-Mate|original |
| 175 | +Club-Mate|Original |
| 176 | +Club-Mate|Winter |
| 177 | +Cucumis|Komkommer-Basilicum |
| 178 | +Elixia|Chocolat |
| 179 | +Fentimans|Cherrytree Cola |
| 180 | +Fentimans|Herbal Tonic |
| 181 | +Flora Power|Mate |
| 182 | +Fritz|Apfelschorle |
| 183 | +Fritz|Cola |
| 184 | +Fritz|Druif |
| 185 | +Fritz|Koffie |
| 186 | +Fritz|Kola |
| 187 | +Fritz|Meloen |
| 188 | +Heldenpause|Peer-Melisse |
| 189 | +Lemonaid|Bloedsinaasappel |
| 190 | +Lemonaid|Limoen |
| 191 | +Lemonaid|Passievrucht |
| 192 | +Proviant|Citroen |
| 193 | +Proviant|Rabarber |
| 194 | +Sauer|Rhabarberschorle |
| 195 | +Statiegeld|krat20 |
| 196 | +Statiegeld|krat24 |
| 197 | +Statiegeld|krat_24 |
| 198 | +Statiegeld|krat_speciaal |
| 199 | +Statiegeld|retour_fles |
| 200 | +Statiegeld|retour_krat20 |
| 201 | +Statiegeld|retour_krat20_leeg |
| 202 | +Statiegeld|retour_krat24 |
| 203 | +Statiegeld|retour_krat24_leeg |
| 204 | + |
0 commit comments