Created
May 12, 2022 18:24
-
-
Save JeroenSteen/08a28a9f3a0bbaa37014d5aea5070fe4 to your computer and use it in GitHub Desktop.
Estimate.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//We're delivering it ourself, so.. | |
if($this->deliveryMethod == "hood") { | |
//Get VAT for delivery | |
$this->deliveryCostsVat = $this->getVat($this->deliveryCosts); | |
//Add delivery costs | |
$totalEditionCosts += $this->deliveryCosts; | |
//Bullshit variable, to fool the world | |
$this->deliveryCostsVatless = 0; | |
} else if (in_array($this->deliveryMethod, ["postnl", "dhl"])) { | |
//Not doing it ourselfs, VAT-less | |
$this->deliveryCostsVatless = $this->deliveryCosts; | |
//Bullshit variable, to fool the world | |
$this->deliveryCostsVat = 0; | |
} else { | |
//Just pickup, bullshit variables | |
$this->deliveryCostsVatless = 0; | |
$this->deliveryCostsVat = 0; | |
} | |
//Add transactioncosts over VAT, because someone wants to pay with Sumup | |
if($this->paymentMethod == "sumup") { | |
//Transactioncosts are VAT less, if it's Sumup for payment, so.. | |
$this->transactionCosts = $this->getBruto( | |
//Ask transaction costs "over" the VAT, and then pretend it didn't happen | |
$this->getSumupTransactionCosts( | |
//Always use the total costs of editions and delivery (sometimes with vat) | |
$this->includeVat($totalEditionCosts) + $this->deliveryCosts + $this->deliveryCostsVat | |
) | |
); | |
} else { | |
$this->transactionCosts = 0; | |
} | |
//We always want transaction costs, with Sumup just pretend adding VAT didn't happen (Actually VAT-less) | |
$totalEditionCosts += $this->transactionCosts; | |
//Include VAT less in exclusive VAT | |
$totalEditionCostsExclVatInclVatless = $totalEditionCosts + $this->deliveryCostsVatless; | |
$totalEditionCostsExclVatInclVatless = round($totalEditionCostsExclVatInclVatless, 2); | |
$perEditionCostsExclVatInclVatless = round($totalEditionCostsExclVatInclVatless / $edition, 2); | |
//VAT only | |
$totalEditionCostsVat = round($this->getVat($totalEditionCosts), 2); | |
$perEditionCostsVat = round($this->getVat($totalEditionCostsVat / $edition), 2); | |
//Including VAT | |
$totalEditionCostsInclVatInclVatless = $totalEditionCostsExclVatInclVatless + $totalEditionCostsVat; | |
$perEditionCostsInclVatInclVatless = $perEditionCostsExclVatInclVatless + $perEditionCostsVat; | |
//Set all the values, with Euro format | |
$this->estimates[$edition]["totalEditionCostsExclVatInclVatless"] = $this->formatEuro($totalEditionCostsExclVatInclVatless); | |
$this->estimates[$edition]["perEditionCostsExclVatInclVatless"] = $this->formatEuro($perEditionCostsExclVatInclVatless); | |
$this->estimates[$edition]["totalEditionCostsVat"] = $this->formatEuro($totalEditionCostsVat); | |
$this->estimates[$edition]["perEditionCostsVat"] = $this->formatEuro($perEditionCostsVat); | |
$this->estimates[$edition]["totalEditionCostsInclVatInclVatless"] = $this->formatEuro($totalEditionCostsInclVatInclVatless); | |
$this->estimates[$edition]["perEditionCostsInclVatInclVatless"] = $this->formatEuro($perEditionCostsInclVatInclVatless); | |
//Already including when setting the values, but we need the already included price for delivering | |
$this->estimates[$edition]["deliveryCostsVatless"] = $this->formatEuro($this->deliveryCostsVatless); | |
/* | |
Now depending on isInclusiveVat we give that value | |
*/ | |
if($this->isInclusiveVat) { | |
$this->estimates[$edition]["totalCosts"] = $this->estimates[$edition]["totalEditionCostsInclVatInclVatless"]; | |
$this->estimates[$edition]["perEditionCosts"] = $this->estimates[$edition]["perEditionCostsInclVatInclVatless"]; | |
} else { | |
$this->estimates[$edition]["totalCosts"] = $this->estimates[$edition]["totalEditionCostsExclVatInclVatless"]; | |
$this->estimates[$edition]["perEditionCosts"] = $this->estimates[$edition]["perEditionCostsExclVatInclVatless"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment