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.

  • I may not be able to help because I don't use the  SDK and I don't read C# very well.

    However, if you are getting the Total Tax Amount, is this the total tax for an invoice found in table titlutot?  Is this the amount you see in the Ctrl-Shift-Y dialog in Sage 50?

    If so, then this is not the same as the line item rows of each invoice.  It looks like SetTAxAmountByRow is attempting to set the tax you see on each record of an invoice that you see in the Ctrl-Y dialog in Sage 50. eg. 

    taxSummaryInfo.SetTaxAmountByRow(1, totalTax);

    is the first row of the invoice, not the total tax of the invoice.

    If so, is it possible the SDK allows for updating the rows and will calculate the Total Tax for the invoice for you?  In this case GetTotalTaxAmountInfo fields might be read-only or you need a SetTotalTaxAmount method?

    Just a guess!

  • 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.

  • Hi Richard,

    Yes, you understood my situation why I need to update tax total.

    For each line tax calculation based on total tax then it may lead wrong total and it won't match total with my application's modified total.

    After checking into details, It's seem hard to do with SDK directly.

    Yes, I was thinking to do directly in SQL but need to update couple of tables and identify columns and it's calculation to be accurate.

    Yes, print showing "'Tax code name' not included " and looking into tables they are modifying I can see they are inserting new records for into SQL table " ttaxdtl ".

    Let me try to modify using SQL commands and update required fields and calculation.

    Thanks a lot for your help and guidelines.

  • For each line tax calculation based on total tax then it may lead wrong total and it won't match total with my application's modified total.

    I'm not sure I fully understand this line but I assume it is more related to your application than Sage 50 so it makes sense I don't know what you are doing.

    ttaxdtl is only required to be updated when Report on Taxes is turned on for the tax (ttaxauth.wTaxRpt I believe).

    The main table that tracks total tax on purchase and sales invoices is titlulit.  This is the total I was referring to above.

    If your app is changing the amounts on invoice already posted, and the changes would affect journal entries then yes, there are a lot of table to update (Accounts, Journal Entries, Invoice lookup, currency info if applicable, etc.).  Please do not invalidate the audit trail of the program.  Also make sure the fiscal year(s) you are posting to are allowed by the system.  I would think the SDK tracks that when you use it but I would test the RunNonQuery method carefully.

    I would still try to adjust the line item tax amounts and see if that flows through properly.