Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com > PHP VAT rounded?

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 09-13-2013, 01:14 PM PM User | #1 timgolding Senior Coder     Join Date: Aug 2006 Location: Southampton Posts: 1,497 Thanks: 107 Thanked 110 Times in 109 Posts VAT rounded? I'm not sure how to do something correctley on our ecommerce system. Its rounding issues im having and I cant quite figure out the best way to store the VAT and weather this should be rounded. At present everything is stored rounded apart from the VAT. Let me explain a little bit about how the storing a transaction works The ex vat selling price for each item is added up. This is done with the calculation on the cost price and a margin. Once i get to the EX VAT total for each item I round this value to the nearest penny. This is so if a user adds 3 items to the basket - Three times the ex total of the item does actually add up. Each item is stored in a table against the order id. For each item we store - The cost rate (how much we pay the supplier for a single item) - The cost total (quantity of that item ordered multiply by the cost rate) - The Ex vat rate (The ex VAT selling price of a single item rounded) - The Ex Total (quantity of that item ordered multiply by the ex vat rate rounded) - The Quantity We then calculate the ex VAT total for the order. Sum of the EX totals. This result will already be rounded. We then add the carriage which is EX VAT. Then we times by 1.2 to get to the grand total. However for each transaction we store the - Cost Total ( Sum of cost totals) - EX Total. ( Sum of the totals) - Carriage ( The amount the user will pay carriage for the order EX VAT) - VAT ( The amount of VAT payed for the that entire order) - The VAT RATE. e.g 1.2 - The Grand Total (EX Total + Carriage + VAT) The problem is on the screen everything is displayed rounded and Everything is stored rounded except the VAT. The grand total is stored to pennies. should i be storing the VAT rate rounded or full float. Should the grand total be stored full float. What happens when we try to calculate the VAT total at year end. Will what we should be paying VAT equal the sum of the rounded VAT values. Thats really what i am trying to figure out __________________ You can not say you know how to do something, until you can teach it to someone else.
 09-13-2013, 04:36 PM PM User | #2 firepages Super Moderator   Join Date: May 2002 Location: Perth Australia Posts: 4,035 Thanks: 10 Thanked 92 Times in 90 Posts The total VAT you report at the end of the year needs to match the actual amount of VAT that you collect, so IMO you should store the VAT rounded (since everything else is rounded), same for purchases, you can only claim what you shell out and the Inland revenue I assume does not do halfpennies any more ( I remember them ) The only time you should worry (IMO) about amounts less than 1p would be in your cost pricing, and even then only for internal purposes, when you pay or sell you are doing so to the nearest penny. __________________ resistance is... MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
 Users who have thanked firepages for this post: timgolding (09-13-2013)
 09-13-2013, 04:45 PM PM User | #3 timgolding Senior Coder     Join Date: Aug 2006 Location: Southampton Posts: 1,497 Thanks: 107 Thanked 110 Times in 109 Posts OK I will round the VAt amounts and make sure the figures add up thanks for your help. __________________ You can not say you know how to do something, until you can teach it to someone else.

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 11:02 PM.