Brexit and the next Thalidomide

The story of Thalidomide is a very dark tale. It caused abnormal fetal development, which was a tragedy, a terrible unexpected side effect of what was otherwise quite an effective medicine — but that wasn’t the scandal. The scandal was the failure to quickly link cause and effect and then to fail to distribute the information learned to prevent further individuals and their families from being affected.

We are now approaching 60 years from October 1st, 1957 when it first went on sale in Germany. The world has changed a lot since then. Thalidomide is making a cautious return and there are projects monitoring and analysing congenital defects across a wide area. In other news, last year the UK voted to leave the European Union, which means we need to talk a bit more about those last two links.

The European Medicines Agency is based in the UK and will be relocating to be based in the European Union. That agency licenses drugs for use in humans. Given that there are not 28 different types of human across the EU it seemed sensible to have some coordination on evaluation and licensing so it gets done once rather than 28 times. Post Brexit we will presumably have to have more of that functionality here, probably paid for out of the NHS budget (oh, you thought that was going to go up did you?).

The second link is to one of many projects that are part of the Horizon 2020 research funding scheme. Data about all of these is available on the Cordis website and you can see all the projects being coordinated by the UK, many of which have an end date after Brexit day. One of them is EUROLinkCAT which is let by Queen Mary university in London and it attracts a total of €7,348,072.75 over 5 years from the start of this year to the end of 2021. That is committed money. There will be a contract (probably several) promising that money to the project from the EU. We, as a member state, committed to that project, and we are a beneficiary of the money funding activity here and also a beneficiary of the output — amongst other things they are looking for the next Thalidomide so that if there is some combination of drugs and environmental or genetic factors that result in a subtle risk of increased congenital abnormalities then it gets spotted sooner and the tragedy isn’t followed by a scandal. It is about doing joined up work studying the topic of early years care of these patients and looking for risk factors across a wide area because it works better that way with a larger corpus of data.

The Brexit press, the media and many Brexiters are currently apoplectic about “divorce bills” and even “reparations” and “punishment beatings” with figures of €60bn or €100bn being waved about and rubbished with declarations that we will walk away and we won’t pay a penny. It is fucking stupid and those Brexiters need to grow up and engage in the detail of the conversation about Brexit and stop flinging out inaccurate emotive bullshit about what the cost of their decision may turn out to be. The settling of accounts is about what we do with projects that we have committed to funding both in the UK and around Europe. There is absolutely no point expressing an opinion on whether €60bn is too much or too little as a whole. It is made up of lots of things, each one we can choose to pay for, we may be able to choose to own it, or we can choose to dispute either the outstanding value or indeed whether it is our problem. Once you have gone through the detailed commitments and decided what to do then you can add up all the things you want to pay for and that is the number we write on the big cheque. You can’t go from the top down just because you don’t like engaging in detail.

The EUROLinkCAT project runs for 1825 days, 1005 of which are after Brexit day. If it is funded continuously then that is €4,046,472.93 in post-brexit funds that we have committed to as a pre-Brexit member state. What are we going to do? The EU starting position is that we pay a closing lump sum for our share to the EU and the EU funds the project until the end of the commitment. This particular project runs past the end of the MFF, does that make a difference to the point we stop funding it? If we don’t want to do that, we could propose that we fund our share of the cost directly. That takes it out of the visible “bill” because we decided to own it. It isn’t clear that the other member states would allow us to pay our share directly — the contract that the project has is with the EU, not us. For some projects taking ownership of the issue and funding direct might be more acceptable than others. Ultimately deciding to own something is just a political move in order to get the visible bill down, it doesn’t save the taxpayer anything in the end. The final option is to dispute it. We say that we don’t care about research into congenital abnormalities, we declare that we are a sovereign nation and can’t be forced to pay for stuff we don’t want. We tell the EU they can pay for it themselves, or move it to somewhere else, or can the whole thing, because we just don’t care. We are not going to look at the results, if we feel like it we might do our own red white and blue research into the topic at some point. This approach could be fairly described as a dick move by someone who clearly hates babies.

There are quite a few projects like that one in Horizon 2020 where we are the coordinating state. Someone needs to go through them and decide to pay/own/dispute each one. All the projects that the UK is not coordinating are also things we committed to under the EU budget, such as this one on understanding the cultural heritage of dissent in former socialist countries where there is some participation from Oxford but the project is run from Hungary. It isn’t just Horizon 2020, there are also the regional development projects, roads, bridges, tunnels, public transport etc. We might decide that a new bridge in Poland is something we don’t want to pay for but we committed budget to it as a full member state every bit as much as we committed to our joint funding obligation for the congenital abnormality project that is coordinated from London.

