summaryrefslogtreecommitdiff
path: root/postgresqleu
diff options
context:
space:
mode:
authorMagnus Hagander2018-12-11 06:45:18 +0000
committerMagnus Hagander2018-12-12 02:11:56 +0000
commita82f1cc2635c7c258478de4d9d88303d092ecccc (patch)
treeb57b95f09af2d4a6cd7c6b2cb549c6a5675d6267 /postgresqleu
parent8d338454cf281cd8792a90d7eba301720195548a (diff)
Fix braintree dependency in invoice paidusing
We can't apply the braintree SQL if there is no braintree module installed...
Diffstat (limited to 'postgresqleu')
-rw-r--r--postgresqleu/invoices/migrations/0002_invoice_paidusing.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/postgresqleu/invoices/migrations/0002_invoice_paidusing.py b/postgresqleu/invoices/migrations/0002_invoice_paidusing.py
index cf0a9bd2..b2c9f6f8 100644
--- a/postgresqleu/invoices/migrations/0002_invoice_paidusing.py
+++ b/postgresqleu/invoices/migrations/0002_invoice_paidusing.py
@@ -2,6 +2,7 @@
from __future__ import unicode_literals
from django.db import migrations, models
+from django.conf import settings
class Migration(migrations.Migration):
@@ -9,10 +10,14 @@ class Migration(migrations.Migration):
dependencies = [
('invoices', '0001_initial'),
('adyen', '0001_initial'),
- ('braintreepayment', '0001_initial'),
('paypal', '0001_initial'),
]
+ if settings.ENABLE_BRAINTREE:
+ dependencies.append(
+ ('braintreepayment', '0001_initial')
+ )
+
operations = [
migrations.AddField(
model_name='invoice',
@@ -22,7 +27,10 @@ class Migration(migrations.Migration):
migrations.RunSQL("UPDATE invoices_invoice SET paidusing_id=(SELECT id FROM invoices_invoicepaymentmethod WHERE classname='postgresqleu.util.payment.adyen.AdyenCreditcard') WHERE EXISTS (SELECT 1 FROM adyen_transactionstatus WHERE notes='PGEU' || invoices_invoice.id AND method != 'bankTransfer_IBAN')"),
migrations.RunSQL("UPDATE invoices_invoice SET paidusing_id=(SELECT id FROM invoices_invoicepaymentmethod WHERE classname='postgresqleu.util.payment.adyen.AdyenBanktransfer') WHERE EXISTS (SELECT 1 FROM adyen_transactionstatus WHERE notes='PGEU' || invoices_invoice.id AND method = 'bankTransfer_IBAN')"),
migrations.RunSQL("UPDATE invoices_invoice SET paidusing_id=(SELECT id FROM invoices_invoicepaymentmethod WHERE classname='postgresqleu.util.payment.paypal.Paypal') WHERE EXISTS (SELECT 1 FROM paypal_transactioninfo WHERE transtext LIKE 'PostgreSQL Europe Invoice #' || invoices_invoice.id || ' - %')"),
+ ]
+ if settings.ENABLE_BRAINTREE:
+ operations.append(
# Our Braintree plugin doesn't keep enough details to do a direct matching, so we do
# a fuzzy match based on our process taking less than 1 second. Which should be safe.
- migrations.RunSQL("UPDATE invoices_invoice SET paidusing_id=(SELECT id FROM invoices_invoicepaymentmethod WHERE classname='postgresqleu.util.payment.braintree.Braintree') WHERE EXISTS (SELECT 1 FROM braintreepayment_braintreetransaction WHERE (paidat-authorizedat) < '1 second'::interval AND (authorizedat-paidat) < '1 second'::interval AND total_amount=amount AND authorizedat IS NOT NULL AND paidat IS NOT NULL)"),
- ]
+ migrations.RunSQL("UPDATE invoices_invoice SET paidusing_id=(SELECT id FROM invoices_invoicepaymentmethod WHERE classname='postgresqleu.util.payment.braintree.Braintree') WHERE EXISTS (SELECT 1 FROM braintreepayment_braintreetransaction WHERE (paidat-authorizedat) < '1 second'::interval AND (authorizedat-paidat) < '1 second'::interval AND total_amount=amount AND authorizedat IS NOT NULL AND paidat IS NOT NULL)")
+ )