Schlo_50 Posted December 2, 2008 Share Posted December 2, 2008 Hi guys, I need to update a price list to comply with the VAT rate at 15%. Unfortunately for me the price list is stored in a flat file database so updating it isn't as easy as a MySQL one. Could someone point me in the right direction to updating the price using the code I have so far please? <?php $Lines = file("priceList.DAT"); foreach($Lines as $Key => $Val) { $Data[$Key] = explode("|", $Val); $one = $Data[$Key][0]; $two = $Data[$Key][1]; $three = $Data[$Key][2]; $four = $Data[$Key][3]; $five = $Data[$Key][4]; $six = $Data[$Key][5]; $newVAT = $five / 47 * 46; round($newVAT, 2); //Need to replace $five with $newVAT here.. } ?> Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/135154-solved-update-vat/ Share on other sites More sharing options...
johnsmith153 Posted December 2, 2008 Share Posted December 2, 2008 Don't reduce your VAT. You'll make more profit! Then when it goes back up in Jan 2010 (UK), complain to your customers how you have had to put prices up because the government have just put VAT back up. They'll never remember that you never dropped it in the first place. At least this is what a lot of companies are doing! Although if you deal B2B then this is irrelevant. Link to comment https://forums.phpfreaks.com/topic/135154-solved-update-vat/#findComment-703937 Share on other sites More sharing options...
Schlo_50 Posted December 2, 2008 Author Share Posted December 2, 2008 ..So yeah, can anybody help me with my PHP question please? Thanks Link to comment https://forums.phpfreaks.com/topic/135154-solved-update-vat/#findComment-704007 Share on other sites More sharing options...
JNorman Posted December 2, 2008 Share Posted December 2, 2008 What sort of flat file is it? You could just produce a discount at the checkout and work out what the difference in VAT change would be. Its going to go back up so it would be a much simpler method than changing the whole script. Link to comment https://forums.phpfreaks.com/topic/135154-solved-update-vat/#findComment-704015 Share on other sites More sharing options...
Schlo_50 Posted December 2, 2008 Author Share Posted December 2, 2008 $Lines = file("priceList.DAT"); Thanks for the input, that would be my way of doing this but my client would like for me to change the pricelist itself. Can anybody else help me please? Link to comment https://forums.phpfreaks.com/topic/135154-solved-update-vat/#findComment-704031 Share on other sites More sharing options...
unkwntech Posted December 2, 2008 Share Posted December 2, 2008 what is the format of the file, can you give an example with any private data *** out. Link to comment https://forums.phpfreaks.com/topic/135154-solved-update-vat/#findComment-704035 Share on other sites More sharing options...
Schlo_50 Posted December 2, 2008 Author Share Posted December 2, 2008 Heres an example of two lines within the file. one|two|three|four|five|six one2|two2|three2|four2|five2|six2 etc etc Link to comment https://forums.phpfreaks.com/topic/135154-solved-update-vat/#findComment-704207 Share on other sites More sharing options...
Mchl Posted December 2, 2008 Share Posted December 2, 2008 <?php $Lines = file("priceList.DAT"); foreach($Lines as $Key => $Val) { $Data[$Key] = explode("|", $Val); $newVAT = $Data[$Key][4] / 47 * 46; round($newVAT, 2); $Data[$Key][4] = $newVAT; //I forgot about this $newline = implode("|",$Data[$Key]); $newData[] = $newline; echo $newline; } // now you just need to save $newData to a file ?> [edit] Forgot one important line Link to comment https://forums.phpfreaks.com/topic/135154-solved-update-vat/#findComment-704213 Share on other sites More sharing options...
Schlo_50 Posted December 3, 2008 Author Share Posted December 3, 2008 Thanks Link to comment https://forums.phpfreaks.com/topic/135154-solved-update-vat/#findComment-704784 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.