Skip to content

Commit 9c8e804

Browse files
committed
Merge branch 'main' into feat/purchase-order-number-graphql-mutations
2 parents e06b71f + 32efd35 commit 9c8e804

16 files changed

Lines changed: 162 additions & 21 deletions

File tree

app/jobs/payment_providers/stripe/customers/fetch_default_payment_method_job.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module Customers
66
class FetchDefaultPaymentMethodJob < ApplicationJob
77
queue_as :default
88

9+
retry_on ::Stripe::RateLimitError, wait: :polynomially_longer, attempts: 5
10+
911
def perform(provider_customer)
1012
PaymentProviders::Stripe::Customers::FetchDefaultPaymentMethodService.call!(provider_customer:)
1113
end

app/models/event.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def subscription
9191
# index_events_on_organization_id (organization_id)
9292
# index_events_on_organization_id_and_code (organization_id,code)
9393
# index_events_on_organization_id_and_created_at (organization_id,created_at DESC) WHERE (deleted_at IS NULL)
94+
# index_events_on_organization_id_and_timestamp (organization_id,timestamp DESC) WHERE (deleted_at IS NULL)
9495
# index_events_on_organization_id_and_transaction_id (organization_id,transaction_id) WHERE (deleted_at IS NULL)
9596
# index_unique_transaction_id (organization_id,external_subscription_id,transaction_id) UNIQUE
9697
#

app/models/invoice.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ def document_invoice_name
499499
return I18n.t("invoice.self_billed.document_name") if self_billed?
500500
return I18n.t("invoice.prepaid_credit_invoice") if credit?
501501

502-
if TAX_INVOICE_LABEL_COUNTRIES.include?(organization.country)
502+
if TAX_INVOICE_LABEL_COUNTRIES.include?(billing_entity.country)
503503
return I18n.t("invoice.paid_tax_invoice") if advance_charges?
504504
return I18n.t("invoice.document_tax_name")
505505
end

app/services/integrations/aggregator/invoices/payloads/base_payload.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ def discounts
149149

150150
output
151151
end
152+
153+
def invoice_url
154+
url = ENV["LAGO_FRONT_URL"].presence || "https://app.getlago.com"
155+
156+
URI.join(url, "/#{invoice.customer.organization.slug}/customer/#{invoice.customer.id}/", "invoice/#{invoice.id}/overview").to_s
157+
end
152158
end
153159
end
154160
end

app/services/integrations/aggregator/invoices/payloads/hubspot.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def create_body
1717
"properties" => {
1818
"lago_invoice_id" => invoice.id,
1919
"lago_invoice_number" => invoice.number,
20+
"lago_invoice_purchase_order_number" => invoice.purchase_order_number,
2021
"lago_invoice_issuing_date" => formatted_date(invoice.issuing_date),
2122
"lago_invoice_payment_due_date" => formatted_date(invoice.payment_due_date),
2223
"lago_invoice_payment_overdue" => invoice.payment_overdue,
@@ -27,7 +28,8 @@ def create_body
2728
"lago_invoice_total_amount" => total_amount,
2829
"lago_invoice_total_due_amount" => total_due_amount,
2930
"lago_invoice_subtotal_excluding_taxes" => subtotal_excluding_taxes,
30-
"lago_invoice_file_url" => invoice.file_url
31+
"lago_invoice_file_url" => invoice.file_url,
32+
"lago_invoice_url" => invoice_url
3133
}
3234
}
3335
}
@@ -45,6 +47,7 @@ def update_body
4547
"properties" => {
4648
"lago_invoice_id" => invoice.id,
4749
"lago_invoice_number" => invoice.number,
50+
"lago_invoice_purchase_order_number" => invoice.purchase_order_number,
4851
"lago_invoice_issuing_date" => formatted_date(invoice.issuing_date),
4952
"lago_invoice_payment_due_date" => formatted_date(invoice.payment_due_date),
5053
"lago_invoice_payment_overdue" => invoice.payment_overdue,
@@ -55,7 +58,8 @@ def update_body
5558
"lago_invoice_total_amount" => total_amount,
5659
"lago_invoice_total_due_amount" => total_due_amount,
5760
"lago_invoice_subtotal_excluding_taxes" => subtotal_excluding_taxes,
58-
"lago_invoice_file_url" => invoice.file_url
61+
"lago_invoice_file_url" => invoice.file_url,
62+
"lago_invoice_url" => invoice_url
5963
}
6064
}
6165
}

