Where does the PK table of the taxes is located in de DB?


#1


hellow sambapos i will like to know where is the the primery key or in wich table does the samba saves the taxes


#2

Are you looking for the tax template?


#3

no, im looking for the value that the samba calculates for each ticket.


#4

That would be in tickets and it would be a transaction

Explain what you want to do and we can help better


#5

but…the tax value…not the ticket total value.


#6

Yes I am aware of what your wanting and there is no tax table. It’s handled with transactions and transaction types


#7


in this case it will be the table where the samba stores de 1.600


#8

If you explain what your trying to do we can offer more accurate help.


#9

im trying to rebuilt some taxes that where wrong calculated in cartain dates, i have come to this
sql query
BEGIN TRANSACTION;
UPDATE t
SET t.TotalAmount = f.TotalACorregir
FROM dbo.Tickets AS t
INNER JOIN (
SELECT q.TicketId,
q.Subtotal,
q.IPOConsumo,
q.ServicioFijo,
q.ServicioPersonalizado,
q.DescuentoFijo,
q.DescuentoValor,
(q.Subtotal + q.IPOConsumo + q.ServicioFijo + q.ServicioPersonalizado + q.DescuentoFijo + q.DescuentoValor) AS TotalACorregir
FROM
(SELECT o.TicketId,
SUM(o.Price * o.CalculatePrice * o.Quantity) AS Subtotal,
(SUM(o.Price * o.CalculatePrice * o.Quantity) * 0.08) AS IPOConsumo,
COALESCE(c1.CalculationAmount, 0) AS ServicioFijo,
COALESCE(c2.CalculationAmount, 0) AS DescuentoFijo,
COALESCE(c3.CalculationAmount, 0) AS DescuentoValor,
COALESCE(c4.CalculationAmount, 0) AS ServicioPersonalizado
FROM dbo.Orders AS o
LEFT JOIN dbo.Calculations AS c1 ON c1.TicketId = o.TicketId AND c1.CalculationTypeId = 3
LEFT JOIN dbo.Calculations AS c2 ON c2.TicketId = o.TicketId AND c2.CalculationTypeId = 5
LEFT JOIN dbo.Calculations AS c3 ON c3.TicketId = o.TicketId AND c1.CalculationTypeId = 2
LEFT JOIN dbo.Calculations AS c4 ON c4.TicketId = o.TicketId AND c2.CalculationTypeId = 4
WHERE
–o.TicketId = 334
o.LastUpdateDateTime >= '12-01-2017’
GROUP BY o.TIcketId,
c1.TicketId,
c2.TicketId,
c3.TicketId,
c4.TicketId,
c1.CalculationAmount,
c2.CalculationAmount,
c3.CalculationAmount,
c4.CalculationAmount) AS q
GROUP BY
q.TicketId,
q.Subtotal,
q.IPOConsumo,
q.ServicioFijo,
q.ServicioPersonalizado,
q.DescuentoFijo,
q.DescuentoValor
) AS f ON f.TicketId = t.Id

but in order to accomplish the update i must find the taxes associetd with each ticket


#10

Taxes are transactions and handled by transaction type


#11


but in wich table are that values stored? im going crazy with that lol…


#12

What values? The transaction values are in the AccountTransactions table… Next one up from transaction types.
You know there is a maintinance task to rebuild tax - im sure there is…
Make sure you backup before that script goes near your DB, your making changes to allot of stuff there, I would be very cautious… :-/


#13

Im trying to find those 1,600, the table in wich they are stored.


#14

Yes, tax, tax is handled by transactions… you have been told this?
If your struggling to find it then personally Id be worried about messing with the sql in the first place… Where did that query you posted earlier come from, Im guessing you didnt write it?


#15

Don’t be worry, I’m doing it in a backup db in other computer, the query was written by a friend.


#16

There is no tax table. Taxes are stored as transactions. I feel like I’m repeating myself.


#17

actually you are repeating yourself brother…you should be more i dont know…polite or patient. it is not a sin to ask twice.


#18

He told you, and I did, and you keep asking same question, hes not being rude, you are because your not listening LOL


#19

ok…sorry im the one being rude…sorry for not “listening”.