-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avalara Tax Compliance #1870
Avalara Tax Compliance #1870
Changes from 107 commits
9f76387
c354446
e5c16fa
c9e7e84
6638741
91af920
67e2fd8
0533278
4b11f1c
10ad786
4a3dfe1
f59a3d9
74fa576
6c4ed39
1ee2c86
eeb68b8
0203559
10b402e
71fe8c6
66120a6
9f0753e
10f0a7d
2fdb4cb
99b1d97
73908fc
19bcfd5
20019eb
b035266
e859297
48a562b
f5cd7a4
f953893
45a7bc5
b0269ca
b866095
ce2f853
60c8400
071edbc
df23bb7
cd55f91
64366fd
1c8aeaf
c098fce
6c23f51
3a16c98
9d5b21b
26ba803
b87a412
b9be7b0
8e974c6
855c880
d48a62e
27f825d
0ef2817
f130c12
f9cabb3
4567608
d7e458a
646f3e2
cae3d1e
b7f9c7d
b68265d
5d3fded
3905c45
8278baf
9b14db9
d8b0527
dfec5ba
b809085
064aa3a
1663ccc
114f913
bd8e03c
c97de61
6c389a5
92ce4e5
9b407ee
54defcf
b5ff3ca
6a4f25f
970d82b
fdb9a31
dca26d7
d420e1c
eea4cb9
764ef90
26dc92a
3ff33c9
9bda0d2
e3ebcc8
fe64d50
b949d4a
376d26d
e75a813
562d8ad
10d53fb
7cfb019
2f084d1
97a26a1
1374710
29f472f
5e0569b
1c25409
28f6b29
de9caa8
eca3f7f
c7397cb
6e234e0
1cac94a
2450b12
116656b
4d94de1
66f0f78
3b238a8
505a0de
9336e00
e4173c9
a32b2a7
38d1f31
4804e82
b2b1fa3
f96aeba
632b9d5
7c01c46
2629c6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,7 @@ [email protected] | |
[email protected] | ||
[email protected] | ||
mrt:[email protected] | ||
natestrauser:[email protected] | ||
[email protected] | ||
[email protected]_1 | ||
[email protected] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./countries"; | ||
export * from "./taxEntitycodes"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Mongo } from "meteor/mongo"; | ||
|
||
/** | ||
* Client side collections | ||
*/ | ||
export const TaxEntityCodes = new Mongo.Collection(null); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,6 @@ <h3 class="panel-title"> | |
{{/each}} | ||
</ul> | ||
</div> | ||
|
||
</div> | ||
{{/if}} | ||
</template> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<template name="taxSettingsPanel"> | ||
<div class="row"> | ||
<div class="col-md-10 col-md-offset-1 panel panel-default panel-tax-settings"> | ||
<h4 data-i18n="accounts.taxSettings">Tax Exempt Settings</h4> | ||
<div> | ||
{{#autoForm collection=Collections.Accounts schema=accountsSchema doc=account id=makeUniqueId type="update" }} | ||
{{>afQuickField name='taxSettings.exemptionNo' class='form-control'}} | ||
{{> afQuickField data-event-action="customType" name="taxSettings.customerUsageType" type="select" options=entityCodes }} | ||
<p>Current Saved Entity Code: {{ account.taxSettings.customerUsageType }}</p> | ||
<div class="panel-body customerUsageType hide"> | ||
<label for="customerUsageType">Custom value</label> | ||
<input id="customerUsageType" type="text" name="custom-customerUsageType" class="form-control"> | ||
</div> | ||
<div class="form-group"> | ||
<button type="submit" class="btn btn-primary">Submit</button> | ||
</div> | ||
{{/autoForm}} | ||
</div> | ||
</div> | ||
</div> | ||
</template> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import _ from "lodash"; | ||
import { Meteor } from "meteor/meteor"; | ||
import { Template } from "meteor/templating"; | ||
import { Reaction } from "/client/api"; | ||
import { Packages, Accounts } from "/lib/collections"; | ||
import { Accounts as AccountsSchema } from "/lib/collections/schemas/accounts"; | ||
import { TaxEntityCodes } from "/client/collections"; | ||
|
||
Template.taxSettingsPanel.helpers({ | ||
account() { | ||
const sub = Meteor.subscribe("Accounts.single", this.member.userId); | ||
if (sub.ready()) { | ||
return Accounts.findOne({ _id: this.member.userId }); | ||
} | ||
return null; | ||
}, | ||
makeUniqueId() { | ||
return `tax-settings-form-${this.member.userId}`; | ||
}, | ||
accountsSchema() { | ||
return AccountsSchema; | ||
}, | ||
entityCodes() { | ||
const customOption = [{ | ||
label: "SET CUSTOM VALUE", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is i81n implemented for "SET CUSTOM VALUE"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Fixed now. |
||
value: "CUSTOM USER INPUT" | ||
}]; | ||
|
||
const entityCodes = TaxEntityCodes.find().map((entityCode) => { | ||
return Object.assign({}, entityCode, { | ||
label: entityCode.name, | ||
value: entityCode.code | ||
}); | ||
}); | ||
|
||
return (entityCodes || []).concat(customOption); | ||
} | ||
}); | ||
|
||
Template.taxSettingsPanel.events({ | ||
"change [data-event-action=customType]": function (event) { | ||
event.stopPropagation(); | ||
|
||
if (isCustomValue()) { | ||
return $(".customerUsageType").toggleClass("hide"); | ||
} | ||
$(".customerUsageType").addClass("hide"); | ||
} | ||
}); | ||
|
||
Template.taxSettingsPanel.onCreated(function () { | ||
const avalaraPackage = Packages.findOne({ | ||
name: "taxes-avalara", | ||
shopId: Reaction.getShopId() | ||
}); | ||
const isAvalaraEnabled = _.get(avalaraPackage, "settings.avalara.enabled", false); | ||
const currentCodes = TaxEntityCodes.find().fetch(); | ||
|
||
if (isAvalaraEnabled && !currentCodes.length) { | ||
Meteor.call("avalara/getEntityCodes", (error, entityCodes) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @impactmass We are neither checking for an error nor checking the entityCodes is a valid value before trying to insert them info the db. |
||
if (error) { | ||
return Alerts.toast( | ||
`${i18next.t("settings.apiError")} ${error.message}`, "error" | ||
); | ||
} | ||
(entityCodes || []).forEach((entityCode) => TaxEntityCodes.insert(entityCode)); | ||
}); | ||
} | ||
}); | ||
|
||
AutoForm.hooks({ | ||
"tax-settings-form": { | ||
before: { | ||
update: function (doc) { | ||
if (isCustomValue()) { | ||
const value = $(".customerUsageType input").val(); | ||
doc.$set["taxSettings.customerUsageType"] = value; | ||
} | ||
return doc; | ||
} | ||
} | ||
} | ||
}); | ||
|
||
function isCustomValue() { | ||
const formData = AutoForm.getFormValues("tax-settings-form"); | ||
const value = _.get(formData, "insertDoc.taxSettings.customerUsageType"); | ||
return value === "CUSTOM USER INPUT"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Router, i18next } from "/client/api"; | ||
import { i18next } from "/client/api"; | ||
|
||
export default { | ||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Reaction } from "/server/api"; | ||
|
||
Reaction.registerPackage({ | ||
label: "Logging", | ||
name: "reaction-logging", | ||
autoEnable: true | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./publications"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Meteor } from "meteor/meteor"; | ||
import { check, Match } from "meteor/check"; | ||
import { Roles } from "meteor/alanning:roles"; | ||
import { Counts } from "meteor/tmeasday:publish-counts"; | ||
import { Logs } from "/lib/collections"; | ||
import { Reaction } from "/server/api"; | ||
|
||
|
||
/** | ||
* Publish logs | ||
* Poor admins get swamped with a ton of data so let's just only subscribe to one | ||
* logType at a time | ||
*/ | ||
Meteor.publish("Logs", function (query, options) { | ||
check(query, Match.OneOf(undefined, Object)); | ||
check(options, Match.OneOf(undefined, Object)); | ||
|
||
const shopId = Reaction.getShopId(); | ||
if (!query || !query.logType || !shopId) { | ||
return this.ready(); | ||
} | ||
|
||
const logType = query.logType; | ||
if (Roles.userIsInRole(this.userId, ["admin", "owner"])) { | ||
Counts.publish(this, "logs-count", Logs.find({ shopId, logType })); | ||
return Logs.find({ shopId, logType }, { sort: { date: 1 } }); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,21 @@ export const TaxCodes = new SimpleSchema({ | |
unique: true | ||
}, | ||
shopId: { | ||
type: String | ||
}, | ||
taxCode: { | ||
type: String, | ||
optional: true | ||
label: "Tax Code" | ||
}, | ||
taxCodeProvider: { | ||
type: String, | ||
label: "Tax Code Provider" | ||
}, | ||
ssuta: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming this is correct, but just want to make sure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't new code, is there a reason we think it's incorrect? |
||
type: Boolean, | ||
label: "Streamlined Sales Tax" | ||
label: "Streamlined Sales Tax", | ||
optional: true, | ||
defaultValue: false | ||
}, | ||
title: { | ||
type: String, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,9 @@ | |
margin-bottom: 0px; | ||
} | ||
.lowInventoryWarningThreshold { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary? Should we just delete this selector? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deleted |
||
} | ||
} | ||
.select2-container { | ||
width: 370px; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be avoiding introducing new atmosphere packages. Can't this be used as an npm import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaronjudd there's an NPM package for this (select2), but under its usage is a bunch of CDNs to source from, and alternative integrations, hence the use of the meteor package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've talked about this a couple of times and the feeling was that this package was coming out as soon as the variant stuff was converted to React anyway