Once they have decided whether or not they hate babies, they also need to go through things like pensions of our MEPs and officials (all those UKIP MEPs get a pension that is in the “brexit bill” — you will hear them declare we should refuse to pay anything, but I have not heard them declare that they shouldn’t get their pensions.)

Perhaps after deciding whether or not to pay people pensions they will move on to discuss agricultural subsidies. The biggest chunk of money the EU spend in the UK is on the single farm payment. On this one there is some semblance of an answer, we have been told that HMRC will pay that at current rates through to at 2020 (the end of the MFF). This is a chunk of money that is an EU committed payment in the MFF that we will decide to own. That takes it out of the headline figure but note that it also takes it out of the mythical £350 million a week. It saves the taxpayer no money to pay this directly, but reduces the “bill” for political purposes.

Basically every plausible line item in the bill will be enumerated, we then decide to pay/own/dispute each one. If you sum the lot you get to a big figure, but you first have to go through the process of line by line decisions, this could be done quite quickly if we choose to pay most of it (owning and disputing are slower). Walking away from the table does not make the bill zero and does not mean we “fall back on WTO rules”. We don’t. WTO rules is the baseline for states in good standing. If we walk out on our obligations it may get treated as a sovereign debt default, our credit rating would be slashed and if we behave badly on trade matters the WTO can authorise sanctions against us, meaning that we don’t get most favored nation terms. None of this “remoaner project fear” stuff needs to happen, if the Brexiters grow up and re-engage with their problem. If paying loads of money to settle our outstanding commitments gets us the Brexit they wanted then great, I look forward to measurable benefits being discovered in 2019. In the meantime we have a very wide ranging damage limitation exercise to do.

Leave voters need to stop banging on about whether they will or won’t pay the grand total. They need to tell us whether or not they want to pay for continuously monitoring for another Thalidomide style scandal. They need to start to engage at a detail level. Walking away does not mean that the commitments we have made evaporate. It means that we defaulted on our payments. The question isn’t “do you want to pay €60bn?”, the question is “How do you intend to address all these individual things you appear to have committed to funding over the next several years which taken together tally up to around €60bn?”. Walking away from the table settles the question of whether you hate babies but it doesn’t settle the question of what to do with the commitments we have made.


Update!

Today the government published a document on their intended future relationship with the EU on the topic of science. https://www.gov.uk/government/uploads/system/uploads/attachment_data/file/642542/Science_and_innovation_paper.pdf

The UK recognises the need to provide certainty to all stakeholders wherever possible. This is why the Government has committed to underwrite bids for Horizon 2020 projects submitted while the UK is still a member of the EU. The UK will work with the Commission to ensure payments when funds are awarded, and Horizon 2020 participants should continue to collaborate as normal. The UK Government will continue to work closely with the Devolved Administrations who play an important role in administering Horizon 2020.

So, this is progress, of a sort. This seems to be an intention to de-commit the EU from funding UK participants in Horizon2020 projects after Brexit day. The UK will take ownership of making payments to UK projects on the existing payment schedule. I am not entirely clear what “underwrite bids” means, but that is my best guess.

Jeremy Hunt on AEO status post-Brexit

Brexit is a fountain of bad ideas, but sometimes one pops out that is so strikingly stupid I can’t let it pass without comment. So went the appearance of David Davis at a select committee last month. You can watch the whole thing on the rather excellent parliamentlive.tv archive

http://www.parliamentlive.tv/Event/Index/a44440b6-2864-4e28-9150-518e1ddfa5bc

It was this session where David Davis was asked about what would happen if there was not a deal on the future relationship with the EU within the article 50 timeframe (the clock is ticking) and he rabbited on about how customs clearance is not a big deal as most consignments are cleared within 5 seconds. This is indeed true at the moment, because we are a member of the EU. It isn’t much of a mitigation strategy for not being a member of the EU. It sounded daft, so I checked the details and wrote to my MP.

Friday 17 March 2017

Dear Jeremy Hunt,

