Skip to content

Commit

Permalink
feat(netsuite): Add fees period dates to invoice payload (#2956)
Browse files Browse the repository at this point in the history
## Description

Add `custcol_service_period_date_from` and
`custcol_service_period_date_to` attributes to the invoice payload for
fee lines items.

Coupons, credits and credit notes will not contain these fields.
  • Loading branch information
ivannovosad authored Dec 13, 2024
1 parent bdb7668 commit af7fbd0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,18 @@ def item(fee)
raise Integrations::Aggregator::BasePayload::Failure.new(nil, code: 'invalid_mapping')
end

from_property = fee.charge? ? 'charges_from_datetime' : 'from_datetime'
to_property = fee.charge? ? 'charges_to_datetime' : 'to_datetime'

{
'item' => mapped_item.external_id,
'account' => mapped_item.external_account_code,
'quantity' => limited_rate(fee.units),
'rate' => limited_rate(fee.precise_unit_amount),
'amount' => limited_rate(amount(fee.amount_cents, resource: invoice)),
'taxdetailsreference' => fee.id
'taxdetailsreference' => fee.id,
'custcol_service_period_date_from' => fee.properties[from_property]&.to_date&.strftime("%-m/%-d/%Y"),
'custcol_service_period_date_to' => fee.properties[to_property]&.to_date&.strftime("%-m/%-d/%Y")
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,29 @@
'quantity' => 0.0,
'rate' => 0.0,
'amount' => 2.0,
'taxdetailsreference' => anything
'taxdetailsreference' => anything,
'custcol_service_period_date_from' => anything,
'custcol_service_period_date_to' => anything
},
{
'item' => '4',
'account' => '44',
'quantity' => 0.0,
'rate' => 0.0,
'amount' => 2.0,
'taxdetailsreference' => anything
'taxdetailsreference' => anything,
'custcol_service_period_date_from' => anything,
'custcol_service_period_date_to' => anything
},
{
'item' => 'm2',
'account' => 'm22',
'quantity' => 2,
'rate' => 4.1212121212334,
'amount' => 2.0,
'taxdetailsreference' => anything
'taxdetailsreference' => anything,
'custcol_service_period_date_from' => anything,
'custcol_service_period_date_to' => anything
},
{
'item' => '2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,34 @@
'quantity' => 0.0,
'rate' => 0.0,
'amount' => 100.0,
'taxdetailsreference' => fee_sub.id
'taxdetailsreference' => fee_sub.id,
'custcol_service_period_date_from' =>
fee_sub.properties['from_datetime']&.to_date&.strftime("%-m/%-d/%Y"),
'custcol_service_period_date_to' => fee_sub.properties['to_datetime']&.to_date&.strftime("%-m/%-d/%Y")
},
{
'item' => '4',
'account' => '44',
'quantity' => 0.0,
'rate' => 0.0,
'amount' => 2.0,
'taxdetailsreference' => minimum_commitment_fee.id
'taxdetailsreference' => minimum_commitment_fee.id,
'custcol_service_period_date_from' =>
minimum_commitment_fee.properties['from_datetime']&.to_date&.strftime("%-m/%-d/%Y"),
'custcol_service_period_date_to' =>
minimum_commitment_fee.properties['to_datetime']&.to_date&.strftime("%-m/%-d/%Y")
},
{
'item' => 'm2',
'account' => 'm22',
'quantity' => 2,
'rate' => 4.1212121212334,
'amount' => 2.0,
'taxdetailsreference' => charge_fee.id
'taxdetailsreference' => charge_fee.id,
'custcol_service_period_date_from' =>
charge_fee.properties['charges_from_datetime']&.to_date&.strftime("%-m/%-d/%Y"),
'custcol_service_period_date_to' =>
charge_fee.properties['charges_to_datetime']&.to_date&.strftime("%-m/%-d/%Y")
},
{
'item' => '2',
Expand Down

0 comments on commit af7fbd0

Please sign in to comment.