Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
12
Erster Beitrag:
vor 4 Jahren, 7 Monaten
Letzter Beitrag:
vor 4 Jahren, 7 Monaten
Beteiligte Autoren:
Allard, artbonds, GuenterP, Marijan Tomasic, Erik Schwarz, Arie, Markus K., Noel Tanti, Paulo Oliveira

Windev 18

Startbeitrag von Allard am 02.12.2013 14:28

Hi I have a coding issue

My app calculates VAT ( btw). In Holland the tax percentages tend to change so I made a table for tax and a table with dates and percentages. So based on the date a certain percentage has to be taken into account. In the general leger I add a function VAT. Based on this number a VAT type has to be taken into account.

Nice If a percentage changes one has to add the percentage and the date when it applies. Nice but now comes my problem How do I code this

when entering a new record I add a date. So I need to look into the VAT date-table and use the date that needs to be used:

EXAMPLE DATA
1 01-01-2012 19%
2 05-02-2013 21%

If my entry has a date between 1 and 2 then the value of date 1 has to be used. If my entry is after date 2 then the value of second date has to be used.
Does anyone have an Idea how to tackle this?

Thanks

Allard

Antworten:

Hi,
compare the entered date (entered_Date) with the dates in your example data to get the relevant vat.

for each example_data
if datedifference(example_data.date, entered_Date) > 0 then
vat = example_data.vat
break
next

if you enter 01.05.2012, then datedifference for 01.01.2012 returns 121 (days), so this value could be valid. The second comparision returns -245, so the first one is the valid vat. If the second comparison would returns a value >0 then this would be "more" valid.

I hope it helps.

von Markus K. - am 02.12.2013 14:46
Hi allard

I would add another date 31/12/2999. This will always contain the current vat rate and then add a query where the date in question is >= the date in file, order by date asc limit 1.

this way you should always get one date with the applicble rate

HTH
Noel

von Noel Tanti - am 02.12.2013 14:55
To get the vat percent for today:
select vat.vat_date,vat.vat_perc from vat_file vat
where vat.vat_data=(select max(vat1.vat_date) from vat_file vat1
where vat1.vat_date

von Paulo Oliveira - am 02.12.2013 15:00
Allard,

I'm using a second date- and and a second percentage-field on the SAME record.
Assuming taxes don;t change very often this solution will do most of the time.

von Arie - am 02.12.2013 15:54
Hi I guess I have to do somthing with the date difference: I donnet get it exactly but you pointed me in the right direction

Screen shot VAT (btw)


Arie. I know what you mean but I think the vat Will indeed change in a view years ( when there is no more crisis )and my Method needs to enable the automatic calculation of VAT.
In the booking screen only the VAt type is automatic selected. Calculation the VAT is done after that using the right percentage

Booking screen



Thanks for your help

von Allard - am 02.12.2013 16:32
Hi Allard,

I'm doing it this way.
You want to know value, which is current on date x

I have a query which gives all Dates ordered by date desc, so the newest entry is at start.
then Loop that query until date is lower than x. This is the one you Need.

Erik

von Erik Schwarz - am 03.12.2013 12:11
Hi Erick,

But what if indeed the percentage changes and you need to enter somting with the old percentage
I guess you would need a datediffirece > 0 before you do the loop for that?
Interesting

Ok I get It thanks

THanks

von Allard - am 03.12.2013 12:27
Other things to worry about...

Do you have different rates for different types of item? For example is food taxed differently than childrens clothing vs an automobile?

Do you have tax holidays? For example when the tax is not collected on certain items (like back to school supplies in Conneticutt just before school opens or things like generators in Louisana just before hurricane season).

Do you have breakpoint taxes? For example 0% on select items up to 100 Euro, then 2% from 100 to 500 Euro, then 5% from 500 to 1000, then back to zero (upper limit).

Does one jurisdiction charge differently than another?

Taxes are enough to drive you crazy.

von artbonds - am 03.12.2013 23:52
Hi Art,

thanks for your input! Yes, VAT within Europe has its funnies too. In Austria, there are three rates of VAT: 20% and 10% and 0%. The reduced one is for food and beverages, all other are 20%, 0% is reserved for goods and services provided / sold by the government. The European VAT-system differs from the US-sales-tax-system. In Europe, only the end user of goods / services pays VAT, all others in the chain charge VAT but can deduct the VAT they paid to others. Even for all goods they themselves are using. Each pencil bought for a business is in fact implicitely free of VAT. In the U.K. they even have VAT-free items. These are for the coverage of basic needs of the poor. This goes from food to clothes. Afaik, there are no VAT-free days in Europe anywhere.

In our software, we are using 20 different VAT-rates and of course a datafile reflecting them. Usage is easy. rate #1 = 10%, #2 = 20%, #3 = 0%. If any changes come along then, for example, #4 = 11%, #5 = 25% or whatever. Of course, on day X of a VAT-increase the rate-numbers in the item files will have to be changed appropriately. Anyway, this saves us from useless date-calculations. Statistics on sales / VAT will be correct until the end of time. Or so. While VAT-rate changes in Europe are not unknown but a rather rare occurrence, our customers have to live with such a (light) burden.

von GuenterP - am 04.12.2013 06:14
Hello Allard,

I'm not shure if I understand you, but if yes:

Make descending key on date field in your VAT table,
Use Hreadseak(vat_table, desc_date_field_key, search_date_value)

Hreadseak should return first equal OR older VAT-date record.


Quote
Allard
Hi I have a coding issue

My app calculates VAT ( btw). In Holland the tax percentages tend to change so I made a table for tax and a table with dates and percentages. So based on the date a certain percentage has to be taken into account. In the general leger I add a function VAT. Based on this number a VAT type has to be taken into account.

Nice If a percentage changes one has to add the percentage and the date when it applies. Nice but now comes my problem How do I code this

when entering a new record I add a date. So I need to look into the VAT date-table and use the date that needs to be used:

EXAMPLE DATA
1 01-01-2012 19%
2 05-02-2013 21%

If my entry has a date between 1 and 2 then the value of date 1 has to be used. If my entry is after date 2 then the value of second date has to be used.
Does anyone have an Idea how to tackle this?

Thanks

Allard


von Marijan Tomasic - am 04.12.2013 07:20
I did it like Erick said, Works like a charm.

Thanks for your help.

Indeed using the VAT is quite a task since there are indeed three typs of VAT but they have to be defined on the Ledger accounts for buying and selling like Gunter states. Then there are differences if an Item is sold withing Holland or To an other country in EU or Outside EU.

To get this all going fine I defined 27 different ledger.functiontypes. But now it works like a charm. I can fillout the VAT form the government supplies HU Yeh Windev rocks.

Regards

Allard

von Allard - am 04.12.2013 19:06
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.