my quest to sell the house and get out of the country continues, but whilst I am still here, I note that David Davis said in the exiting the EU select committee on Wednesday that in the event that there is no deal with the EU there are mitigation strategies that could be put in place, one of which would be using and expanding the authorised economic operators scheme down to smaller companies.

http://data.parliament.uk/writtenevidence/committeeevidence.svc/evidencedocument/exiting-the-european-union-committee/the-uks-negotiating-objectives-for-its-withdrawal-from-the-eu/oral/48859.html

in response to Q1383

This scheme is not going to be open to UK companies, it has a base in law under EU regulation 648/2005 and is an EU scheme for companies established in the customs territory of the Union:

http://ec.europa.eu/taxation_customs/general-information-customs/customs-security/authorised-economic-operator-aeo/authorised-economic-operator-aeo_en#who_can_become

Who can become AEO

Any economic operator established in the customs territory of the Union who is part of the international supply chain and is involved in customs-related operations, may apply for the AEO status.”

On Brexit day our economic operators will not be established in the customs territory of the Union. Deal or no deal. It is plausible that we could set up our own scheme and ask for a mutual recognition deal, but it is flat out insane to say that a mitigation strategy of having no deal is to use one of the key benefits that we have that derives from our status as an EU member. 
This is dangerously stupid, someone needs to provide some adult intervention here or we are going to have serious trade disruption and food shortages in our country.

Yours sincerely,

Alan Bell

and today he replied

Dear Mr Bell

Thank you for contacting me about the EU customs area.

You are right that the EU has established its Authorised Economic Status (AEO) concept. This means that the AEO status granted by one member state is recognised by customs authorities across the EU. Although the EU’s AEO concept is only open to countries in the EU customs union, the EU has already agreed the mutual recognition of AEO programmes with third party countries including Switzerland, Japan and the United States. This makes customs clearance easier and more efficient.

As I am sure you can appreciate, I would not want to pre-empt the negotiations by committing to precise details on future trading relationships. I can assure you, however, that the Government will be working to achieve the best possible deal for UK companies to trade with and operate within European markets.

Thank you again for taking the time to contact me.

Best wishes

Jeremy Hunt

So, this means that if we are going for a mutual recognition deal, they are expecting on day 1 of Brexit that the EU will fully recognise a completely untested significant IT system that doesn’t yet exist, and that we have no current plan to build as we are going to see what pops out of the negotiations first before specifying it. This is still in no way whatsoever a reply to the question about what happens in the event of “no deal”.

Some costs of Brexit

Today we see that the European Parliament has passed a resolution saying that the UK must pay for “financial costs arising directly as a result of the United Kingdom’s withdrawal”. We also find out today the unsurprising news that the European Banking Authority and European Medical Agency are going to have to leave London and relocate. Now it is quite possible that this is going to incur a financial cost, that is directly as a result of the stupid decision to leave the EU. No doubt this will be described as a massive unwelcome surprise to the government and press. It will not however actually come as a surprise to Jeremy Hunt or DExEU because I wrote to them in September pointing this out.

Thursday 8 September 2016

Dear Jeremy Hunt,

Could you please ask DExEU which department budget will be called upon
to fund the relocation of the European Banking Authority and the
European Medicine Agency should they have to be moved to a different
country and the UK is found to be liable for relocation costs. I do
hope that as minister for health you would resist the EMA relocation
costs being paid from the NHS budgets.

Yours sincerely,

Alan Bell

I should probably include his reply, hardly seems worth it though:

Many thanks for your email regarding UK withdrawal from the EU. We are about to begin these negotiations and it would be wrong to set out further unilateral positions in advance. At every step of these negotiations we will work to ensure the best possible outcome for the British people.

Thank you once again for writing to me.

Best wishes

Jeremy Hunt

She was warned, she was given an explanation, nevertheless, she persisted

Earlier this month I wrote an email to Lord Bridges of Headley, with some suggestions on how to make Brexit a tiny bit safer. Today, in the post I got a letter in reply (on fancy paper and everything). The reply basically regurgitates stuff we already know from the white paper and speeches, it is the government line. That said, they got my email, someone read it, and they will carry on regardless.

Thursday 2 February 2017

Lord Bridges of Headley House of Lords London SW1A 0PW

Dear Lord Bridges of Headley,

I do want you to make a success of Brexit, but I just don’t think the government is going in the right direction. There are some steps you could take to reassure people that the government has got the capacity to do the work required.

