<% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>

FS::Cron::tax_rate_update

NAME

FS::Cron::tax_rate_update

DESCRIPTION

Cron routine to update city/district sales tax rates in cust_main_county. Currently supports sales tax in the state of Washington.

wa_sales

Tax Rate Download

Once each month, update the tax tables from the WA DOR website.

Customer Address Rate Classification

Find cust_location rows in WA with no tax district. Try to determine a tax district. Otherwise, generate a log error that address needs to be correctd.

FUNCTIONS

tax_rate_update

Cron routine for freeside_daily.

Run one of the available cron functions based on conf value tax_district_method

wa_sales

Monthly: Update the complete WA state tax tables Every Run: Log errors for cust_location records without a district

wa_sales_log_customer_without_tax_district

For any cust_location records * In WA state * Attached to non cancelled packages * With no tax district

Classify the tax district for the record using the WA State Dept of Revenue API. If this fails, generate an error into system log so address can be corrected

wa_sales_update_tax_table \%args

Update city/district sales tax rates in FS::cust_main_county from the Washington State Department of Revenue published data files.

Creates, or updates, a FS::cust_main_county row for every tax district in Washington state. Some cities have different tax rates based on the address, within the city. Because of this, some cities have multiple districts.

If tax classes are enabled, a row is created in every tax class for every district.

Customer addresses aren't classified into districts here. Instead, when a Washington state address is inserted or changed in FS::cust_location, a job is queued for FS::geocode_Mixin::process_district_update, to ask the Washington state API which tax district to use for this address.

All arguments are optional:

  filename: Skip file download, and process the specified filename instead

  taxname:  Updated or created records will be set to the given tax name.
            If not specified, conf value 'tax_district_taxname' is used

  year:     Specify year for tax table download.  Defaults to current year

  quarter:  Specify quarter for tax table download.  Defaults to current quarter

Washington State Department of Revenue Resources

The state of Washington makes data files available via their public website. It's possible the availability or format of these files may change. As of now, the only data file that contains both city and county names is published in XLSX format.

WA Dept of Revenue

https://dor.wa.gov

Data file downloads

https://dor.wa.gov/find-taxes-rates/sales-and-use-tax-rates/downloadable-database

XLSX file example

https://dor.wa.gov/sites/default/files/legacy/Docs/forms/ExcsTx/LocSalUseTx/ExcelLocalSlsUserates_19_Q1.xlsx

CSV file example

https://dor.wa.gov/sites/default/files/legacy/downloads/Add_DataRates2018Q4.zip

Address lookup API tool

http://webgis.dor.wa.gov/webapi/AddressRates.aspx?output=xml&addr=410 Terry Ave. North&city=&zip=98100

wa_sales_update_cust_main_county \%args

Create or update the FS::cust_main_county records with new data

update_non_sales_tax_rows tax_class, $district_href

The customer may have created additional taxes, such as Universal Service Fund.

Ensure the columns for city and county are consistant between the user-created tax rows and the wa-sales-managed tax rows.

wa_sales_parse_xlsx_file \%args

Parse given XLSX file for tax district information Return an arrayref of district information hashrefs

wa_sales_fetch_xlsx_file \%args

Download data file from WA state DOR to temporary storage, return filename

wa_sales_update_tax_table_sanity_check

There should be no duplicate tax table entries in the tax table, with the same district value, within a tax class, where source=wa_sales.

If there are, custome taxes may have been user-entered in the freeside UI, and incorrectly labelled as source=wa_sales. Or, the dupe record may have been created by issues with older wa_sales code.

If these dupes exist, the sysadmin must solve the problem by hand with the freeeside-wa-tax-table-resolve script

Returns 1 unless problem sales tax entries are detected

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 14:

'=item' outside of any '=over'

Around line 56:

You forgot a '=back' before '=head1'

<% include ('/elements/footer.html' ) %>