hellow sambapos i will like to know where is the the primery key or in wich table does the samba saves the taxes
Are you looking for the tax template?
no, im looking for the value that the samba calculates for each ticket.
That would be in tickets and it would be a transaction
Explain what you want to do and we can help better
butā¦the tax valueā¦not the ticket total value.
Yes I am aware of what your wanting and there is no tax table. Itās handled with transactions and transaction types
If you explain what your trying to do we can offer more accurate help.
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
Taxes are transactions and handled by transaction type
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ā¦ :-/
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?
Donāt be worry, Iām doing it in a backup db in other computer, the query was written by a friend.
There is no tax table. Taxes are stored as transactions. I feel like Iām repeating myself.
actually you are repeating yourself brotherā¦you should be more i dont knowā¦polite or patient. it is not a sin to ask twice.
He told you, and I did, and you keep asking same question, hes not being rude, you are because your not listening LOL
okā¦sorry im the one being rudeā¦sorry for not ālisteningā.