I want the government to present a fully worked example of how they would calculate our external schedule of tariffs and quotas for several interesting products (beef & citrus perhaps as that touches on quantitative tariff breaks and seasonal protectionist tariffs for a product we don’t produce), and a plan on how they intend to complete that work in the two year timescale before starting the clock ticking.

The second thing I want them to do is to present a fully worked example of transposing an EU regulation into UK law, as they intend to do under the great repeal act. This would expose various problems and things that become illegal to do in the UK under UK law because we are not a member state, or it would require our courts to notify EU member state courts in ways that can’t be reciprocated if we are not a member state etc. Plus they should present a plan on how they intend to complete that work in the two year timescale before invoking article 50.

Thirdly I would like the government to explain in detail what a transitional arrangement is. What goes on the front cover of the document it is written in? Who is a party to it? What gives it legal effect? What can and can’t be covered in a transition. Normally transitions are written in the destination treaty, if we are going to WTO rules then there is no destination treaty in which to write them. The government needs to explain how they think this will work before invoking article 50.

None of these in any way whatsoever expose the government’s negotiating strategy or weaken our position. Every one of them strengthens the credibility of our “walk away” option.

Yours sincerely,

Alan Bell



The Somalia Option for Brexit

Everyone is curious to see what our intrepid team of brexiteers will come up with. Will they go for the Norway option, with free market access, but free movement of people budget contributions and no input into regulations (not so much take back control, but give up control). That doesn’t sound like it is what people voted for.

Maybe we want the Switzerland option, with free movement of people and a lack of access for the banking sector and services — well that could screw London quite badly and it isn’t what people voted for.

How about the Canada option? Well CETA was on the way as a comprehensive trade agreement with the EU, but it isn’t in force yet, and it needs completely rewriting because if we leave we would probably want to take our portion of the tonnage of potted shrimp and suchlike with us (this is what the Article 50 negotiations are going to be about, carving out the UK portion of existing trade agreements). CETA doesn’t include services and took years to put together, and now it is all wrong. It isn’t a good template to use to draw up a UK/EU trade agreement.

How about the default, full Brexit to WTO rules? Well that means tariffs and it means the EU must impose tariffs on us or they can’t impose tariffs on other WTO members because they have to give all WTO members the status of their most favoured nation. We can’t be more favoured than Singapore for example or any external tariffs the EU is imposing on Singapore become illegal.

You might think that we have run out of options at this point, but no! There is one left. With the Unilateral Continuity option we just leave the EU but say we want to have informal tariff free trade with the EU, whilst reserving the right to impose tariffs elsewhere if we want to. This is completely contrary to the principals of global trade since the 1948 General Agreement on Tariffs and Trade, and puts us in an extremely exclusive group of countries. I call this the Somalia option.

A second Brexit referendum won’t work

The referendum on the membership of the EU was non binding, it had no significance in law. It is an advisory instruction to the government, the legal significance is the invocation of article 50. If we have a second referendum then there will be two, non-binding advisory instructions to the government. This does not move us any further forward, even if the second referendum is to remain and not tear up the Good Friday agreement (which really should have been the text on the ballot paper). There is a petition for a second referendum, I signed it because, well, why not, but it won’t work. It doesn’t ask enough.

David Cameron fell on his sword to give us a few months time before invocation of article 50. His resignation wasn’t the important bit, kicking the can down the road a bit was the important part of that speech. As a Financial Times journalist put it, the shock resignation of the Prime Minister was the third most important story of the day. David Cameron is still our Prime Minister and he still can do one last thing to help our country. He can recall parliament and propose a motion “That there shall be an early parliamentary general election.” as set out in the fixed term parliament act 2011 http://www.legislation.gov.uk/ukpga/2011/14/section/2/enacted this needs a 2/3 majority of the house including vacant seats — and lets all take a minute to think about why there is a vacant seat and whether Farage won a victory without a shot being fired.

I call upon David Cameron to propose a three line whipped motion that there shall be an early parliamentary general election.

Leaving this to the next prime minister is insufficient, Boris wants to be Winston Churchill — just watch him lower his voice like Jim Hacker on Yes Minister when saying something that he things is statesmanlike. Europe want us to invoke article 50 soon, the only way we can fail to do that is if we have no government. The government needs to collectively fall on it’s sword. After that we get a snap election, where a party can stand on a platform of setting aside the referendum result and never activating Article 50 and attempting to put this basket case of a country back together. We need to accept the reality that this party of national unity might be the SNP standing in every UK constituency.