app/services/integrations/aggregator/invoices/payloads/netsuite.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ def tax_line_item(fee)
8787
}
8888
end
8989

90-
def invoice_url
91-
url = ENV["LAGO_FRONT_URL"].presence || "https://app.getlago.com"
92-
93-
URI.join(url, "/#{invoice.customer.organization.slug}/customer/#{invoice.customer.id}/", "invoice/#{invoice.id}/overview").to_s
94-
end
95-
9690
def due_date
9791
invoice.payment_due_date&.strftime("%-m/%-d/%Y")
9892
end

app/services/integrations/aggregator/invoices/payloads/xero.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ def initialize(integration_customer:, invoice:)
99
super
1010
end
1111

12+
def body
13+
super.map do |invoice_payload|
14+
invoice_payload.merge("reference" => invoice.purchase_order_number)
15+
end
16+
end
17+
1218
def item(fee)
1319
base_item = super
1420
base_item["item_code"] = base_item.delete("external_id")

app/services/integrations/hubspot/invoices/deploy_object_service.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Integrations
44
module Hubspot
55
module Invoices
66
class DeployObjectService < Integrations::Aggregator::BaseService
7-
VERSION = 1
7+
VERSION = 3
88

99
def action_path
1010
"v1/hubspot/object"
@@ -83,6 +83,13 @@ def payload
8383
fieldType: "text",
8484
searchableInGlobalSearch: true
8585
},
86+
{
87+
name: "lago_invoice_purchase_order_number",
88+
label: "Lago Purchase Order Number",
89+
type: "string",
90+
fieldType: "text",
91+
searchableInGlobalSearch: true
92+
},
8693
{
8794
name: "lago_invoice_issuing_date",
8895
label: "Lago Invoice Issuing Date",
@@ -153,6 +160,12 @@ def payload
153160
label: "Lago Invoice File URL",
154161
type: "string",
155162
fieldType: "file"
163+
},
164+
{
165+
name: "lago_invoice_url",
166+
label: "Lago Invoice URL",
167+
type: "string",
168+
fieldType: "text"
156169
}
157170
],
158171
associatedObjects: %w[COMPANY CONTACT]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
class AddEventsOrganizationTimestampIndex < ActiveRecord::Migration[8.0]
4+
disable_ddl_transaction!
5+
6+
def change
7+
add_index :events,
8+
[:organization_id, :timestamp],
9+
order: {timestamp: :desc},
10+
where: "deleted_at IS NULL",
11+
name: "index_events_on_organization_id_and_timestamp",
12+
algorithm: :concurrently,
13+
if_not_exists: true
14+
end
15+
end

db/structure.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ DROP INDEX IF EXISTS public.index_fees_on_billing_entity_id;
643643
DROP INDEX IF EXISTS public.index_fees_on_applied_add_on_id;
644644
DROP INDEX IF EXISTS public.index_fees_on_add_on_id;
645645
DROP INDEX IF EXISTS public.index_events_on_organization_id_and_transaction_id;
646+
DROP INDEX IF EXISTS public.index_events_on_organization_id_and_timestamp;
646647
DROP INDEX IF EXISTS public.index_events_on_organization_id_and_created_at;
647648
DROP INDEX IF EXISTS public.index_events_on_organization_id_and_code;
648649
DROP INDEX IF EXISTS public.index_events_on_organization_id;
@@ -8191,6 +8192,13 @@ CREATE INDEX index_events_on_organization_id_and_code ON public.events USING btr
81918192
CREATE INDEX index_events_on_organization_id_and_created_at ON public.events USING btree (organization_id, created_at DESC) WHERE (deleted_at IS NULL);
81928193

81938194

8195+
--
8196+
-- Name: index_events_on_organization_id_and_timestamp; Type: INDEX; Schema: public; Owner: -
8197+
--
8198+
8199+
CREATE INDEX index_events_on_organization_id_and_timestamp ON public.events USING btree (organization_id, "timestamp" DESC) WHERE (deleted_at IS NULL);
8200+
8201+
81948202
--
81958203
-- Name: index_events_on_organization_id_and_transaction_id; Type: INDEX; Schema: public; Owner: -
81968204
--
@@ -12847,6 +12855,7 @@ ALTER TABLE ONLY public.membership_roles
1284712855
SET search_path TO "$user", public;
1284812856

1284912857
INSERT INTO "schema_migrations" (version) VALUES
12858+
('20260706173746'),
1285012859
('20260706131152'),
1285112860
('20260703164249'),
1285212861
('20260702074504'),

0 commit comments

Comments
 (0)