summaryrefslogtreecommitdiff
path: root/postgresqleu/invoices
AgeCommit message (Collapse)Author
2025-04-11When deciding to put bank info on invoices, only look at active methodsMagnus Hagander
If a payment method that had bank info on it was added to an invoice, we would include the bank data on the PDF even if the method was not marked as active. It would still not show on the webpage of available methods, but if someone forwarded the PDF alone for payment, they would get the bank info for an inactive method. So fix that.
2025-02-19Add cli command to export a set of invoices or receipts by idMagnus Hagander
2024-12-04Support fractional VAT ratesMagnus Hagander
Allow fractional tax rates, up to 6 decimal places. Author: Steve Singer, with some fixes from me Fixes #164
2024-11-12Generate a fake payment link when previewing invoiceMagnus Hagander
This way we get to see the qr code on the preview as well, even though it can of course not be used. But it helps adjusting layouts.
2024-09-03Fix cancellation of invoices manually flagged as paidMagnus Hagander
This is not a normal situation and has to be dealt with manually regardless, but we shouldn't crash on it prior to telling the user they have to do that...
2024-03-21Don't crash invoice saving when using unavailable accountsMagnus Hagander
If an automated system added an accounting account to an invoice that did not have the checkbox for "available in invoicing", we would first not show the account on the invoice, and if it was saved (to change the payment providers for example), we would crash. This is normally a misconfiguration, but we sohuldn't crash hard on it... Crashed and diagnosed by Steve Singer
2023-11-23Set content-disposition on invoice pdf viewersMagnus Hagander
When viewing a PDF either in the user or admin interface, set the filename using content-disposition so if the user decides to save the file it will get a reasonable filename, and not just `document.pdf` or similar depending on the browser.
2023-11-01Implement pending registration transfers with invoicesMagnus Hagander
Instead of requiring registration transfer invoicing to be full manual, create a new object that represents a pending transfer. So instead of transfering, the admin will create a pending transfer and have it auto-generate an invoice. That's left as pending until the invoice is paid, at which point the transfer is automatically completed.
2023-08-24Fix rendering of invoices with fees not defined yetMagnus Hagander
Commit c594130d missed that the fee amount can be returned as a string (e.g. "not settled yet"), and thus cannot be passed to format_currency. A cleaner fix might be to return it as an object, but for now just make the invoice payment wrapper figure it out and apply format_currency only when it's not already a string.
2023-07-25BREAKING CHANGE: Allow the currency format to be configurable.Dave Page
This change allows the currency format to be configured in the instance. This allows us to use alternate symbols (e.g. £), and to format amounts using the format required in different jurisdictions. The currency format is set to Euro by default. Note that this change requires an update to any Jinja templates that use the currency_format tag. This must be changed to format_currency.
2023-06-28Add a field for "invoice extra description", use in confsponsorMagnus Hagander
This is a free text field added to each invoice (optional). If specified, the text in question will be included on the invoice payment page and in the email sent to the invoice recipient (if an email is sent). Also add a field to the SponsorshipLevel model in confsponsor, that allows you to specify this individually for each sponsorship level. It will then be passed through to the invoice and included everywhere (sponsorship invoices are always automatically emailed). This is intended to for example inform sponsors about optional other payment methods or oher such information.
2023-06-20Show which type it is when it's the wrong type, not just that it's wrongMagnus Hagander
Message only appears when debugging, but debugging becomes a lot easier..
2022-09-01Add match information on invoice idMagnus Hagander
Just matching up the invoice id is not enough to auto-approve a payment (it's too short, and people should use the payment reference), but it should still be given as a hint tot he user for manual matching.
2022-08-22Fix accouting for overpaid invoicesMagnus Hagander
When the invoie is overpaid we have to put the overpayment *somewhere* in the accounting, otherwise the accounting entry doesn't balance and an exception in thrown. So put this overpayment in as a "negative cost" on whatever account gets the payment fees, set the description to indicate what it was, and then leave the accounting entry open for the treasurer to handle.
2022-08-15Create a base class for before-new-object-formsMagnus Hagander
Pass the current conference (if any) to this base class, and make it available to subclasses. Doing this as a proper baseclass makes further additions later easier.
2022-07-15Rename instances of variables "l"Magnus Hagander
This is complained about more loudly in newer versions of pycodestyle, and it's a bad idea in general. So rename them all to something more readable.
2022-02-15Explicitly say that 0 is a decimal in CoalesceMagnus Hagander
Seems in django 3.2, it no longer recognises that 0 can be a decimal and considers it an integer, ccomplaining about type mismatch. So explictly make it a Decimal(0) to get around it.
2022-01-05Centralize creation of invoice return URLsMagnus Hagander
This code was copy/pasted between several different places, so centralize it into the InvoiceManager class to reduce the risk of furhter off-by-one mistakes when editing.
2021-12-27Switch to native JSON FieldMagnus Hagander
Django 3.2 has deprecated the JSON field that's in contrib.postgres and instead have one in core, so switch to using that one.
2021-12-19Make django ORM use joins for pending xacts and matchersMagnus Hagander
Without this a silly number of queries is generated if there is a lot of pending records.
2021-04-09Don't crash when matching payment to multiple invoices with zero invoicesMagnus Hagander
Unintentionally "reported" by Lætitia Avrot
2020-07-13Remove unused importsMagnus Hagander
2020-05-13Generate pending bank matchers for managed bank accountsMagnus Hagander
For managed bank accounts that don't have support for automated refunds, we can still generate pending bank matcher for a reasonable string, since the transaction will eventually show up. If it doesn't, or amounts don't match etc, the operator can always drop the pending bank matcher as well. This also means it can complete the accounting entry for automatic closing. In this also update the email that's sent to treasurer to suggest the proper string. Fixes #47
2020-04-10Look for invoices to refund every 1 hour instead of 4Magnus Hagander
We have a very cheap check to see if there is antyhing at all to do, so we can definitely run it a bit more often to decrease waiting times. We still want to batch things out a bit like this due to how some of the upstream APIs work, but once an hour is definitely still within reason.
2020-04-06Fix incorrect query for refund exposureMagnus Hagander
It accidentally multiplied the cost of a bulk payment with the number of people on it, which is clearly not correct.
2020-04-06Add simple report showing refund exposure per payment providerMagnus Hagander
This shows the exposure to refunds for current and recently-past conferences, in case they have to be canceled and everything refunded.
2020-04-05Properly decode base64 output in bank file uploadMagnus Hagander
The actual file was correctly decoded, but the temporary storage during the validation step was not.
2020-04-04Sync up migration with modelMagnus Hagander
This hasn't changed since 2016, but the new version of django complains (with the opposite complaint that 1.11 had back in 2016).
2020-04-04Enable use of django 2.2 autocomplete in admin viewsMagnus Hagander
2020-04-04Remove dependency on django-selectableMagnus Hagander
The version we have doesn't work in django 2.2. And while there might be newer ones available, we only use it in the admin interface and the newer django has it's own functionality for delivering the same thing there.
2020-04-04Fix setting of manytomany fieldFINAL_DJANGO111Magnus Hagander
While this works in the current django version, the syntax is not correct and will be removeed in the future, so let's get it fixed.
2020-04-04Store id instead of internalname of payment method for bank transfersMagnus Hagander
Internal names can change, and since this field is only ever used internally or in debugging anyway, it's better to store the id.
2020-04-02Add protection against accidentally over-refunding an invoiceMagnus Hagander
This check is normally done higher up in the stack to make sure we can give a proper error message. But if the upper end of the stack failed to do it's checking, add a hard exception in case an attempt is made to refund more of an invoice than is actually available.
2020-04-01Always decode base64encoded values to stringsMagnus Hagander
2020-04-01Change JSONField defaults to be dict instead of {}Magnus Hagander
Per warnings in newer django versions
2020-04-01Fix amount in accounting entry for manually refunded invoicesMagnus Hagander
When issuing a partial refund of a manual invoice, the full amount was put in the pending accounting record, instead of the partial amount. (For automatic refunding it was correct, which is why this went unnoticed for so long)
2020-04-01Specify on_delete for all ForeignKey and OneToOneFieldsMagnus Hagander
This was already done once in 8289e05cd but had not been properly maintained.
2020-03-31Create abstraction for getting "today"Magnus Hagander
This will work differently for conferences and non-conferences once we add proper timezone support, so abstract it out into a separate couple of functions. For now they both return the same thing, but this will change in a later commit. In passing, fix missing datetime.now() -> timezone.now() conversions.
2020-03-31Notify invoice handlers on manual refundsMagnus Hagander
When manual refunds are generated in the system, there is a manual step that needs to be handled by the person managing the account. So send an email explicitly saying that this has to be done, instead of just creating and open accounting entry and leaving it at that.
2020-03-30Show payment provider on refunds listMagnus Hagander
2020-03-29Remove date parameter to create_accounting_entryMagnus Hagander
This should always be set to todays date, so set it in the function instaed. This changes the behaviour of the paypal plugin to actually use todays date rather than a date parsed out from the notification. In theory this could change the accounting entry date in case the notification is so delayed it ends up on a different day, but either one could be argued to be equally correct in this case, and using the date of creation of the transaction makes tracking things a lot easier. While at it, clean up some imports that have been missed earlier.
2020-03-27Add an administrative view of refundsMagnus Hagander
While refunds could be viewed on the individual invoice that was refunded, it's useful to also have a global view of refunds on the admin page (which links to the invoices as necessary). Button on the frontpage will be highlighted if there are any refunds that are in pendning state (either waiting for us to issue them or waiting for completion).
2020-03-24Raise exception when processing refunds if any failMagnus Hagander
Now that we don't crash on the individual refund in order to proceed with others, it became a bit too easy to miss the fact that something went wrong at all. So instead, collect the error state until the end and raise an exception if anything went wrong earlier, thereby triggering an error flag in the job scheduler.
2020-03-24Extend length of invoice history rowsMagnus Hagander
Needed to store actual real world error messages.
2020-03-24Catch exceptions when issuing API refunds for invoicesMagnus Hagander
Instead of crashing the cronjob, catch the exception and log it. This allows the script to proceed with further refunds if one fails.
2020-03-12Replace datetime.now() with timezone.now()Magnus Hagander
As a step on the way to better timezone support, use the django function timezone.now() instead of datetime.now(). As long as we haven't enabled timezones globally this becomes a no-op and does exactly what it did before, but once timezones are enabled it will generate datetimes that are aware of this. No functionality change but gets a lot of boiler-plate out of the way making the verification of the rest of the timezone work easier.
2020-02-22Add Generic Managed Bank AccountsMagnus Hagander
This is a subset of the managed bank accounts to handle the case where no API or scrapers exist, but there is a "reasonable format" available for downloadable transactions. For these, the file format definition can go in a JSON file instead of requiring specific code for each banks format. This centralizes a bit of the code written specificaly for the pgeu bank and kept in a separate repository, and makes it more configurable to suit the regular case. In doing so, also create the concept of a BankStatementRow that contains the actual output from the bank files. This was previously handled independently by each django app for different payment providers, making it hard to provide a good generic view. And finally, also create generic views to see this set of bank statement rows coming out of the files, so it's possible to follow things up. For now this can be filtered by file (which file did these transactions come from) or just by payment method ("all transactions for this bank account"). This can be extende din the future to cover more advanced filters and searching. Include generic parsers for Credit Mutuel (the one previously living in code form in the pgeu repository) in France, SEB and Swedbank (both in Sweden).
2020-02-09Verify that integer parameters are integers at an early stageMagnus Hagander
Previously we'd in many places pass down the value directly from get or post requests to a lower layer, only to have that layer throw an exception because it wasn't an integer, or we'd ust wrap it in int() which also causes a hard exception when it's not an integer. Instead create a small wrapper for get_int_or_error() which can be called with a parameter that's supposed to be integer, and will then just return a 404 if the parameter doesn't exist or is not an integer. These are all "should never happen" scenarios, so not generating hard crashes and stackdumps are an improvement. None of these were places where the actual bad data would get anywyhere, they would all just cause an ugly exception, but should get fixed regardless. One or two instances spotted by Daniel Gustafsson, and then a lot of grep to try to find most of the rest.
2020-02-08Guard against missing parametersMagnus Hagander
There were a few places that directly accessed request.GET/POST without verifying that the parameter actually existed first. This would cause a hard 500 internal server error -- so to make that nicer, instead look for them and exit with a 404 if the data is incomplete.
2020-01-30Delegate decoding of uploaded bank files to implementationMagnus Hagander
In particular, this removes the global hardcoding of files being utf-8, instead allowing each implementation to figure that out from the contents (or just from knowing it).