Skip to content
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

Truncate itemCode #151

Merged
merged 1 commit into from
Nov 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions app/models/solidus_avatax_certified/line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def item_line(line_item)
number: "#{line_item.id}-LI",
description: line_item.name[0..255],
taxCode: line_item.tax_category.try(:tax_code) || '',
itemCode: line_item.variant.sku,
itemCode: truncateLine(line_item.variant.sku),
quantity: line_item.quantity,
amount: line_item.amount.to_f,
discounted: discounted?(line_item),
Expand Down Expand Up @@ -59,7 +59,7 @@ def shipment_lines_array
def shipment_line(shipment)
{
number: "#{shipment.id}-FR",
itemCode: shipment.shipping_method.name,
itemCode: truncateLine(shipment.shipping_method.name),
quantity: 1,
amount: shipment.total_before_tax.to_f,
description: 'Shipping Charge',
Expand Down Expand Up @@ -97,7 +97,7 @@ def refund_lines
def refund_line
{
number: "#{@refund.id}-RA",
itemCode: @refund.transaction_id || 'Refund',
itemCode: truncateLine(@refund.transaction_id) || 'Refund',
quantity: 1,
amount: [email protected]_f,
description: 'Refund',
Expand All @@ -114,7 +114,7 @@ def return_item_line(line_item, quantity, amount)
number: "#{line_item.id}-LI",
description: line_item.name[0..255],
taxCode: line_item.tax_category.try(:tax_code) || '',
itemCode: line_item.variant.sku,
itemCode: truncateLine(line_item.variant.sku),
quantity: quantity,
amount: -amount.to_f,
addresses: {
Expand Down Expand Up @@ -142,6 +142,12 @@ def default_ship_from
::Spree::StockLocation.order_default.first.to_avatax_hash
end

def truncateLine(line)
return if line.nil?

line.truncate(50)
end

private

def base_line_hash
Expand Down