Skip to content

Commit

Permalink
Update VAT return to format numbers with 2 or 0 decimal places
Browse files Browse the repository at this point in the history
  • Loading branch information
craigfrancis committed Dec 5, 2018
1 parent 8f20d33 commit 3f01d4f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions hmrc-vat.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,26 @@ public function request_body_get_xml() {
$xml = '
<IRenvelope xmlns="' . xml($namespace) . '">' . $this->request_header_get_xml() . '
<VATDeclarationRequest>
<VATDueOnOutputs>' . xml($this->details['vat_due_output']) . '</VATDueOnOutputs>
<VATDueOnECAcquisitions>' . xml($this->details['vat_due_acquisitions']) . '</VATDueOnECAcquisitions>
<TotalVAT>' . xml($this->details['vat_total']) . '</TotalVAT>
<VATReclaimedOnInputs>' . xml($this->details['vat_reclaimed']) . '</VATReclaimedOnInputs>
<NetVAT>' . xml($this->details['vat_net']) . '</NetVAT>
<NetSalesAndOutputs>' . xml($this->details['total_sales']) . '</NetSalesAndOutputs>
<NetPurchasesAndInputs>' . xml($this->details['total_purchases']) . '</NetPurchasesAndInputs>
<NetECSupplies>' . xml($this->details['total_supplies']) . '</NetECSupplies>
<NetECAcquisitions>' . xml($this->details['total_acquisitions']) . '</NetECAcquisitions>
<VATDueOnOutputs>' . xml($this->format_amount(2, $this->details['vat_due_output'])) . '</VATDueOnOutputs>
<VATDueOnECAcquisitions>' . xml($this->format_amount(2, $this->details['vat_due_acquisitions'])) . '</VATDueOnECAcquisitions>
<TotalVAT>' . xml($this->format_amount(2, $this->details['vat_total'])) . '</TotalVAT>
<VATReclaimedOnInputs>' . xml($this->format_amount(2, $this->details['vat_reclaimed'])) . '</VATReclaimedOnInputs>
<NetVAT>' . xml($this->format_amount(2, $this->details['vat_net'])) . '</NetVAT>
<NetSalesAndOutputs>' . xml($this->format_amount(0, $this->details['total_sales'])) . '</NetSalesAndOutputs>
<NetPurchasesAndInputs>' . xml($this->format_amount(0, $this->details['total_purchases'])) . '</NetPurchasesAndInputs>
<NetECSupplies>' . xml($this->format_amount(0, $this->details['total_supplies'])) . '</NetECSupplies>
<NetECAcquisitions>' . xml($this->format_amount(0, $this->details['total_acquisitions'])) . '</NetECAcquisitions>
</VATDeclarationRequest>
</IRenvelope>';

return $xml;

}

public function format_amount($decimals, $amount) {
return number_format($amount, $decimals, '.', '');
}

}

?>

0 comments on commit 3f01d4f

Please sign in to comment.