webtranslateit-payday 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitattributes +1 -0
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/ci.yml +53 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +11 -0
- data/.rubocop_todo.yml +22 -0
- data/CHANGELOG.md +76 -0
- data/Gemfile +3 -0
- data/Guardfile +10 -0
- data/README.md +175 -0
- data/Rakefile +12 -0
- data/fonts/NotoSans-Bold.ttf +0 -0
- data/fonts/NotoSans-Regular.ttf +0 -0
- data/lib/generators/payday/setup/USAGE +30 -0
- data/lib/generators/payday/setup/setup_generator.rb +44 -0
- data/lib/generators/payday/setup/templates/invoice.rb +5 -0
- data/lib/generators/payday/setup/templates/line_item.rb +5 -0
- data/lib/generators/payday/setup/templates/migration.rb +26 -0
- data/lib/payday/config.rb +35 -0
- data/lib/payday/i18n.rb +3 -0
- data/lib/payday/invoice.rb +52 -0
- data/lib/payday/invoiceable.rb +87 -0
- data/lib/payday/line_item.rb +46 -0
- data/lib/payday/line_itemable.rb +12 -0
- data/lib/payday/locale/de.yml +23 -0
- data/lib/payday/locale/en.yml +22 -0
- data/lib/payday/locale/es.yml +22 -0
- data/lib/payday/locale/fr.yml +22 -0
- data/lib/payday/locale/nl.yml +22 -0
- data/lib/payday/locale/zh-CN.yml +21 -0
- data/lib/payday/pdf_renderer.rb +322 -0
- data/lib/payday/version.rb +5 -0
- data/lib/payday.rb +18 -0
- data/payday.gemspec +35 -0
- data/spec/assets/default_logo.png +0 -0
- data/spec/assets/svg.pdf +2501 -0
- data/spec/assets/testing.pdf +14178 -0
- data/spec/assets/testing_predefined_amount.pdf +0 -0
- data/spec/assets/tiger.svg +52 -0
- data/spec/invoice_spec.rb +244 -0
- data/spec/line_item_spec.rb +30 -0
- data/spec/pdf_renderer_spec.rb +11 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/support/asset_matchers.rb +26 -0
- metadata +297 -0
Binary file
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
+
<svg
|
4
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
5
|
+
xmlns:cc="http://web.resource.org/cc/"
|
6
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
7
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
9
|
+
xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
|
10
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
11
|
+
id="svg2"
|
12
|
+
sodipodi:version="0.32"
|
13
|
+
inkscape:version="0.43"
|
14
|
+
width="500"
|
15
|
+
height="500"
|
16
|
+
sodipodi:docbase="C:\Documents and Settings\clint\My Documents\Working\Chinese Zodiac"
|
17
|
+
sodipodi:docname="tiger.svg"
|
18
|
+
version="1.0">
|
19
|
+
<metadata
|
20
|
+
id="metadata7">
|
21
|
+
<rdf:RDF>
|
22
|
+
<cc:Work
|
23
|
+
rdf:about="">
|
24
|
+
<dc:format>image/svg+xml</dc:format>
|
25
|
+
<dc:type
|
26
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
27
|
+
</cc:Work>
|
28
|
+
</rdf:RDF>
|
29
|
+
</metadata>
|
30
|
+
<defs
|
31
|
+
id="defs5" />
|
32
|
+
<sodipodi:namedview
|
33
|
+
inkscape:window-height="540"
|
34
|
+
inkscape:window-width="749"
|
35
|
+
inkscape:pageshadow="2"
|
36
|
+
inkscape:pageopacity="0.0"
|
37
|
+
borderopacity="1.0"
|
38
|
+
bordercolor="#666666"
|
39
|
+
pagecolor="#ffffff"
|
40
|
+
id="base"
|
41
|
+
inkscape:showpageshadow="false"
|
42
|
+
inkscape:zoom="0.35539095"
|
43
|
+
inkscape:cx="372.04724"
|
44
|
+
inkscape:cy="413.62899"
|
45
|
+
inkscape:window-x="22"
|
46
|
+
inkscape:window-y="22"
|
47
|
+
inkscape:current-layer="svg2" />
|
48
|
+
<path
|
49
|
+
style="fill:#000000"
|
50
|
+
d="M 72.43032,426.80336 L 0,353.60672 L 0,249.87117 L 0,146.13561 L 73.06253,73.06781 L 146.12504,0 L 249.35846,0 L 352.59188,0 L 426.29594,72.93766 L 500,145.87532 L 500,249.87514 L 500,353.87496 L 426.93219,426.93747 L 353.86439,500 L 249.36251,500 L 144.86062,500 L 72.43032,426.80336 z M 396.70634,429.68394 C 424.11357,401.65166 446.69282,378.01562 446.88244,377.15941 C 447.07206,376.3032 446.92787,374.41003 446.56203,372.95236 C 445.94227,370.48309 442.3713,373.8271 394.27873,421.91275 L 342.66061,473.52342 L 249.99333,473.52342 L 157.32606,473.52342 L 91.90132,408.09279 L 26.47658,342.66215 L 26.47658,249.98237 L 26.47658,157.30259 L 39.71516,144.09339 C 47.96659,135.86029 53.36701,129.63201 54.05075,127.56022 C 54.92594,124.90839 55.69887,124.23625 57.87318,124.23625 C 60.11155,124.23625 69.33225,115.50117 109.47047,75.35642 L 158.34235,26.47658 L 249.86797,26.47658 L 341.39359,26.47658 L 407.32808,91.64585 L 473.26256,156.8151 L 473.80432,203.40756 C 474.25479,242.14803 474.70941,253.00413 476.50199,267.82612 C 477.68774,277.63048 479.06712,287.02457 479.56728,288.70188 C 480.12403,290.56895 480.51061,265.14652 480.56421,223.14228 L 480.65173,154.53303 L 413.31682,86.43149 L 345.98191,18.32994 L 250.13228,18.32994 L 154.28265,18.32994 L 86.30629,86.30061 L 18.32994,154.27128 L 18.32994,249.9943 L 18.32994,345.71731 L 85.79143,413.18452 L 153.25291,480.65173 L 250.06396,480.65173 L 346.875,480.65173 L 396.70634,429.68394 z M 389.25276,416.75543 C 416.55886,389.45359 438.9002,366.82233 438.9002,366.46372 C 438.9002,366.1051 436.72352,365.50098 434.06314,365.1212 C 431.40275,364.74144 426.82582,363.69097 423.89219,362.78684 C 420.95855,361.88272 418.38295,361.33947 418.16864,361.57963 C 417.32031,362.53024 393.29131,395.19347 388.78386,401.52313 C 383.17353,409.40151 370.4232,420.2631 363.67753,422.91039 C 356.86729,425.58301 346.94376,426.89851 343.47214,425.58888 C 341.90971,424.99948 338.00045,422.82724 334.78488,420.76168 C 329.68687,417.48691 328.93724,416.59128 328.92948,413.76588 C 328.91953,410.14802 330.12575,409.08613 341.14053,403.01597 C 351.24481,397.44758 364.00144,385.85058 369.81011,376.95258 C 372.55625,372.74592 374.44643,368.98832 374.01051,368.60235 C 373.57458,368.21638 364.74033,361.5734 354.37882,353.84016 C 334.08799,338.69625 324.36839,330.24607 318.73727,322.85357 C 315.1964,318.20513 315.14984,318.18269 311.60896,319.41677 C 309.64868,320.09999 306.78954,320.68484 305.25533,320.71646 C 303.72111,320.74807 300.09985,321.67293 297.20809,322.77172 C 294.31632,323.8705 283.19888,326.44214 272.50266,328.48646 C 261.80645,330.53077 250.90677,332.83951 248.28116,333.61698 C 245.65556,334.39444 242.79151,335.03055 241.9166,335.03055 C 241.0417,335.03055 240.32146,335.37424 240.31608,335.7943 C 240.31069,336.21436 239.1604,343.20265 237.75987,351.32383 C 234.66674,369.25977 232.54584,390.98033 231.69433,413.44196 C 230.97348,432.45681 229.79708,438.95197 226.19509,443.80433 C 221.80542,449.71781 216.8955,451.48894 204.68432,451.56379 C 198.80346,451.59984 192.73167,451.27691 191.19145,450.84618 C 188.63978,450.13259 188.39104,449.63371 188.39104,445.22948 C 188.39104,438.9905 190.7428,434.83391 196.9215,430.15245 L 201.8878,426.38959 L 201.17118,415.58787 C 200.77705,409.64692 199.53101,400.43279 198.4022,395.11202 C 197.2734,389.79124 195.97837,383.14664 195.52435,380.34623 C 194.09839,371.55094 188.46727,357.68473 184.54881,353.31982 C 182.55771,351.10186 180.64975,349.28717 180.3089,349.28717 C 178.17726,349.28717 174.4038,378.69758 173.46211,402.65108 C 172.65147,423.27145 172.55132,423.52283 160.5495,435.06682 C 151.71726,443.56212 147.71687,445.55944 141.26681,444.69431 L 137.1499,444.14211 L 148.2419,455.26862 L 159.3339,466.39511 L 249.46961,466.39511 L 339.60532,466.39511 L 389.25276,416.75543 z M 207.19435,444.28109 C 207.77554,441.96543 207.33778,441.05842 204.50434,438.70767 C 200.27193,435.19627 199.78929,435.19129 198.48435,438.64562 C 197.90249,440.18585 196.22424,442.70621 194.75488,444.24644 L 192.08332,447.04684 L 199.29175,447.04684 C 206.28433,447.04684 206.52098,446.96402 207.19435,444.28109 z M 151.27247,438.54275 C 153.20499,436.66591 154.77672,434.2601 154.7652,433.19652 C 154.75369,432.13293 152.70405,428.97149 150.21047,426.17108 L 145.67668,421.07943 L 140.04812,426.84527 C 132.8173,434.25244 132.80962,438.08751 140.02037,440.69126 C 145.23113,442.57284 147.58576,442.12324 151.27247,438.54275 z M 138.11895,425.25815 C 141.52722,419.62373 141.9229,418.19975 142.35218,410.02365 C 142.87932,399.98354 141.41378,386.79106 138.32004,373.72709 C 136.21592,364.84201 133.42951,343.009 133.4114,335.2652 C 133.39958,330.21869 126.35657,315.14222 110.22955,285.64155 C 95.95984,259.53837 91.03014,248.48923 89.10281,238.28921 C 88.20326,233.52851 87.20153,228.3109 86.87674,226.69449 C 86.27095,223.67953 80.20611,217.12684 70.1553,208.62798 L 64.58269,203.91584 L 60.60374,206.14338 C 58.17769,207.50157 54.81805,210.99928 51.99547,215.10547 C 49.44934,218.80946 47.20778,221.68164 47.01423,221.48809 C 46.82068,221.29454 46.22959,219.21023 45.70069,216.85629 C 44.62141,212.05276 45.14826,210.88176 52.23197,202.33947 L 56.28757,197.4488 L 50.80163,198.1563 C 47.78436,198.54544 44.2548,199.25693 42.95815,199.73741 C 41.66151,200.21788 39.37026,200.57161 37.8665,200.52347 L 35.13238,200.43594 L 37.67821,199.65873 C 41.70981,198.42793 48.38252,194.79978 49.8364,193.04795 C 51.02333,191.61778 50.41553,191.44271 44.16746,191.41506 C 36.23457,191.37996 36.91961,190.36572 46.27221,188.29891 L 52.32039,186.96233 L 48.81803,185.42612 C 45.3448,183.90268 45.33804,183.88698 48.00588,183.53765 C 50.46459,183.21569 50.75227,182.68645 51.34922,177.38699 C 52.74623,164.98476 55.76192,156.00953 60.14403,151.2121 C 61.96665,149.21673 61.9383,149.04484 59.01078,144.34137 C 57.35934,141.68809 56.00991,139.17217 56.01207,138.75046 C 56.01423,138.32875 50.9683,142.79532 44.79889,148.67617 L 33.58178,159.36864 L 33.53911,250 L 33.49644,340.63136 L 81.66675,388.14697 L 129.83707,435.66257 L 132.09816,433.56804 C 133.34176,432.41606 136.05112,428.6766 138.11895,425.25815 z M 357.68839,412.68447 C 359.89625,410.70859 359.98662,406.48539 357.88523,403.48524 C 355.91843,400.67724 354.87418,400.66888 348.65287,403.41127 C 339.26286,407.55046 337.42082,412.85432 344.70468,414.7794 C 348.01729,415.65491 355.7663,414.40459 357.68839,412.68447 z M 376.48882,406.82642 C 380.42855,406.03435 388.87246,398.05448 394.4727,389.83088 C 396.64145,386.6462 399.75419,380.23072 401.38991,375.57426 C 406.85423,360.01872 406.90055,362.00542 400.92628,355.69171 C 395.83581,350.31201 395.60058,349.81154 395.11202,343.32161 L 394.60285,336.55804 L 390.69321,347.08811 L 386.78355,357.61817 L 389.07449,360.05675 C 390.3345,361.39798 393.01035,363.34563 395.02079,364.38486 C 397.88433,365.86506 398.74569,366.97655 398.99708,369.51581 C 399.28106,372.38423 398.90395,372.93025 395.72021,374.2605 C 393.74144,375.08729 390.74432,375.76375 389.05995,375.76375 C 386.15063,375.76375 386.04848,375.90382 387.01758,378.56415 C 387.57865,380.10438 388.81714,382.85387 389.76978,384.67413 C 391.42037,387.82802 391.40902,388.15606 389.52862,391.64777 C 387.38949,395.61989 385.81167,397.03416 375.76375,403.98597 C 372.12322,406.50471 370.0611,408.32218 371.18126,408.02478 C 372.30143,407.72736 374.68983,407.18811 376.48882,406.82642 z M 221.01015,388.21404 C 220.26219,382.92239 219.28421,380.78753 214.96317,375.01387 C 210.57346,369.14845 202.64766,362.15791 202.64766,364.15163 C 202.64766,364.49624 204.05403,366.5539 205.77294,368.7242 C 209.0705,372.8877 212.83096,382.22467 212.83096,386.24879 C 212.83096,387.88787 214.18984,389.62474 217.15886,391.78053 C 219.53921,393.50889 221.58029,394.83382 221.69459,394.72482 C 221.80891,394.6158 221.50091,391.68596 221.01015,388.21404 z M 161.95251,363.82518 C 161.27011,360.77594 159.40977,356.37203 157.81839,354.03872 C 153.98544,348.41876 140.51685,335.18326 140.57578,337.09452 C 140.60122,337.91962 142.65383,340.65682 145.13714,343.17719 C 148.30119,346.38847 151.40272,351.48494 155.50224,360.20928 C 159.99133,369.7627 161.56637,372.27625 162.27273,371.01407 C 162.8432,369.9947 162.72143,367.26111 161.95251,363.82518 z M 460.70245,366.22166 L 464.48962,363.03462 L 460.48762,357.32944 C 456.49706,351.64057 456.49108,351.61726 458.39659,349.1828 L 460.30758,346.74134 L 462.5876,349.30644 C 463.84161,350.71723 466.07514,353.41641 467.55101,355.30459 L 470.2344,358.73766 L 472.01313,356.02298 C 473.71473,353.42602 473.70935,353.21714 471.88907,351.20576 C 470.02864,349.15 470.03131,349.06974 472.00945,347.59798 C 473.12217,346.77009 474.71996,345.67123 475.56008,345.15606 C 476.80743,344.39117 476.26825,343.43953 472.62007,339.96713 L 468.15257,335.71488 L 463.37358,340.71894 C 455.94578,348.49659 452.00631,351.54509 444.40547,355.39715 C 440.53745,357.35743 437.17693,359.0807 436.93765,359.22664 C 436.5254,359.47807 437.47611,360.41615 442.78923,365.00053 L 445.06764,366.96644 L 449.6214,362.49726 C 454.55916,357.65121 456.3137,359.09467 451.62933,364.14919 C 449.22955,366.73858 448.38132,369.63048 449.6496,370.89875 C 450.74897,371.99813 456.96279,369.3687 460.70245,366.22166 z M 373.00915,352.57284 C 377.4385,347.67847 391.32291,306.48816 395.39869,286.15071 C 395.6793,284.75051 396.64601,279.9389 397.54693,275.45825 C 399.61037,265.19602 399.59916,264.9057 397.23353,267.3399 C 392.46289,272.24881 383.95787,292.94144 378.41038,313.13646 C 376.87185,318.73727 374.78909,325.38187 373.78203,327.90224 C 372.77495,330.42261 371.63527,333.85947 371.24941,335.53971 C 370.86354,337.21996 368.68981,341.74265 366.41887,345.59012 C 363.13966,351.14588 362.57612,352.76687 363.6806,353.46659 C 366.0548,354.97072 371.29331,354.46883 373.00915,352.57284 z M 417.20248,351.102 C 423.43369,347.47206 438.91728,335.19492 445.26477,328.85106 C 450.68605,323.43287 452.86987,318.73727 449.96846,318.73727 C 448.0511,318.73727 426.62885,332.06734 419.43135,337.73908 C 413.8917,342.10443 407.33198,350.25787 407.33198,352.77808 C 407.33198,354.22514 413.69646,353.14441 417.20248,351.102 z M 209.14638,286.15071 C 209.24458,239.70984 208.17715,218.14726 205.22422,206.92154 L 203.96603,202.13849 L 203.26974,211.81263 C 202.88678,217.1334 202.47559,247.86408 202.35597,280.10303 L 202.13849,338.71932 L 204.68432,342.45919 L 207.23014,346.19906 L 208.13928,339.34189 C 208.6393,335.57045 209.09249,311.63442 209.14638,286.15071 z M 236.85234,331.73901 C 237.57545,330.46891 238.8868,327.87283 239.76645,325.96995 C 240.64609,324.06706 242.01862,322.00494 242.81651,321.38746 C 243.6144,320.76998 246.1299,316.63269 248.40652,312.19348 C 252.79533,303.6357 253.45962,299.20153 251.16058,293.81008 L 249.8672,290.77698 L 247.16555,298.39257 C 245.67964,302.58113 243.83513,308.27669 243.06664,311.04936 L 241.66939,316.09057 L 240.45731,304.93938 C 239.26628,293.98185 237.2045,287.75224 234.41466,286.68168 C 233.64356,286.38578 231.79408,286.98663 230.3047,288.01688 C 224.92309,291.73956 224.6964,291.7752 225.44801,288.78049 C 226.12944,286.0655 226.72932,282.11141 229.70932,260.69246 C 231.75746,245.97128 232.55886,230.13566 231.40787,227.12912 C 230.49763,224.75143 230.41265,224.82864 229.72684,228.65662 C 229.32956,230.87409 227.4017,239.33299 225.44271,247.45418 C 219.08358,273.8165 215.88595,291.23564 215.88595,299.5147 C 215.88595,303.72261 216.61822,304.66944 221.99593,307.41491 C 226.80366,309.8694 231.75527,317.37102 232.61294,323.49951 C 234.36513,336.01974 234.38889,336.06592 236.85234,331.73901 z M 480.65173,332.69364 C 480.65173,331.96841 478.32123,328.87523 475.47285,325.81991 C 472.52793,322.66104 468.29894,316.31135 465.66901,311.0998 C 463.1253,306.05906 459.62647,299.9545 457.89385,297.5341 L 454.74364,293.13337 L 453.51853,296.51577 C 449.57717,307.39758 455.00935,316.43455 473.52342,329.79594 C 479.69938,334.25304 480.65173,334.64018 480.65173,332.69364 z M 260.33509,325.31914 C 264.72501,322.34007 269.42634,317.35115 271.40634,313.57065 C 272.6366,311.22168 272.14729,304.39441 270.64072,302.88783 C 270.41349,302.66061 267.97223,306.24834 265.21568,310.86057 C 258.87974,321.46181 255.41202,327.90224 256.03993,327.90224 C 256.30875,327.90224 258.24158,326.73985 260.33509,325.31914 z M 179.8587,323.57434 C 182.02073,321.10485 182.91767,319.24334 186.11475,310.59063 C 188.76348,303.42198 193.48274,283.0214 193.48252,278.741 C 193.48226,273.9982 190.77253,260.30798 188.19685,252.03666 C 186.64414,247.05038 185.95826,242.15432 185.91434,235.74338 C 185.85269,226.74239 185.93805,226.41227 190.68546,217.29277 C 195.26823,208.4895 195.51935,207.58637 195.51935,199.90798 C 195.51935,191.57776 193.4843,183.27322 190.63836,179.98982 C 188.36902,177.37166 187.58751,177.76368 186.26297,182.18457 C 185.29555,185.41353 185.38362,187.54355 186.73126,193.51111 C 189.40788,205.36353 189.0212,208.41101 183.21217,221.24587 L 178.0333,232.68839 L 178.56966,241.85336 C 178.86465,246.89409 179.99953,253.76782 181.0916,257.12831 C 186.68998,274.35557 187.22542,285.98342 183.01414,298.87984 C 177.9026,314.5332 175.19813,325.86558 176.574,325.86558 C 177.2773,325.86558 178.75541,324.83452 179.8587,323.57434 z M 478.99082,306.51731 C 475.5919,299.79601 473.0702,298.09173 469.69474,300.23459 C 468.68796,300.87372 468.83406,302.2401 470.37362,306.58355 C 472.74066,313.26162 475.83376,319.27892 478.31271,322.02825 C 480.09535,324.00532 480.15096,323.87735 480.46788,317.06957 C 480.70849,311.90113 480.32388,309.15338 478.99082,306.51731 z M 135.62313,315.43784 C 138.53154,311.37269 146.59317,294.8928 147.70813,290.7332 C 148.15851,289.05295 152.47217,275.99635 157.29404,261.71853 C 162.11592,247.44071 166.70409,233.23501 167.48999,230.15031 C 175.16038,200.04348 175.90873,194.31864 173.77118,182.09913 C 171.57404,169.53891 168.84251,165.01228 160.81123,160.62224 L 156.14386,158.07096 L 154.31197,161.47258 L 152.48008,164.87419 L 156.70329,169.91834 C 164.60469,179.35571 165.43213,182.42167 165.3987,202.13849 C 165.38256,211.65988 164.90405,221.55899 164.33537,224.13654 C 162.78804,231.1497 156.30265,248.5622 150.53022,261.20163 C 147.71655,267.36253 144.83911,274.46538 144.13593,276.98574 C 143.43274,279.50611 141.00536,285.92159 138.74174,291.24236 C 133.83171,302.7837 129.98891,315.31894 130.75155,317.30636 C 131.61683,319.56125 133.07246,319.00294 135.62313,315.43784 z M 335.7279,307.02648 C 345.1648,291.29577 347.99311,285.92709 348.76104,282.28703 C 349.65007,278.07296 347.61328,269.17854 345.75925,269.17854 C 345.006,269.17854 344.62415,269.78954 344.91072,270.53632 C 345.19729,271.2831 344.89742,271.89409 344.24437,271.89409 C 343.59131,271.89409 343.33349,272.34148 343.67143,272.88828 C 344.00937,273.43508 343.64471,275.10615 342.86108,276.60177 L 341.43628,279.32109 L 340.79172,276.75293 C 340.43721,275.34044 339.66596,259.01086 339.07783,240.46496 C 338.1713,211.87893 337.70746,205.8028 336.03118,200.55559 C 332.97705,190.99533 328.27014,186.26152 320.3389,184.7736 C 316.65782,184.08303 315.03003,185.77724 318.20429,186.99532 C 319.88558,187.64049 325.75636,195.48741 328.49062,200.74408 C 332.20611,207.8872 336.04888,223.11241 336.04888,230.69023 C 336.04888,239.27615 335.16164,244.6004 333.86446,243.7987 C 332.70484,243.08202 326.92434,230.64455 325.86107,226.57841 C 325.4217,224.89817 324.3504,221.4613 323.48041,218.94094 C 322.61042,216.42057 320.89949,210.7341 319.67836,206.30435 C 317.15237,197.14116 312.5177,190.18449 306.53455,186.57539 L 302.68048,184.25057 L 308.16304,195.48769 C 311.17846,201.6681 313.64562,207.10819 313.64562,207.57678 C 313.64562,208.04537 315.95678,213.8033 318.78154,220.37218 C 325.09505,235.05405 331.31641,255.28932 333.02816,266.71003 C 334.56033,276.93253 333.73133,299.89636 331.6095,306.00815 C 330.14556,310.22492 328.40407,318.61561 329.17892,317.71894 C 329.42092,317.4389 332.36795,312.62729 335.7279,307.02648 z M 364.70116,308.4285 C 370.01636,294.5337 371.83679,288.70683 373.62292,279.87162 C 378.17518,257.35348 379.06285,216.18552 375.27706,203.15682 C 372.61292,193.9883 366.63316,188.55317 356.13516,185.75834 C 347.55343,183.47367 346.72406,183.84741 351.26732,187.95197 C 355.6053,191.87106 361.85259,202.50948 365.57825,212.32179 C 368.45616,219.90137 369.36601,239.42392 367.73764,258.6558 C 365.88492,280.53727 363.69895,302.97955 363.16853,305.5646 C 361.00036,316.13136 361.44018,316.95324 364.70116,308.4285 z M 312.95461,312.37271 C 315.1469,310.04755 319.61341,299.0191 323.36531,286.66722 C 326.45345,276.50052 326.97467,266.45678 324.54046,264.02256 C 323.30519,262.78729 322.81884,263.34297 321.05548,268.00427 C 319.92833,270.9838 318.3033,275.71283 317.44429,278.51324 C 316.58527,281.31365 314.94548,285.89613 313.8003,288.69654 C 312.65511,291.49695 310.72326,296.53768 309.50728,299.89817 C 308.29131,303.25866 306.92876,306.74501 306.47939,307.64561 C 305.92697,308.75275 306.3688,309.98953 307.84362,311.46435 C 310.35687,313.97761 311.28576,314.1427 312.95461,312.37271 z M 295.17981,302.02892 C 297.68842,294.23422 297.61219,293.26235 293.45487,280.04073 L 290.7332,271.38493 L 290.17171,290.7332 C 289.86289,301.37475 289.80529,310.67493 290.04369,311.40027 C 290.72099,313.46093 292.60962,310.01493 295.17981,302.02892 z M 422.36457,308.02461 C 425.31172,307.25339 428.15843,306.3533 428.6906,306.02441 C 429.22276,305.69551 433.65377,304.84959 438.53729,304.14459 C 454.26241,301.87447 449.72501,300.6167 423.67366,300.02441 C 418.43963,299.90541 417.98708,300.09659 415.7816,303.35833 C 412.90786,307.60838 412.61753,311.12814 415.22403,310.11768 C 416.20418,309.73772 419.41741,308.79584 422.36457,308.02461 z M 472.19041,294.04277 C 474.70316,290.16037 475.11347,286.49587 473.75823,280.04073 C 472.99391,276.4002 472.13486,272.73422 471.84923,271.89409 C 471.31662,270.32752 470.39356,271.21882 463.62498,279.83549 L 460.98648,283.19439 L 464.59844,286.9638 C 466.58502,289.03697 468.52022,291.76426 468.89888,293.02444 C 469.66521,295.57483 470.94299,295.97014 472.19041,294.04277 z M 458.43328,277.49491 C 460.16897,274.13442 462.6181,270.01018 463.87578,268.32994 C 468.89821,261.62007 470.57906,256.83755 470.2468,250.20255 C 470.02002,245.67378 469.6911,244.46553 469.0828,245.92668 C 468.61647,247.04684 467.60202,249.33809 466.82847,251.01833 C 458.62058,268.84704 454.18711,279.52717 453.65041,282.76399 C 452.86838,287.48046 453.81355,286.4392 458.43328,277.49491 z M 125.09458,276.77231 C 136.15702,259.90427 138.34785,256.06872 137.43961,255.15954 C 136.29602,254.01477 136.82757,253.40555 130.83496,262.72912 C 125.73796,270.65927 119.71877,278.69767 117.39693,280.67509 C 116.65845,281.30403 116.33713,282.55582 116.68288,283.45685 C 117.68866,286.07786 120.41013,283.91519 125.09458,276.77231 z M 444.12586,277.40212 C 442.58389,267.09498 440.15704,255.32483 434.27658,229.6334 C 432.23508,220.71422 427.92544,211.58398 423.09885,205.95272 C 418.88112,201.03183 406.66132,191.28681 407.52617,193.53385 C 407.83869,194.34584 413.83478,208.29939 420.85082,224.54175 C 427.86686,240.78411 433.92275,255.58387 434.30835,257.4301 C 434.69395,259.27633 436.83471,265.23356 439.0656,270.66839 C 441.29649,276.10322 443.37572,281.37001 443.68614,282.37236 C 444.78534,285.92183 445.01391,283.33819 444.12586,277.40212 z M 279.07185,269.60285 C 280.65359,261.22544 280.67818,244.44791 279.11725,238.62196 C 278.543,236.47866 277.40373,228.76782 276.58551,221.48676 C 275.38593,210.81195 275.33045,206.76954 276.29898,200.611 L 277.50011,192.97352 L 280.22782,199.0835 C 281.72807,202.44399 285.32241,210.42712 288.21527,216.82379 C 295.13603,232.1269 296.94475,238.05868 297.86308,248.46421 C 298.36721,254.17656 299.44988,258.84274 301.05282,262.21166 L 303.47938,267.31161 L 303.00402,254.07332 C 302.23588,232.68098 297.67215,212.05851 290.0242,195.42039 C 285.51871,185.6187 286.92323,186.23851 274.56667,188.59896 L 268.58344,189.74192 L 269.20531,200.01352 C 269.54733,205.66291 270.08678,218.07536 270.40409,227.59674 C 270.72141,237.11813 271.43262,249.03259 271.98456,254.07332 C 273.12662,264.50343 275.8221,276.98574 276.93235,276.98574 C 277.3424,276.98574 278.30518,273.66344 279.07185,269.60285 z M 347.25051,266.74234 C 347.25051,266.14921 346.79226,265.94713 346.23218,266.29328 C 345.6721,266.63943 345.21385,267.12473 345.21385,267.37171 C 345.21385,267.6187 345.6721,267.82077 346.23218,267.82077 C 346.79226,267.82077 347.25051,267.33548 347.25051,266.74234 z M 253.55563,263.38392 C 253.55094,262.18367 252.66133,251.78327 251.57872,240.27193 C 248.28425,205.24196 245.40695,190.94398 241.03596,187.88242 C 238.8016,186.31742 229.61192,185.74413 228.7845,187.11813 C 228.53155,187.53819 229.91132,191.30728 231.85068,195.49388 C 233.79003,199.68049 235.6155,204.4921 235.90726,206.18634 C 236.19903,207.8806 237.52146,212.70367 238.846,216.90428 C 240.17054,221.10489 242.17253,229.39551 243.29486,235.32788 C 244.41719,241.26025 246.22916,249.50873 247.32149,253.65782 C 248.4138,257.80691 249.58256,262.44564 249.91872,263.96609 C 250.64852,267.26698 253.56897,266.79949 253.55563,263.38392 z M 407.23507,243.89002 C 407.34003,232.08942 404.67676,214.77481 402.22273,211.30346 C 401.82678,210.74338 401.19412,208.99442 400.81682,207.41689 C 400.01257,204.05424 389.85266,193.59298 385.43788,191.5818 C 383.75764,190.81635 381.58096,189.78142 380.60081,189.28192 C 379.62067,188.78244 378.81874,188.58868 378.81874,188.85131 C 378.81874,189.11396 381.26003,194.04402 384.24383,199.807 C 392.62119,215.98722 399.48345,235.23924 403.94969,255.09165 L 405.78246,263.23829 L 406.468,258.14664 C 406.84506,255.34623 407.19023,248.93075 407.23507,243.89002 z M 115.17008,247.51906 C 116.34951,242.2698 114.96591,239.75122 112.97652,243.52611 C 112.2807,244.84643 111.43631,246.1558 111.1001,246.43585 C 110.76388,246.71589 108.83881,248.81813 106.82215,251.10751 C 103.84942,254.48224 103.24464,255.87735 103.62653,258.47931 L 104.09756,261.68864 L 109.13249,256.83506 C 112.86416,253.23782 114.42697,250.82642 115.17008,247.51906 z M 460.60325,249.10894 C 465.3078,243.59296 466.38748,240.85192 466.3913,234.41459 C 466.39474,228.62838 466.0046,227.42126 462.44193,222.19463 C 456.37786,213.29832 445.50396,205.21857 431.26273,199.02721 C 429.0224,198.05323 426.29098,196.80136 425.19289,196.2453 C 424.09481,195.68922 425.8509,198.16244 429.09532,201.74136 C 432.33975,205.32027 437.0332,211.10036 439.52521,214.58599 C 444.38922,221.38936 452.1313,239.50693 452.1497,244.12906 C 452.15587,245.67783 452.44691,248.67557 452.79648,250.79069 L 453.43205,254.63638 L 456.09485,252.95463 C 457.55938,252.02966 459.58817,250.29911 460.60325,249.10894 z M 105.45445,242.86827 C 108.29875,239.39718 109.32379,237.10732 109.67105,233.44872 L 110.12985,228.61507 L 108.03491,231.1609 C 106.88269,232.5611 105.65727,234.62322 105.31176,235.74338 C 104.96624,236.86354 103.08279,239.28527 101.1263,241.12501 C 98.21205,243.86537 97.79289,244.73968 98.80738,245.96208 C 100.66012,248.19449 101.35505,247.87104 105.45445,242.86827 z M 128.30957,241.77944 C 128.30957,240.40469 127.90727,238.48419 127.41556,237.51164 C 125.38425,233.49389 123.21792,227.95507 123.21792,226.77916 C 123.21792,225.18656 117.27799,210.98705 115.43217,208.16718 C 114.66967,207.00231 114.35719,205.73785 114.73777,205.35727 C 115.11835,204.97669 113.98916,205.16749 112.22845,205.78128 L 109.02717,206.89725 L 115.61338,219.94863 C 119.53129,227.71244 122.19959,234.29064 122.19959,236.18572 C 122.19959,238.07809 122.81974,239.60943 123.72709,239.95761 C 124.56721,240.28 125.25458,241.33486 125.25458,242.30175 C 125.25458,243.26865 125.54763,244.35278 125.90578,244.71095 C 127.0623,245.86746 128.30957,244.34637 128.30957,241.77944 z M 135.18007,227.08758 C 135.58587,221.90086 135.34938,221.14373 131.98147,216.84708 C 129.98123,214.29524 126.52102,211.18243 124.29211,209.92971 L 120.23954,207.65205 L 122.32946,213.04191 C 123.47892,216.00633 125.4888,220.95214 126.79587,224.03259 C 128.10292,227.11303 129.75288,231.90918 130.46244,234.69067 L 131.75256,239.74794 L 133.24722,236.21817 C 134.06929,234.27679 134.93907,230.16802 135.18007,227.08758 z M 103.89765,225.36452 C 107.35592,222.99789 107.90938,222.00477 107.92738,218.13356 C 107.9394,215.54824 106.88471,213.64899 103.32165,209.8398 C 97.06241,203.14816 93.96937,201.93457 89.08323,204.2532 C 85.86651,205.77963 84.82102,205.8519 81.79343,204.75712 C 79.84946,204.05416 78.16356,203.63565 78.04702,203.82709 C 77.93046,204.01852 77.25936,204.93121 76.55568,205.85529 C 75.46641,207.2857 75.83682,208.06428 79.04794,211.09379 C 81.12237,213.0509 84.60403,215.24107 86.78498,215.96085 C 90.47059,217.1772 91.15189,217.06618 96.4429,214.38711 C 100.65817,212.25272 102.55871,211.76984 103.76631,212.52641 C 107.67539,214.97544 105.65663,222.89529 100.47145,225.45263 C 97.9812,226.68082 97.71889,227.04647 99.31517,227.06439 C 100.45073,227.07714 102.51285,226.3122 103.89765,225.36452 z M 151.04132,219.66585 C 150.02053,218.38431 144.9799,213.57428 139.83992,208.97689 C 133.57784,203.37587 129.96608,200.82079 128.89287,201.23263 C 128.01198,201.57065 127.29124,202.20049 127.29124,202.63225 C 127.29124,204.69413 149.40151,221.99593 152.03644,221.99593 C 152.50992,221.99593 152.06212,220.94739 151.04132,219.66585 z M 403.02339,97.01522 L 339.61914,33.60489 L 249.48969,33.60489 L 159.36024,33.60489 L 113.25303,79.72045 L 67.14584,125.83601 L 71.78754,128.09112 C 76.67169,130.46403 81.93287,131.04467 82.99389,129.3279 C 83.34004,128.76782 84.51965,128.30957 85.61524,128.30957 C 86.71084,128.30957 90.00609,126.97096 92.93803,125.33488 C 99.01249,121.9452 105.95158,119.85296 110.64547,119.99581 C 114.18114,120.10341 121.29871,123.44853 123.40315,125.99168 C 125.58965,128.63401 136.68106,133.40312 140.52953,133.35572 C 142.48982,133.33158 145.92668,132.65147 148.16701,131.84436 C 154.26383,129.6479 156.30017,129.99127 159.62331,133.77611 C 161.76903,136.21996 162.83862,138.74255 163.3438,142.55079 C 163.73375,145.49044 163.82075,148.12765 163.53713,148.41127 C 162.8458,149.1026 178.32232,158.88682 190.93002,165.72901 C 196.52707,168.76652 201.33868,171.60134 201.62248,172.0286 C 201.90628,172.45588 206.9501,174.65509 212.83096,176.91575 C 229.32824,183.25747 235.75251,183.76839 278.3833,182.12909 C 324.28668,180.36396 373.6524,180.58693 392.56619,182.64484 C 407.84635,184.30739 420.25558,186.58765 423.51443,188.33173 C 424.6219,188.92443 426.36008,189.41596 427.37705,189.42401 C 428.39401,189.43206 433.85275,191.66373 439.50758,194.38328 C 450.55131,199.69448 460.3452,207.71811 463.94301,214.40192 L 465.88595,218.01142 L 466.15679,189.21848 L 466.42763,160.42555 L 403.02339,97.01522 z M 151.83147,198.80922 C 154.0788,192.29648 155.78374,171.51195 153.68845,176.17108 C 150.74289,182.72092 149.6945,185.51454 149.6945,186.81367 C 149.6945,187.58835 148.72845,190.43686 147.54773,193.14368 C 143.66532,202.04415 143.4615,203.54296 145.8137,205.89516 C 148.32935,208.41081 148.64756,208.03613 151.83147,198.80922 z M 104.48296,198.82892 C 105.55634,193.48401 107.35224,192.17341 113.60282,192.17341 L 119.33457,192.17341 L 115.22976,188.42124 C 110.85319,184.42066 109.36355,180.80105 110.3978,176.68024 C 110.93863,174.52544 111.62031,174.13934 114.8361,174.16642 C 119.58674,174.20644 122.66247,177.89146 122.66247,183.54319 C 122.66247,185.64942 122.9859,187.37271 123.38118,187.37271 C 123.77648,187.37271 125.75965,185.3472 127.78824,182.87158 C 133.17225,176.3011 138.65714,162.88344 139.42547,154.40346 C 140.00202,148.04013 140.37462,147.13886 143.51145,144.52013 C 148.12433,140.66912 152.66362,139.6784 154.45714,142.13118 C 156.98018,145.58166 156.09893,148.4468 151.74866,150.93701 C 148.27798,152.92371 145.24118,156.1932 147.43991,155.57592 C 147.83981,155.46365 149.26526,155.97948 150.60758,156.72221 C 153.30944,158.21721 152.99481,158.50802 157.58656,150.2717 C 158.84674,148.01128 159.87608,144.55089 159.87398,142.58195 C 159.87049,139.30902 159.48494,138.84364 155.37793,137.15484 C 150.63243,135.20349 148.05666,135.57186 137.66545,139.68793 C 134.59254,140.90515 134.13922,140.83554 132.5738,138.90607 C 131.62868,137.74115 128.33503,135.45319 125.25458,133.82171 C 120.0064,131.04216 118.91646,130.8554 107.94297,130.8554 L 96.23218,130.8554 L 86.8991,135.29081 C 78.35281,139.35232 77.27244,139.62934 74.08337,138.57684 C 72.1679,137.94468 69.30179,136.07169 67.71424,134.41463 C 65.5049,132.10858 64.50993,131.66558 63.47294,132.5262 C 61.56342,134.11097 61.76126,135.48171 64.69621,141.00159 C 67.64436,146.54627 67.6384,146.58501 61.89564,159.22143 C 57.20161,169.55021 57.14763,173.3315 61.55672,182.96223 C 64.01015,188.32122 64.09967,188.39104 68.51747,188.39104 C 72.36165,188.39104 73.1649,188.76866 74.21276,191.06846 C 74.88371,192.54104 75.30096,193.8367 75.13996,193.9477 C 74.97897,194.0587 73.28888,194.77105 71.38421,195.53071 L 67.92117,196.9119 L 71.75469,198.2391 C 75.22845,199.44175 75.86799,199.36708 78.5695,197.44343 C 81.94203,195.04199 81.93864,195.03272 74.99362,187.67551 C 69.92379,182.3048 70.50916,181.31064 81.99623,175.78267 C 83.68785,174.9686 85.93891,173.34452 86.99859,172.17358 C 88.84401,170.13442 89.01016,170.12013 90.9372,171.83493 C 93.63811,174.23835 95.72301,179.40051 95.72301,183.6844 C 95.72301,186.2487 94.60575,188.60327 91.56154,192.45448 C 89.27273,195.35004 87.55558,197.87465 87.74564,198.06471 C 88.05405,198.37313 101.16079,201.33901 103.13136,201.5463 C 103.56543,201.59197 104.17365,200.36914 104.48296,198.82892 z M 123.21792,159.96371 C 122.3778,159.48494 120.23435,158.78238 118.4547,158.40248 C 116.67506,158.02259 113.65132,156.23327 111.7353,154.42621 C 109.81927,152.61916 106.36436,150.51783 104.05772,149.75657 C 98.19491,147.82166 99.80979,146.28054 106.79317,147.14607 C 116.55477,148.35593 122.63302,151.84166 125.88665,158.09572 C 127.43785,161.0774 126.42105,161.78911 123.21792,159.96371 z M 68.92164,155.44078 C 70.39567,153.00043 72.55073,150.41109 73.71066,149.68671 C 78.71631,146.56062 93.68635,144.27702 93.68635,146.63951 C 93.68635,147.19959 93.08405,147.65784 92.3479,147.65784 C 91.61176,147.65784 85.76909,150.39656 79.3642,153.74387 C 72.95931,157.09119 67.38654,159.84068 66.98026,159.85385 C 66.57399,159.86703 67.44762,157.88114 68.92164,155.44078 z M 136.36946,195.05504 C 137.94637,194.23959 140.00126,191.96093 140.9359,189.99134 C 142.77444,186.11689 145.95839,174.22395 147.02128,167.26069 C 147.64331,163.18568 147.53881,162.93279 145.233,162.93279 C 142.39446,162.93279 142.28365,163.15825 140.47789,172.60692 C 139.72863,176.52749 138.43675,180.80868 137.60707,182.12066 C 136.77738,183.43264 132.72595,186.08508 128.60386,188.01498 C 124.48178,189.94487 121.34888,191.91173 121.64186,192.38577 C 121.93484,192.85983 124.31969,193.56937 126.94155,193.96254 C 130.32598,194.47006 131.28948,194.94264 130.26364,195.59195 C 127.74924,197.18343 133.17648,196.7062 136.36946,195.05504 z "
|
51
|
+
id="path1308" />
|
52
|
+
</svg>
|
@@ -0,0 +1,244 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Payday # rubocop:todo Metrics/ModuleLength
|
4
|
+
describe Invoice do # rubocop:todo Metrics/BlockLength
|
5
|
+
# rubocop:todo RSpec/MultipleExpectations
|
6
|
+
it 'is able to be initialized with a hash of options' do # rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations
|
7
|
+
# rubocop:enable RSpec/MultipleExpectations
|
8
|
+
i = described_class.new(invoice_number: 20, bill_to: 'Here', ship_to: 'There',
|
9
|
+
notes: 'These are some notes.',
|
10
|
+
line_items:
|
11
|
+
[LineItem.new(price: 10, quantity: 3, description: 'Shirts')],
|
12
|
+
shipping_rate: 15.00, shipping_description: 'USPS Priority Mail:',
|
13
|
+
tax_rate: 0.125, tax_description: 'Local Sales Tax, 12.5%',
|
14
|
+
invoice_date: Date.civil(1993, 4, 12))
|
15
|
+
|
16
|
+
expect(i.invoice_number).to eq(20)
|
17
|
+
expect(i.bill_to).to eq('Here')
|
18
|
+
expect(i.ship_to).to eq('There')
|
19
|
+
expect(i.notes).to eq('These are some notes.')
|
20
|
+
expect(i.line_items[0].description).to eq('Shirts')
|
21
|
+
expect(i.shipping_rate).to eq(BigDecimal('15.00'))
|
22
|
+
expect(i.shipping_description).to eq('USPS Priority Mail:')
|
23
|
+
expect(i.tax_rate).to eq(BigDecimal('0.125'))
|
24
|
+
expect(i.tax_description).to eq('Local Sales Tax, 12.5%')
|
25
|
+
expect(i.invoice_date).to eq(Date.civil(1993, 4, 12))
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'totals all of the line items into a subtotal correctly' do # rubocop:todo RSpec/ExampleLength
|
29
|
+
i = described_class.new
|
30
|
+
|
31
|
+
# $100 in Pants
|
32
|
+
i.line_items << LineItem.new(price: 20, quantity: 5, description: 'Pants')
|
33
|
+
|
34
|
+
# $30 in Shirts
|
35
|
+
i.line_items <<
|
36
|
+
LineItem.new(price: 10, quantity: 3, description: 'Shirts')
|
37
|
+
|
38
|
+
# $1000 in Hats
|
39
|
+
i.line_items << LineItem.new(price: 5, quantity: 200, description: 'Hats')
|
40
|
+
|
41
|
+
expect(i.subtotal).to eq(BigDecimal('1130'))
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'calculates the correct tax rounded to two decimal places' do
|
45
|
+
i = described_class.new(tax_rate: 10.0)
|
46
|
+
i.line_items << LineItem.new(price: 20, quantity: 5, description: 'Pants')
|
47
|
+
|
48
|
+
expect(i.tax).to eq(BigDecimal('10'))
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'does not apply taxes to invoices with subtotal <= 0' do
|
52
|
+
i = described_class.new(tax_rate: 10.0)
|
53
|
+
i.line_items << LineItem.new(price: -1, quantity: 100,
|
54
|
+
description: 'Negative Priced Pants')
|
55
|
+
|
56
|
+
expect(i.tax).to eq(BigDecimal('-10'))
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'calculates the total for an invoice correctly' do # rubocop:todo RSpec/ExampleLength
|
60
|
+
i = described_class.new(tax_rate: 10.0)
|
61
|
+
|
62
|
+
# $100 in Pants
|
63
|
+
i.line_items << LineItem.new(price: 20, quantity: 5, description: 'Pants')
|
64
|
+
|
65
|
+
# $30 in Shirts
|
66
|
+
i.line_items <<
|
67
|
+
LineItem.new(price: 10, quantity: 3, description: 'Shirts')
|
68
|
+
|
69
|
+
# $1000 in Hats
|
70
|
+
i.line_items << LineItem.new(price: 5, quantity: 200, description: 'Hats')
|
71
|
+
|
72
|
+
expect(i.total).to eq(BigDecimal('1243'))
|
73
|
+
end
|
74
|
+
|
75
|
+
it "is overdue when it's past date and unpaid" do
|
76
|
+
i = described_class.new(due_at: Date.today - 1)
|
77
|
+
expect(i.overdue?).to eq(true)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "isn't overdue when past due date and paid" do
|
81
|
+
i = described_class.new(due_at: Date.today - 1, paid_at: Date.today)
|
82
|
+
expect(i.overdue?).not_to eq(true)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'is overdue when due date is a time before the current date' do
|
86
|
+
i = described_class.new(due_at: Time.parse('Jan 1 14:33:20 GMT 2011'))
|
87
|
+
expect(i.overdue?).to eq(true)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'is not refunded when not marked refunded' do
|
91
|
+
i = described_class.new
|
92
|
+
expect(i.refunded?).not_to eq(true)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'is refunded when marked as refunded' do
|
96
|
+
i = described_class.new(refunded_at: Date.today)
|
97
|
+
expect(i.refunded?).to eq(true)
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'is not paid when not marked paid' do
|
101
|
+
i = described_class.new
|
102
|
+
expect(i.paid?).not_to eq(true)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'is paid when marked as paid' do
|
106
|
+
i = described_class.new(paid_at: Date.today)
|
107
|
+
expect(i.paid?).to eq(true)
|
108
|
+
end
|
109
|
+
|
110
|
+
# rubocop:todo RSpec/MultipleExpectations
|
111
|
+
it 'is able to iterate over details' do # rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations
|
112
|
+
# rubocop:enable RSpec/MultipleExpectations
|
113
|
+
i = described_class.new(invoice_details: [%w[Test Yes], %w[Awesome Absolutely]])
|
114
|
+
details = []
|
115
|
+
i.each_detail do |key, value|
|
116
|
+
details << [key, value]
|
117
|
+
end
|
118
|
+
|
119
|
+
expect(details.length).to eq(2)
|
120
|
+
expect(details).to include(%w[Test Yes])
|
121
|
+
expect(details).to include(%w[Awesome Absolutely])
|
122
|
+
end
|
123
|
+
|
124
|
+
# rubocop:todo RSpec/MultipleExpectations
|
125
|
+
it 'is able to iterate through invoice_details as a hash' do # rubocop:todo RSpec/ExampleLength, RSpec/MultipleExpectations
|
126
|
+
# rubocop:enable RSpec/MultipleExpectations
|
127
|
+
i = described_class.new(invoice_details:
|
128
|
+
{ 'Test' => 'Yes', 'Awesome' => 'Absolutely' })
|
129
|
+
details = []
|
130
|
+
i.each_detail do |key, value|
|
131
|
+
details << [key, value]
|
132
|
+
end
|
133
|
+
|
134
|
+
expect(details.length).to eq(2)
|
135
|
+
expect(details).to include(%w[Test Yes])
|
136
|
+
expect(details).to include(%w[Awesome Absolutely])
|
137
|
+
end
|
138
|
+
|
139
|
+
describe 'rendering' do # rubocop:todo Metrics/BlockLength
|
140
|
+
before do
|
141
|
+
Dir.mkdir('tmp') unless File.exist?('tmp')
|
142
|
+
Config.default.reset
|
143
|
+
end
|
144
|
+
|
145
|
+
let(:invoice) { new_invoice(invoice_params) }
|
146
|
+
let(:invoice_params) { {} }
|
147
|
+
|
148
|
+
it 'renders to a file' do
|
149
|
+
File.unlink('tmp/testing.pdf') if File.exist?('tmp/testing.pdf')
|
150
|
+
|
151
|
+
invoice.render_pdf_to_file('tmp/testing.pdf')
|
152
|
+
|
153
|
+
expect(File.exist?('tmp/testing.pdf')).to be true
|
154
|
+
end
|
155
|
+
|
156
|
+
context 'with some invoice details' do
|
157
|
+
let(:invoice_params) do
|
158
|
+
{
|
159
|
+
invoice_details: {
|
160
|
+
'Ordered By:' => 'Alan Johnson',
|
161
|
+
'Paid By:' => 'Dude McDude'
|
162
|
+
}
|
163
|
+
}
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'renders an invoice correctly' do # rubocop:todo RSpec/ExampleLength
|
167
|
+
Payday::Config.default.company_details = <<-DETAILS
|
168
|
+
10 This Way
|
169
|
+
Manhattan, NY 10001
|
170
|
+
800-111-2222
|
171
|
+
awesome@awesomecorp.com
|
172
|
+
DETAILS
|
173
|
+
|
174
|
+
invoice.line_items += [
|
175
|
+
LineItem.new(price: 20, quantity: 5, description: 'Pants'),
|
176
|
+
LineItem.new(price: 10, quantity: 3, description: 'Shirts'),
|
177
|
+
LineItem.new(price: 5, quantity: 200, description: 'Hats')
|
178
|
+
] * 30
|
179
|
+
|
180
|
+
expect(invoice.render_pdf).to match_binary_asset 'testing.pdf'
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
context 'with a mix of LineItems with price, quantity and predefined_amounts' do
|
185
|
+
let(:invoice_params) do
|
186
|
+
{
|
187
|
+
invoice_details: {
|
188
|
+
'Ordered By:' => 'Alan Johnson',
|
189
|
+
'Paid By:' => 'Dude McDude'
|
190
|
+
}
|
191
|
+
}
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'renders an invoice correctly' do # rubocop:todo RSpec/ExampleLength
|
195
|
+
Payday::Config.default.company_details = <<-DETAILS
|
196
|
+
10 This Way
|
197
|
+
Manhattan, NY 10001
|
198
|
+
800-111-2222
|
199
|
+
awesome@awesomecorp.com
|
200
|
+
DETAILS
|
201
|
+
|
202
|
+
invoice.add_line_item(price: 10, quantity: 3, description: 'Extra Users')
|
203
|
+
invoice.add_line_item(predefined_amount: 79,
|
204
|
+
description: "Flat Fee\n<color rgb=\'888888\'>From date to date</color>")
|
205
|
+
|
206
|
+
expect(invoice.render_pdf).to match_binary_asset 'testing_predefined_amount.pdf'
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
context 'paid, with an svg logo' do # rubocop:todo RSpec/ContextWording
|
211
|
+
before do
|
212
|
+
logo = { filename: 'spec/assets/tiger.svg', size: '100x100' }
|
213
|
+
Payday::Config.default.invoice_logo = logo
|
214
|
+
end
|
215
|
+
|
216
|
+
let(:invoice_params) { { paid_at: Date.civil(2012, 2, 22) } }
|
217
|
+
|
218
|
+
it 'renders an invoice correctly' do # rubocop:todo RSpec/ExampleLength
|
219
|
+
invoice.line_items += [
|
220
|
+
LineItem.new(price: 20, quantity: 5, description: 'Pants'),
|
221
|
+
LineItem.new(price: 10, quantity: 3, description: 'Shirts'),
|
222
|
+
LineItem.new(price: 5, quantity: 200.0, description: 'Hats')
|
223
|
+
] * 3
|
224
|
+
|
225
|
+
expect(invoice.render_pdf).to match_binary_asset 'svg.pdf'
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def new_invoice(params = {})
|
230
|
+
default_params = {
|
231
|
+
tax_rate: 0.1,
|
232
|
+
notes: 'These are some crazy awesome notes <color rgb=\'888888\'>with color</color>!',
|
233
|
+
invoice_number: 12,
|
234
|
+
invoice_date: Date.civil(2011, 1, 1),
|
235
|
+
due_at: Date.civil(2011, 1, 22),
|
236
|
+
bill_to: "Alan Johnson\n101 This Way\nSomewhere, SC 22222",
|
237
|
+
ship_to: "Frank Johnson\n101 That Way\nOther, SC 22229"
|
238
|
+
}
|
239
|
+
|
240
|
+
Invoice.new(default_params.merge(params))
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Payday
|
4
|
+
describe LineItem do
|
5
|
+
it 'is able to be initialized with a price' do
|
6
|
+
li = described_class.new(price: BigDecimal('20'))
|
7
|
+
expect(li.price).to eq(BigDecimal('20'))
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'is able to be initialized with a quantity' do
|
11
|
+
li = described_class.new(quantity: 30)
|
12
|
+
expect(li.quantity).to eq(BigDecimal('30'))
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'is able to be initialized with a description' do
|
16
|
+
li = described_class.new(description: '12 Pairs of Pants')
|
17
|
+
expect(li.description).to eq('12 Pairs of Pants')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'returns the correct amount' do
|
21
|
+
li = described_class.new(price: 10, quantity: 12)
|
22
|
+
expect(li.amount).to eq(BigDecimal('120'))
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns the correct amount when using a predefined amount' do
|
26
|
+
li = described_class.new(predefined_amount: 244)
|
27
|
+
expect(li.amount).to eq(BigDecimal('244'))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require_relative '../lib/payday'
|
2
|
+
|
3
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
4
|
+
# spec/support/ and its subdirectories.
|
5
|
+
Dir['spec/support/**/*.rb'].each { |f| require f[5..-1] }
|
6
|
+
|
7
|
+
RSpec.configure do |_config|
|
8
|
+
# some (optional) config here
|
9
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
# Usage: expect(renderer.render).to match_binary_asset('pdf/test.pdf')
|
4
|
+
RSpec::Matchers.define(:match_binary_asset) do |file_name|
|
5
|
+
match do |actual_output|
|
6
|
+
expected_path = File.join('spec/assets', file_name)
|
7
|
+
expected_output = File.binread(expected_path)
|
8
|
+
|
9
|
+
(actual_output == expected_output).tap do |result|
|
10
|
+
unless result
|
11
|
+
output_path = File.join('tmp/rendered_output', file_name)
|
12
|
+
|
13
|
+
FileUtils.mkdir_p(File.dirname(output_path))
|
14
|
+
File.open(output_path, 'wb') { |f| f.write actual_output }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
failure_message do |_actual_output|
|
20
|
+
expected_output_path = File.join('spec/assets', file_name)
|
21
|
+
actual_output_path = File.join('tmp/rendered_output', file_name)
|
22
|
+
|
23
|
+
"expected output to match '#{expected_output_path}' "\
|
24
|
+
"(see #{actual_output_path})"
|
25
|
+
end
|
26
|
+
end
|