TotalTaxAmount SetTaxAmountByRow not working

Hi,

I am trying to update invoice's total tax  using below code

TaxSummaryInfo taxSummaryInfo = journal.GetTotalTaxAmountInfo();
if (taxSummaryInfo.GetCount() > 0)
{
double totalTax = 10;
taxSummaryInfo.SetTaxAmountByRow(1, totalTax);
taxSummaryInfo.Save();
}

But it's throwing error, field you are trying to update is not accessible.

Is there anything wrong or any suggestion to make it working?

Thanks in advance.

Parents
  • Hi Richard,

    Thanks for your inputs.

    Yes its same as SAGE 50 CTRL + Shift + Y and I would like to update the same value using SDK.

    There is no direct method  for SetTotalTaxAmount in .NET SDK and I need to update only total tax not the individual Item's tax (CTRL + Y).

    Please let me know if there is any alternative in .NET SDK to update tax total.

    Thanks.

  • As i said, I don't use the SDK so I don't know all the methods.  I'd have to read the help files just like you do.

    So I am going back to the logic of why you need to update only the total of the invoice without updating the tax on the line items.

    eg. 

    Line 1 Amount $100 HST @ 13% = $13

    Line 2 Amount $150 HST @ 13% = $19.50

    Total tax should be $32.50

    But if for some reason, the original invoice has a total tax of $32.51, is this your situation?

    If so, then you may have a line item like the following

    Line 1 Amount $81.75 HST @ 13% = $10.63

    Line 2 Amount $149.66 HST @ 13% = $19.46

    Total tax should be $30.09

    But if you calculate the total tax on the total of each line items then

    $81.75 + $149.66 = $231.41 @ 13% = $30.08

    If this is your scenario, I think you should be updating the tax on the line and I would hope the total tax would be updated as well.  A couple of quick tests should be able to show you what happens.

    If not, then you will have to use SQL commands to do the update of the total tax once you validate the total tax based on each line.

    And yes I know the total tax in the program can be updated with Ctrl + Shift + Y but in sales invoices, this also results in a dumb line at the bottom of the customer invoice printout indicating the tax not included in the lines.  So why would there be tax not included in the lines when the tax is supposed to be calculated on the amounts on the lines?

    You don't see this on the purchase invoice side because you can't print a purchase invoice.

  • Using nice round numbers, you have an invoice with two rows.

    $100

    $200

    and for some reason, your program is calculating the total HST @ 13% to be $39.01.

    Sage 50 will calculate $39 in total HST using $13 on the first row and $26 on the second row.

    What are you posting on the original invoice before you attempt to update the amounts?

    Based on my recommendation above I would be posting $13.01 and $26.00 on each of the rows so the total tax is $39.01.

    However, based on this line

    Yes, I am posting invoice first and while posting entry, it's not allowing to set any parameter or field to set updated total tax as SAGE calculating auto.

    You are not completing the transaction before you start to edit the already posted transaction.  If the transaction is not posted, how do you update it?

    In your original transaction, I am assuming you have tried it without editing the total tax, do you see the exact invoice you posted in the Sales Invoice data entry screen and the tax you posted under Ctrl-Y and Ctrl-Shift-Y?

    I still think you should be updating the row tax amounts and see what happens to the total but you have been resistant to this option.  I don't know if I am correct because as I mentioned, I don't use the SDK but based on what I have read, this sounds like a suitable test.

    What happens to the total tax when you post the $13.01 and $26 in line item tax as I mention above?  Do you get $39.01 or does the Sage 50 program recalculate?  You should be able to set a break point in your code to allow you to stop and adjust the dollar amounts as you step through the code, before you do the final post without changing the code to pull the original invoice from your program.

    I am not sure I can help you much more but I would be interested in hearing what happens in this kind of test.  It will prove whether you only need to adjust the line item amounts instead of the total as I mentioned above and will prevent you from having to do at least 6 SQL RunNonQuery Update commands to update a penny in the two account totals (in the proper fiscal year), HST reports, invoice line items tax, customer, invoice total tax and bank rec tables if applicable.

  • Hi Richard,

    Finally I have achieved this.

    I have updated all required tables with right values using SQL and its working perfectly.

    Thanks for your help.

  • You are welcome.

    You never did mention if adding the difference to the tax in one of the rows worked or not?  And if not what kind of error message you received?

  • I have mentioned in my earlier reply but let me mention that again as below quote.

    Yes, its throwing error at SetTaxAmountByRow "The field you are trying to change or function you are calling is not accessible under current circumstance.".


    Now instead of SDK, I have done with SQL query as SDK is not allowing to update using row method as above.

    Please let me know if you want to know details about solution I have applied to override tax total.

    Thanks.

  • Sorry my confusion.  I thought that command was causing a problem because the it is normally used after the entry is posted and it appeared you were trying to issue it as you were posting the original invoice.

    Please let me know if you want to know details about solution I have applied to override tax total.

    Thank you but I don't think that is necessary.  I know the tests and tables that need to be updated or not.

Reply
  • Sorry my confusion.  I thought that command was causing a problem because the it is normally used after the entry is posted and it appeared you were trying to issue it as you were posting the original invoice.

    Please let me know if you want to know details about solution I have applied to override tax total.

    Thank you but I don't think that is necessary.  I know the tests and tables that need to be updated or not.

Children
No Data