The other paths to peace that I see are very narrow. We could invoke article 50 and as part of the exit negotiation Scotland gets the remnants of our membership, they join the Euro and Shengen, and they take Northern Ireland with it’s current borders and redraft the Good Friday agreement as close as they can to the status quo. That way the border does not change (if it changes at all it will need to be re-militarised), free movement does not change and with the Euro trade over the border is a bit smoother. England goes it’s own way in an isolated economic spiral over 15 years with external borders north and south until it is annexed by Scotland. Argentina gets shared sovereignty over the Falklands, Spain gets shared sovereignty over Gibraltar. We accept the end of the Le Touquet agreement and set up a refugee camp in Dover (I do expect the Jungle to disperse and net migration to go negative as England is a deeply unattractive destination). England and Wales is done, stick a fork in it.

The current personality based movements in the shadow cabinet are a pointless distraction. The priority is preventing article 50 being invoked by the government.

None of this can happen this week, because too many people who voted leave don’t realise the consequences of what they did yet. We are going to have to wait a few weeks until opinions change and the baseless optimism is fully exposed. Specifically, it will be after George Osborne comes out from his cave and tells us how HS2 is gone, how Trident renewal is off the table (good, and Trident scares me right now) how we have no new schools or hospitals, road maintenance and building has gone and wages are frozen in education and the NHS.

Brexit and the tampon tax

The #Brexit campaign has got one argument that I can’t refute. They don’t talk about it much, but they should because it is, as far as I can see, pretty solid.

