From: Radek Czajka Date: Thu, 19 Mar 2020 16:46:39 +0000 (+0000) Subject: Sending tax receipts. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/a5d95bc65cbd0b8703471a2dddef0a48234bd265 Sending tax receipts. --- diff --git a/src/club/management/commands/send_receipts.py b/src/club/management/commands/send_receipts.py new file mode 100644 index 000000000..e461b6854 --- /dev/null +++ b/src/club/management/commands/send_receipts.py @@ -0,0 +1,16 @@ +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from datetime import timedelta +import traceback +from django.core.management.base import BaseCommand, CommandError +from django.utils.timezone import now +from club.models import PayUOrder + + +class Command(BaseCommand): + def handle(self, *args, **options): + year = 2019 + for email in PayUOrder.objects.filter(completed_at__year=2019).order_by('schedule__email').values_list('schedule__email', flat=True).distinct(): + print(email) + PayUOrder.send_receipt(email, year) diff --git a/src/club/models.py b/src/club/models.py index 6fd58e0b3..1d993bc77 100644 --- a/src/club/models.py +++ b/src/club/models.py @@ -2,10 +2,12 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from datetime import datetime, timedelta +import os +import tempfile from django.apps import apps from django.conf import settings from django.contrib.sites.models import Site -from django.core.mail import send_mail +from django.core.mail import send_mail, EmailMessage from django.urls import reverse from django.db import models from django import template @@ -13,6 +15,7 @@ from django.utils.timezone import now from django.utils.translation import ugettext_lazy as _, ungettext, ugettext, get_language from catalogue.utils import get_random_hash from messaging.states import Level +from reporting.utils import render_to_pdf from .payment_methods import recurring_payment_method, single_payment_method from .payu import models as payu_models from . import utils @@ -239,6 +242,33 @@ class PayUOrder(payu_models.Order): if not self.schedule.email_sent: self.schedule.send_email() + @classmethod + def send_receipt(cls, email, year): + qs = cls.objects.filter(status='COMPLETED', schedule__email=email, completed_at__year=year).order_by('completed_at') + if not qs.exists(): return + ctx = { + "email": email, + "year": year, + "next_year": year + 1, + "total": qs.aggregate(s=models.Sum('schedule__amount'))['s'], + "orders": qs, + } + temp = tempfile.NamedTemporaryFile(prefix='receipt-', suffix='.pdf', delete=False) + temp.close() + render_to_pdf(temp.name, 'club/receipt.texml', ctx, { + "fnp.eps": os.path.join(settings.STATIC_ROOT, "img/fnp.eps"), + }) + + message = EmailMessage( + f'Odlicz od podatku swoje darowizny przekazane dla Wolnych Lektur', + template.loader.render_to_string('club/receipt_email.txt', ctx), + settings.CONTACT_EMAIL, [email] + ) + with open(temp.name, 'rb') as f: + message.attach('wolnelektury-darowizny.pdf', f.read(), 'application/pdf') + message.send() + os.unlink(f.name) + class PayUCardToken(payu_models.CardToken): schedule = models.ForeignKey(Schedule, on_delete=models.CASCADE) diff --git a/src/club/templates/club/receipt.texml b/src/club/templates/club/receipt.texml new file mode 100644 index 000000000..4cfef286f --- /dev/null +++ b/src/club/templates/club/receipt.texml @@ -0,0 +1,89 @@ + +text_x+x-{{ email }} + + diff --git a/src/club/templates/club/receipt_email.txt b/src/club/templates/club/receipt_email.txt new file mode 100644 index 000000000..c8c909366 --- /dev/null +++ b/src/club/templates/club/receipt_email.txt @@ -0,0 +1,27 @@ +Dzień dobry, + +Czy wiesz, że możesz odliczyć od podatku darowizny przekazane +Fundacji Nowoczesna Polska na prowadzenie biblioteki Wolne Lektury? +Kliknij i zobacz swoje zestawienie darowizn za rok {{ year }}! + +Dane z zaświadczenia wprowadź do formularza PIT. Pamiętaj, że musisz +mieć potwierdzenie wykonanych przelewów z Twojego banku. Zaświadczenie +będzie dostępne do końca kwietnia {{ next_year }} roku. + +Pamiętaj, że podczas wypełniania swojego PIT-a możesz przekazać +1% swojego podatku na wybraną organizację pożytku publicznego. +Chcesz dodatkowo wesprzeć Wolne Lektury? Nic prostszego! +Wystarczy, że w swoim zeznaniu podatkowym w odpowiednim polu +podasz "Fundacja Nowoczesna Polska" oraz numer KRS: 0000070056. + +Serdecznie dziękujemy za Twoje wsparcie! + +zespół Wolnych Lektur + + +Administratorem danych osobowych jest Fundacja Nowoczesna Polska +(ul. Marszałkowska 84/92 lok. 125, 00-514 Warszawa). Podanie danych osobowych +jest dobrowolne. Dane są przetwarzane w zakresie niezbędnym do wysyłania +informacji darczyńcom Wolnych Lektur. Osobom, których dane są zbierane, +przysługuje prawo dostępu do treści swoich danych oraz ich poprawiania. +Więcej informacji w polityce prywatności (https://nowoczesnapolska.org.pl/prywatnosc/). diff --git a/src/wolnelektury/static/img/fnp.eps b/src/wolnelektury/static/img/fnp.eps new file mode 100644 index 000000000..26b7a9d0c --- /dev/null +++ b/src/wolnelektury/static/img/fnp.eps @@ -0,0 +1,251 @@ +%!PS-Adobe-3.0 EPSF-3.0 +%%Creator: cairo 1.14.6 (http://cairographics.org) +%%CreationDate: Wed Mar 4 14:25:40 2020 +%%Pages: 1 +%%DocumentData: Clean7Bit +%%LanguageLevel: 2 +%%BoundingBox: 0 -1 630 218 +%%EndComments +%%BeginProlog +save +50 dict begin +/q { gsave } bind def +/Q { grestore } bind def +/cm { 6 array astore concat } bind def +/w { setlinewidth } bind def +/J { setlinecap } bind def +/j { setlinejoin } bind def +/M { setmiterlimit } bind def +/d { setdash } bind def +/m { moveto } bind def +/l { lineto } bind def +/c { curveto } bind def +/h { closepath } bind def +/re { exch dup neg 3 1 roll 5 3 roll moveto 0 rlineto + 0 exch rlineto 0 rlineto closepath } bind def +/S { stroke } bind def +/f { fill } bind def +/f* { eofill } bind def +/n { newpath } bind def +/W { clip } bind def +/W* { eoclip } bind def +/BT { } bind def +/ET { } bind def +/pdfmark where { pop globaldict /?pdfmark /exec load put } + { globaldict begin /?pdfmark /pop load def /pdfmark + /cleartomark load def end } ifelse +/BDC { mark 3 1 roll /BDC pdfmark } bind def +/EMC { mark /EMC pdfmark } bind def +/cairo_store_point { /cairo_point_y exch def /cairo_point_x exch def } def +/Tj { show currentpoint cairo_store_point } bind def +/TJ { + { + dup + type /stringtype eq + { show } { -0.001 mul 0 cairo_font_matrix dtransform rmoveto } ifelse + } forall + currentpoint cairo_store_point +} bind def +/cairo_selectfont { cairo_font_matrix aload pop pop pop 0 0 6 array astore + cairo_font exch selectfont cairo_point_x cairo_point_y moveto } bind def +/Tf { pop /cairo_font exch def /cairo_font_matrix where + { pop cairo_selectfont } if } bind def +/Td { matrix translate cairo_font_matrix matrix concatmatrix dup + /cairo_font_matrix exch def dup 4 get exch 5 get cairo_store_point + /cairo_font where { pop cairo_selectfont } if } bind def +/Tm { 2 copy 8 2 roll 6 array astore /cairo_font_matrix exch def + cairo_store_point /cairo_font where { pop cairo_selectfont } if } bind def +/g { setgray } bind def +/rg { setrgbcolor } bind def +/d1 { setcachedevice } bind def +%%EndProlog +%%BeginSetup +%%EndSetup +%%Page: 1 1 +%%BeginPageSetup +%%PageBoundingBox: 0 -1 630 218 +%%EndPageSetup +q 0 -1 630 219 rectclip q +0.376471 0.364706 0.360784 rg +291.172 19.928 m 303.199 19.928 l 303.199 40.378 l 307.066 40.378 l 312.133 + 40.378 314.539 40.807 317.117 42.268 c 322.703 45.276 325.969 51.292 325.969 + 58.506 c 325.969 64.178 324.164 69.163 320.727 72.596 c 317.375 76.034 +313.852 77.237 307.668 77.237 c 291.172 77.237 l h +303.199 51.463 m 303.199 66.155 l 305.863 66.155 l 308.785 66.155 309.816 + 65.897 311.102 64.866 c 312.562 63.577 313.336 61.6 313.336 58.85 c 313.336 + 56.014 312.562 54.042 311.102 52.753 c 309.816 51.721 308.785 51.463 305.863 + 51.463 c h +346.586 65.725 m 335.848 65.725 329.145 56.702 329.145 42.44 c 329.145 +28.092 335.848 19.057 346.586 19.057 c 357.328 19.057 364.027 27.92 364.027 + 41.924 c 364.027 56.96 357.586 65.725 346.586 65.725 c h +346.586 55.67 m 350.711 55.67 352.773 51.12 352.773 42.096 c 352.773 33.764 + 350.539 29.124 346.586 29.124 c 344.27 29.124 342.723 30.413 341.777 33.077 + c 340.918 35.569 340.402 38.917 340.402 42.44 c 340.402 45.878 340.918 +49.229 341.777 51.721 c 342.723 54.381 344.27 55.67 346.586 55.67 c h +369.957 19.928 m 381.043 19.928 l 381.043 77.237 l 369.957 77.237 l h +385.594 34.28 m 386.453 24.655 392.383 19.057 401.746 19.057 c 406.215 +19.057 410.082 20.272 412.832 22.592 c 415.75 25.085 417.727 29.467 417.727 + 33.506 c 417.727 39.174 415.238 43.471 410.598 45.878 c 408.879 46.737 +406.73 47.51 403.723 48.37 c 400.629 49.229 399.598 49.659 398.824 50.26 + c 398.141 50.948 397.711 51.979 397.711 53.01 c 397.711 54.983 399.172 +56.272 401.488 56.272 c 404.066 56.272 405.441 54.557 405.699 51.292 c 416.695 + 51.292 l 415.75 60.483 409.996 65.725 400.887 65.725 c 392.383 65.725 386.453 + 60.225 386.453 52.151 c 386.453 48.628 387.828 45.018 390.062 42.612 c +391.867 40.721 394.188 39.432 398.141 38.229 c 400.973 37.284 400.113 37.542 + 400.973 37.284 c 403.293 36.51 403.379 36.51 403.637 36.428 c 405.441 35.741 + 406.473 34.366 406.473 32.733 c 406.473 30.241 404.668 28.522 402.004 28.522 + c 398.742 28.522 397.023 30.413 396.594 34.28 c h +434.055 77.237 m 422.969 77.237 l 422.969 19.928 l 434.055 19.928 l 434.055 + 35.225 l 436.887 39.518 l 444.02 19.928 l 455.531 19.928 l 443.762 48.026 + l 454.414 64.866 l 442.73 64.866 l 434.055 48.713 l h +489.812 64.866 m 480.105 64.866 l 480.105 60.311 l 478.559 63.749 475.207 + 65.725 470.824 65.725 c 461.805 65.725 456.477 56.96 456.477 42.01 c 456.477 + 27.835 461.977 19.057 470.824 19.057 c 475.035 19.057 477.957 20.702 480.105 + 24.483 c 480.105 19.928 l 489.812 19.928 l h +478.73 38.487 m 478.73 34.71 478.473 33.335 477.613 31.702 c 476.754 30.155 + 475.121 29.124 473.402 29.124 c 469.453 29.124 467.734 32.991 467.734 42.01 + c 467.734 51.463 469.453 55.67 473.402 55.67 c 476.754 55.67 478.73 52.753 + 478.73 47.596 c h +478.73 38.487 m f +290.219 97.315 m 300.109 97.315 l 300.109 123.151 l 300.109 127.37 301.41 + 129.21 304.402 129.21 c 306.012 129.21 307.543 128.213 307.926 126.831 +c 308.156 126.221 308.309 124.838 308.309 123.46 c 308.309 97.315 l 318.199 + 97.315 l 318.199 126.065 l 318.199 133.503 313.906 138.178 307.008 138.178 + c 302.867 138.178 300.414 136.721 298.879 133.35 c 298.879 137.413 l 290.219 + 137.413 l h +339.051 138.178 m 329.469 138.178 323.488 130.128 323.488 117.401 c 323.488 + 104.6 329.469 96.538 339.051 96.538 c 348.637 96.538 354.617 104.448 354.617 + 116.944 c 354.617 130.358 348.867 138.178 339.051 138.178 c h +339.051 129.21 m 342.734 129.21 344.574 125.147 344.574 117.096 c 344.574 + 109.659 342.578 105.518 339.051 105.518 c 336.984 105.518 335.602 106.67 + 334.758 109.045 c 333.992 111.268 333.531 114.26 333.531 117.401 c 333.531 + 120.467 333.992 123.46 334.758 125.682 c 335.602 128.057 336.984 129.21 + 339.051 129.21 c h +365.809 137.413 m 355.754 137.413 l 365.809 97.315 l 374.855 97.315 l 380.066 + 123.612 l 385.281 97.315 l 394.402 97.315 l 404.371 137.413 l 394.402 137.413 + l 391.797 124.073 l 390.492 117.249 390.34 115.87 389.805 109.506 c 389.344 + 115.487 389.113 116.635 387.273 124.073 c 384.055 137.413 l 376.082 137.413 + l 372.402 122.081 l 372.324 121.694 372.172 120.854 371.789 118.936 c 371.48 + 117.631 371.328 116.866 371.25 116.1 c 370.637 113.417 370.562 112.651 +370.332 109.506 c 370.18 112.038 370.023 113.569 369.871 114.874 c 369.562 + 117.096 369.105 119.932 368.797 121.467 c h +420.93 138.178 m 411.348 138.178 405.367 130.128 405.367 117.401 c 405.367 + 104.6 411.348 96.538 420.93 96.538 c 430.512 96.538 436.492 104.448 436.492 + 116.944 c 436.492 130.358 430.742 138.178 420.93 138.178 c h +420.93 129.21 m 424.609 129.21 426.449 125.147 426.449 117.096 c 426.449 + 109.659 424.457 105.518 420.93 105.518 c 418.859 105.518 417.48 106.67 +416.637 109.045 c 415.871 111.268 415.41 114.26 415.41 117.401 c 415.41 +120.467 415.871 123.46 416.637 125.682 c 417.48 128.057 418.859 129.21 420.93 + 129.21 c h +468.461 121.694 m 468.152 126.831 467.695 129.057 466.16 131.967 c 464.016 + 136.034 460.18 138.178 455.199 138.178 c 449.68 138.178 445.77 135.803 +443.238 130.819 c 441.32 126.831 440.402 122.538 440.402 117.096 c 440.402 + 111.651 441.707 106.44 443.93 102.608 c 446.305 98.467 449.832 96.538 454.891 + 96.538 c 463.246 96.538 467.926 101.995 468.309 112.268 c 458.648 112.268 + l 458.496 107.514 457.422 105.596 454.891 105.596 c 453.203 105.596 451.672 + 107.053 451.211 109.124 c 450.676 111.116 450.445 114.182 450.445 117.479 + c 450.445 120.393 450.676 123.077 451.211 125.378 c 451.746 127.831 453.051 + 129.21 454.738 129.21 c 456.117 129.21 457.191 128.518 457.883 127.217 +c 458.418 126.295 458.57 125.221 458.648 122.616 c 458.648 121.694 l h +497.285 105.518 m 482.336 105.518 l 497.285 128.674 l 497.285 137.413 l + 472.602 137.413 l 472.602 129.21 l 485.863 129.21 l 470.992 106.057 l 470.992 + 97.315 l 497.285 97.315 l h +530.941 114.413 m 530.941 116.405 l 530.941 123.307 530.023 127.753 527.723 + 131.737 c 525.27 135.878 521.129 138.178 516.145 138.178 c 506.18 138.178 + 500.277 130.053 500.277 116.405 c 500.277 111.651 501.426 106.975 503.422 + 103.452 c 506.027 98.928 510.32 96.538 515.914 96.538 c 524.043 96.538 +529.484 101.686 530.559 110.35 c 520.898 110.35 l 520.133 106.901 518.367 + 104.983 515.84 104.983 c 513.461 104.983 511.621 106.592 510.855 109.506 + c 510.473 110.811 510.32 111.96 510.242 114.413 c h +510.32 121.85 m 510.395 127.061 512.234 129.745 515.688 129.745 c 518.906 + 129.745 520.82 126.756 520.898 121.85 c h +533.703 110.12 m 534.469 101.534 539.758 96.538 548.113 96.538 c 552.102 + 96.538 555.551 97.624 558.004 99.694 c 560.609 101.917 562.375 105.827 +562.375 109.428 c 562.375 114.491 560.152 118.323 556.012 120.467 c 554.477 + 121.237 552.562 121.924 549.879 122.694 c 547.117 123.46 546.199 123.842 + 545.508 124.378 c 544.895 124.995 544.512 125.913 544.512 126.831 c 544.512 + 128.596 545.816 129.745 547.887 129.745 c 550.184 129.745 551.41 128.213 + 551.641 125.299 c 561.453 125.299 l 560.609 133.503 555.477 138.178 547.348 + 138.178 c 539.758 138.178 534.469 133.272 534.469 126.065 c 534.469 122.924 + 535.695 119.702 537.688 117.557 c 539.297 115.87 541.367 114.721 544.895 + 113.647 c 547.426 112.803 546.66 113.034 547.426 112.803 c 549.496 112.112 + 549.57 112.112 549.801 112.038 c 551.41 111.424 552.332 110.198 552.332 + 108.741 c 552.332 106.518 550.723 104.983 548.344 104.983 c 545.43 104.983 + 543.898 106.67 543.516 110.12 c h +567.051 97.315 m 576.941 97.315 l 576.941 123.151 l 576.941 127.37 578.242 + 129.21 581.234 129.21 c 582.844 129.21 584.375 128.213 584.762 126.831 +c 584.988 126.221 585.145 124.838 585.145 123.46 c 585.145 97.315 l 595.035 + 97.315 l 595.035 126.065 l 595.035 133.503 590.738 138.178 583.84 138.178 + c 579.699 138.178 577.246 136.721 575.715 133.35 c 575.715 137.413 l 567.051 + 137.413 l h +629.992 137.413 m 621.328 137.413 l 621.328 133.35 l 619.949 136.417 616.957 + 138.178 613.051 138.178 c 605 138.178 600.246 130.358 600.246 117.018 c + 600.246 104.37 605.152 96.538 613.051 96.538 c 616.805 96.538 619.41 98.006 + 621.328 101.381 c 621.328 97.315 l 629.992 97.315 l h +620.102 113.878 m 620.102 110.503 619.871 109.276 619.105 107.819 c 618.34 + 106.44 616.883 105.518 615.348 105.518 c 611.824 105.518 610.289 108.971 + 610.289 117.018 c 610.289 125.452 611.824 129.21 615.348 129.21 c 618.34 + 129.21 620.102 126.604 620.102 122.003 c h +620.102 113.878 m f +290.367 168.592 m 296.469 168.592 l 296.469 180.534 l 304.879 180.534 l + 304.879 186.155 l 296.469 186.155 l 296.469 192.038 l 304.879 192.038 l + 304.879 197.663 l 290.367 197.663 l h +331.102 197.663 m 331.102 178.092 l 331.102 174.342 331.668 172.471 333.367 + 170.725 c 335.113 168.94 338.074 167.842 341.168 167.842 c 343.961 167.842 + 346.75 168.764 348.535 170.292 c 350.496 171.948 351.281 174.17 351.281 + 178.092 c 351.281 197.663 l 345.18 197.663 l 345.18 178.092 l 345.18 176.217 + 345.004 175.608 344.352 174.823 c 343.609 173.909 342.566 173.471 341.039 + 173.471 c 339.73 173.471 338.688 173.952 337.945 174.823 c 337.336 175.651 + 337.203 176.217 337.203 178.092 c 337.203 197.663 l h +378.812 168.592 m 384.914 168.592 l 384.914 179.311 l 384.914 181.01 384.871 + 182.842 384.871 184.194 c 384.785 185.936 384.738 186.721 384.523 188.901 + c 384.871 187.592 385 186.94 385.262 186.198 c 385.742 184.803 386.484 +182.842 387.094 181.448 c 392.672 168.592 l 398.383 168.592 l 398.383 197.663 + l 392.281 197.663 l 392.281 187.854 l 392.281 184.151 392.324 183.28 392.586 + 179.749 c 392.281 180.753 392.281 180.663 391.715 182.19 c 390.406 185.588 + 390.492 185.46 389.188 188.116 c 384.652 197.663 l 378.812 197.663 l h +426.133 168.592 m 434.762 168.592 l 438.074 168.592 440.207 169.288 442.172 + 171.12 c 445.047 173.733 446.703 178.135 446.703 183.19 c 446.703 187.331 + 445.656 190.948 443.652 193.608 c 441.473 196.53 438.945 197.663 434.805 + 197.663 c 426.133 197.663 l h +432.234 174.213 m 432.234 192.038 l 433.801 192.038 l 436.07 192.038 436.941 + 191.823 437.855 191.081 c 439.469 189.772 440.297 186.983 440.297 182.975 + c 440.297 179.663 439.641 177.178 438.336 175.694 c 437.465 174.647 436.285 + 174.213 434.457 174.213 c h +470.172 168.592 m 476.543 168.592 l 478.332 174.213 l 485.871 174.213 l + 487.656 168.592 l 494.02 168.592 l 485.043 197.663 l 479.203 197.663 l +h +484.867 179.225 m 479.203 179.225 l 482.078 190.948 l h +539.641 186.241 m 539.336 193.784 535.238 198.401 528.918 198.401 c 522.031 + 198.401 517.543 192.389 517.543 183.147 c 517.543 173.866 522.031 167.842 + 528.918 167.842 c 535.238 167.842 539.336 172.514 539.641 180.01 c 533.32 + 180.01 l 533.191 178.178 533.059 177.44 532.754 176.479 c 532.102 174.561 + 530.75 173.471 528.961 173.471 c 525.91 173.471 523.992 177.178 523.992 + 183.147 c 523.992 189.077 525.91 192.78 528.961 192.78 c 530.75 192.78 +532.102 191.69 532.754 189.772 c 533.059 188.858 533.191 188.073 533.32 +186.241 c h +580.637 197.663 m 574.535 197.663 l 574.535 176.917 l 574.535 174.475 573.84 + 173.471 572.141 173.471 c 571.051 173.471 570.309 174.17 570.004 175.475 + c 569.875 176.045 569.828 176.612 569.828 177.831 c 563.719 177.831 l 563.719 + 176.874 l 563.719 171.553 567.172 167.842 572.141 167.842 c 574.754 167.842 + 577.152 168.897 578.723 170.639 c 580.07 172.21 580.637 174.038 580.637 + 176.874 c h +605.285 168.592 m 611.656 168.592 l 613.445 174.213 l 620.984 174.213 l + 622.77 168.592 l 629.133 168.592 l 620.156 197.663 l 614.316 197.663 l +h +619.98 179.225 m 614.316 179.225 l 617.191 190.948 l h +619.98 179.225 m f +0.905882 0.470588 0.0901961 rg +0 217.46 m 98.75 217.46 l 98.75 205.819 l 17.824 205.819 l 17.824 30.69 + l 98.754 30.69 l 98.754 19.049 l 0 19.049 l 0 85.186 0 151.323 0 217.46 + c h +0 217.46 m f* +212.828 198.409 m 120.492 198.409 l 120.492 186.768 l 194.48 186.768 l +194.48 11.639 l 118.512 11.639 l 118.512 -0.001 l 212.828 -0.001 l 212.828 + 66.135 212.828 132.272 212.828 198.409 c h +212.828 198.409 m f* +Q Q +showpage +%%Trailer +end restore +%%EOF