There has been for some time a campaign to zero rate VAT on feminine hygiene products in the UK, on the quite reasonable basis that tampons are not a luxury item, they are a necessity and paying VAT on them is a bit of an affront. As a member of the EU we can’t do that, there are very specific rules on minimum VAT rates (we have some historic exemptions that other countries don’t like us having) and VAT is deeply tied in to our membership (for example, the rebate we get that means we don’t pay £350 million per week is based on a complicated formula involving VAT and GDP https://en.wikipedia.org/wiki/UK_rebate). We can negotiate some stuff around VAT, and occasionally ignore bits (HMRC decided to officially not bother with enforcing the place of supply change on digital VAT for non-registered small businesses) but adding a new class of zero rated products just isn’t going to happen, the other members of the club won’t let us. VAT was dropped on tampons from 17.5% to 5% back in 2000, but getting it to zero is for the moment a step too far. George Osborne’s compromise, or acknowledgement of the issue, was to use the VAT raised to fund women’s charities and shelters to the tune of about £12 million a year — not very satisfactory to some. They are still lobbying the commission over the issue, but it would take a proposal backed by all 28 members to get it through, not impossible but very hard indeed.

If we were to Brexit, we would absolutely be able to zero rate tampons as soon as we left (about 2 years). So there you go #brexit advocates, if you want a fact based economic argument for something that we could, should and would do after brexit that we probably can’t do from within the EU then you had best start talking about menstruation because that is all you have got.

Jeremy Hunt on #ipbill

I wrote to my MP, who happens to be the Health Secretary but you can write to your constituency MP about anything, best way to do it is through https://www.writetothem.com/. I tend to write about one specific actionable point, even if it isn’t the biggest issue on the subject. This time the subject was the return of the snoopers charter, the Investigatory Powers Bill.

Dear Jeremy Hunt,

I am concerned about the draft Investigatory Powers Bill.

"Section 51 Whilst everyone has a right to privacy, certain professions handle particularly sensitive or confidential information, which may attract additional protections. These professions include medical doctors, lawyers, journalists, Members of Parliament and the devolved legislatures, and Ministers of Religion."

One of these things is not like the others, one of these things does not belong. Ministers of Religion should not have a privileged status here, Abu Hamza, Anjem Chowdry, other radical clerics and the paedophile priests of all denominations do not deserve more hurdles protecting their privacy than I do.

Please work with your colleagues to remove Ministers of Religion from the list of sensitive professions.

I can't say I am a fan of the bill overall, it seems rather naïve about the nature of encryption.

Yours sincerely,

Alan Bell

and he wrote back, completely and utterly failing to address my point.

Dear Mr Bell

Thank you for contacting me about encryption.

The Government recognises the importance of encryption. I agree it is vital in keeping people's personal data and intellectual property secure and ensuring safe online commerce and communication. Current law requires that companies must be able to provide targeted access, subject to warrant, to the communications of those who seek to commit crimes or do serious harm in the UK or to its citizens.

It is true that the growing use of encryption does present a significant challenge. However the Government does not advocate or require the provision of a back-door key or support arbitrarily weakening the security of internet applications and services in such a way. Such tools threaten the integrity of the internet itself. The current legislation already requires that companies providing services to UK customers must be able to comply with a warrant and I am assured that the Government intends to preserve that position.

The draft Investigatory Powers Bill, which will be subject to scrutiny by a Joint Committee of both Houses of Parliament, will not introduce any new powers relating to encryption.

Best wishes

Jeremy Hunt
--------------------------------------------
Rt Hon Jeremy Hunt MP
Member of Parliament for South West Surrey

Well, that was quite unsatisfactory, so I wrote back.

thanks for replying, but it seems you didn’t address my specific and actionable point.
Section 51 of the draft investigatory powers bill gives radical clerics more protection over their privacy than I have for mine. Why is this? Why does the bill privilege radical clerics and other ministers of religion above anyone else? Can you please press for the removal of the privileged status of ministers of religion under this bill.
"Section 51 Whilst everyone has a right to privacy, certain professions handle particularly sensitive or confidential information, which may attract additional protections. These professions include medical doctors, lawyers, journalists, Members of Parliament and the devolved legislatures, and Ministers of Religion."
Alan Bell.

turns out if you are persistent you get results, this time it seems he read the mail.

Dear Mr Bell
Thank you for your further email. As you have mentioned, Section 51 includes Ministers of Religion as a profession that may attract additional protections as such people do tend to handle particularly sensitive or confidential information. Let me assure you that there are many measures in place to make sure extremist preachers cannot spread their message of hate. The new Counter-Extremism Strategy is a clear signal of the choice to take on the poisonous ideology of extremism with resolve, determination and the goal of a building a greater Britain. The strategy follows the 4 key pillars set out by the Prime Minister last July: to counter extremist ideology; to support mainstream voices, especially in our faith communities and in civil society; to disrupt extremists, aggressively pursuing key radicalisers; and to build more cohesive communities, tackling segregation and feelings of alienation.
Thank you again for taking the time to contact me.
Best wishes
Jeremy Hunt
 — — — — — — — — — — — — — — — — — — — — — — 
Rt Hon Jeremy Hunt MP
Member of Parliament for South West Surrey

so, second part of that is a bit of a brush off, but I think the point got through. Radical preachers are on the same level as politicians, journalists, doctors and lawyers under this bill, so either the protections for all of these are meaningless, or the bill really misses the very people it is allegedly aimed at.

How I compute a convex hull

I have a bunch of points defined by their x and y position, in my real world scenario these are points on the ground where a van will go and deliver some stuff, the x and y positions are actually latitude and longitudes. I want to draw on a map a polygon showing the area containing the dots. There are actually different sets of dots where different vans go, so I will be putting lots of these polygons on a map and I want to show the areas covered by each van, but we can focus on the way to do just one van at a time. I don’t want the polygon to be all spikey, I want it to be what you would get if you put a rubber band around the points and it turns out this is called a convex hull.

The locations of the points are held in a mysql database and the latitude and longitude columns are indexed, this means I can do very fast queries that involve sorting or comparing these values. I know there is a computational cost for sorting and comparing things, but I don’t care about it, it is probably O(log n) in terms of complexity and it is fast and easy. I don’t really want to calculate angles at all because that involves doing more trigonometry than I can be bothered to remember.

Start at the most northerly point

select * from points order by lat desc limit 1;

From the points to the west choose the most northern one. — repeat this step until you are on the most western point.

select * from points where lng < ? order by lat desc limit 1;

From the points south of this one, select the most western — repeat until on the most southern point

select * from points where lat < ? order by lng asc limit 1;

From the points to the east of this one, select the most southerly — repeat until on the most eastern point

select * from points where lng > ? order by lat asc limit 1;

From the points to the north of this, select the most eastern point — repeat until back at the most northerly point that you started from.

select * from points where lat > ? order by lng desc limit 1;

This doesn’t necessarily give you a strictly convex hull, but it does give you a shape that water would run off even if rotated 90/180/270 degrees. This is actually good enough for my purposes but you can then do a second pass around the path you have calculated and check for convexness without doing any angles by taking three points at a time and checking to see if the middle point is left or right of the line connecting the first and last point, this can be done with simple maths and no angles with a function somewhat like this:

function convex(p1,p2,p3){ return (p2.lat-p1.lat)*(p3.lng-p1.lng)-(p2.lng-p1.lng)*(p3.lat-p1.lat)
}

If that returns a negative value then discard the middle point from the polygon (I may have that the wrong way round). This test could be done as you go along as part of the first walk around the path.

Here is what it looks like for my data, without doing the second pass for strict convex shapes.


May You Live in Interesting VAT Times

Accountancy is not very exciting in general. If you arranged all the subjects within the topic of accountancy in order of excitingness, VAT would not be at the more thrilling end of the scale. This will remain the case until the end of the month, when on January 1st 2015 the European Union will introduce some changes to perk up VAT and make it much more exciting! Yay!

So, what is VAT anyway and who has to care about it? Well, VAT is short for Value Added Tax, from a consumer standpoint this name makes no sense, it just looks like a tax on the sale price, what is the “value added” bit all about? Well it starts to make a bit of sense when you think about a VAT registered business that buys things, does something to them and sells them again for more than they paid in the first place.

The VAT the business pays for the goods is “input tax” and they can claim that back from HMRC. If a business buys a widget for £12, then HMRC owes the business £2 for the VAT they paid out. The business will then typically do something to the product, which might be a manufacturing process using it in a component of a bigger product, or it might be splitting a big pack into little packs, or simply putting the product in a shop. Whatever the in between bit is, lets say this product ends up being sold on for £15+VAT. Someone walks into the shop and pays £18 and walks out with their widget. Now the business just collected £3 in VAT from the consumer, so the business owes HMRC £3, and they can offset the £2 that HMRC owe them. The net result is the business owes HMRC £1, which is a 20% tax on the £5 improvement or “value added” to the product as it passed from input to output. The chain from raw materials to consumer can be quite complicated, and HMRC collects 20% of the value added from each business in the chain, ultimately this is paid by the consumer in the purchase price, but it is shared back along the supply chain in proportion to the amount of improvement each element of the chain made to the product in terms of it’s price. You might wonder how this applies to digital goods, where there are no clear raw materials or an obvious supply chain but as VAT looks at your total inputs and total outputs, it does kind of work. If you buy a computer and a desk and a chair, these are allowable expenses for your ebook business, they are the raw materials. They each have a supply chain behind them, so the VAT you pay to HMRC is the amount you collect on the ebooks, less the amount of VAT you paid on the computer/desk/chair. You pay to HMRC a proportion of the value you added to the equipment by sitting at it and writing an ebook.

It is quite a clever system and only really gets complicated when you have international trades involved. If that happens when you are buying stuff as a business you have to do a “reverse charge supply” this means you pay the tax on things you buy at UK VAT rates to HMRC (instead of the supplier paying them out of the gross price), and then claim it straight back again as input tax. It is a paper transaction, no money changes hands, just some boxes to fill in for the VAT return. It is just like buying goods from a UK supplier except the VAT portion doesn’t get paid to the supplier, it gets paid to HMRC. If you are selling to a business overseas you sell it and don’t put VAT on it. They then have to do the reverse charge thing and pay their local VAT to their local VAT office and claim it back as input tax. The UK business then needs to fill in an EC Sales list with the VAT numbers of the customers so that it can be audited and someone can check that the customers are in fact paying and reclaiming the VAT.

Now, this is all fine, bit odd perhaps, but it works. A UK business can sell stuff with 20% VAT and pay that over to HMRC, this is always a safe thing to do. They don’t need to know who the customer is, or where they are, it is always safe to sell for one price including the VAT and hand over the collected VAT to HMRC. If the customer happens to be in Europe that is fine. If they are a business in Europe then they are paying 20% too much, and that is still fine. Slightly too much VAT is collected and nobody cares. Perhaps if a Europe VAT registered business wants to not pay UK VAT in addition to their local VAT then they can arrange to get a zero VAT invoice for the goods, but if they don’t do that, they can pay the VAT inclusive price and nothing bad happens.

“Nothing bad happens” is what we want in business. From January 1st, this position evaporates. Bad things can happen. Really bad things. There are very few ways to avoid bad things happening. The change is small, the consequences drastic. They are changing the place of supply. This means that instead of charging VAT according to where the seller is, VAT is charged according to where the purchaser is. Simples!

This tiny little change has ramifications and unintended side-effects. What they wanted was to stop multi-nationals like Amazon and Google from incorporating in Luxembourg as a flag of convenience and selling around Europe from there at the lower Luxembourg VAT rate. Nice for the Luxembourg exchequer, but really a bit unfair to everyone else. These companies manage to undercut domestic UK businesses and all the VAT paid by the UK consumer was whisked out of our economy. This change of the place of supply means that the UK taxpayer is better off, tax on stuff we buy here stays here. The huge companies have to stop hiding in Luxembourg and register in the places they actually trade and pay their taxes.

Trading with the EU is completely optional, see https://www.gov.uk/trading-in-the-eu the founding point of the EU is to make it easier to trade across the borders you decide to trade across. The internet makes it easier to trade without caring where the borders are, which goes somewhat further. This move brings things back to a requirement to have a deliberate intention of operating in a market, and then it is as easy as the EU designed it to be, but not as easy as the internet makes it. Accidental trades across borders could now shut your business down, you could get penalties from 27 separate VAT regimes.

There are in fact 75 potentially different VAT rates across the EU. Different countries have different rates for various classifications of items. (Jaffa cakes are not biscuits in the UK, for example, but they might be different elsewhere). You now need to care about all of this. Did you know about the VAT rate on ebooks in Italy? Are you preparing to change your store for the Polish VAT cut in 2016? No? Do you want to have to care about that?

In this new world order with the changing place of supply companies are supposed to capture two bits of non conflicting evidence to suggest where a customer is located, and then charge the relevant VAT. This means you need to know what the relevant VAT would be, and you need to know where the customer is prior to the payment happening. If you were hoping that you would use the paypal billing country you get after payment then you are kinda late, you have charged them the wrong price. It is a big problem and other people have written about how big a problem it is in more detail than I want to. EU VAT Action has a great list of articles expanding on the problem.

Don’t bring me problems, bring me solutions!

So yes, that is a big old mess, lots of people are very worried about the implications and practicalities of finding out where your customers are and accounting for the VAT, but is there a simple solution? Well yes, there is, and it is perhaps a bit surprising.

I propose we introduce, very soon, a new special rate of VAT. The Default EU VAT. This would be set at 30% for all member states, and would be legal (but optional) to collect on all transactions and remit to a VATMOSS. This VAT fund would then be distributed to all the member states in proportion to population (or GDP or whatever other distribution methodology they negotiate). Businesses can safely list prices and sell goods to anyone including this rate of VAT, but if a customer wants to get a lower price then the customer can provide two bits of evidence to support their claim to be in a particular member state, they will then be shown the prices including their local VAT rate and can buy things for less money. This way we retain the freedom of anonymous trades, but customers have a financial incentive to give up some of that anonymity for lower prices and a more accurate allocation of tax. Nobody need ever pay this 30% rate, it’s sole purpose is to remove the risk of collecting too little VAT when the place of supply hasn’t been established. It also means that completely anonymous trading is legal (but a bit more expensive). I belive this is a proposal that all 28 countries could agree on very quickly. Thresholds simply are not going to happen, but this could be politically agreed and implemented across Europe without delay.

Why 30%? Well it is higher than any standard VAT rate, and it is exactly double the EU statutory minimum standard VAT rate of 15% that all countries have to comply with. Setting it at double the 15% means it will automatically change if the minimum statutory rate changes.

Shouldn’t HMRC/UK Government do something?

Well they have been trying. The thing is they can’t just unilaterally fix this for us. People have been saying that HMRC should allow a de minimis threshold on it, like the £81k threshold for UK VAT. The problem that many people don’t seem to grasp is that HMRC can’t give us a threshold or exemption on German or French or any other member state’s VAT. It isn’t for HMRC to do that. Like my other proposal, this one may come as a surprise.

I propose that HMRC go on an enforcement rampage. Go out, have fun, make sure everyone complies to the letter and send as many penalty notices as possible. Just not to UK companies . . . HMRC should make sure that anyone selling a knitting pattern or a recipe pdf or a wordpress extension module anywhere in Europe that might be purchased by someone in the UK is correctly registered with their local VATMOSS and is accounting for the VAT. All of the rest of the EU owes our exchequer VAT money for the digital services stuff we buy from them. This mess won’t get fixed if the rest of Europe ignores the problem and the law abiding UK businesses close.