Skip to content

Commit

Permalink
rename getInvoices to getMonthlySubscriptionInvoices
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoTuxx committed Feb 28, 2025
1 parent 9a2ef87 commit 39ab2b6
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 7 deletions.
4 changes: 2 additions & 2 deletions client/src/services/bms/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,11 @@ class BmsAccess {
});
}

async getInvoices(): Promise<BmsResponse> {
async getMonthlySubscriptionInvoices(): Promise<BmsResponse> {
assertLoggedIn(this.tokens);
assertLoggedIn(this.customerInformation);
await this.ensureFreshToken();
return await this.api.getInvoices(this.tokens.access, {
return await this.api.getMonthlySubscriptionInvoices(this.tokens.access, {
userId: this.customerInformation.id,
clientId: this.customerInformation.clientId,
});
Expand Down
4 changes: 2 additions & 2 deletions client/src/services/bms/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ async function getOrganizationStatus(token: AuthenticationToken, query: Organiza
});
}

async function getInvoices(token: AuthenticationToken, query: ClientQueryData): Promise<BmsResponse> {
async function getMonthlySubscriptionInvoices(token: AuthenticationToken, query: ClientQueryData): Promise<BmsResponse> {
return await wrapQuery(async () => {
const axiosResponse = await http.getInstance().get(`/users/${query.userId}/clients/${query.clientId}/invoices`, {
headers: { Authorization: `Bearer ${token}` },
Expand Down Expand Up @@ -713,7 +713,7 @@ export const BmsApi = {
listOrganizations,
getOrganizationStats,
getOrganizationStatus,
getInvoices,
getMonthlySubscriptionInvoices,
refreshToken,
getBillingDetails,
addPaymentMethod,
Expand Down
2 changes: 1 addition & 1 deletion client/src/services/bms/mockApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export const MockedBmsApi = {
};
}),
getOrganizationStatus: createMockFunction('getOrganizationStatus'),
getInvoices: createMockFunction('getInvoices'),
getMonthlySubscriptionInvoices: createMockFunction('getMonthlySubscriptionInvoices'),
refreshToken: createMockFunction('refreshToken'),
getBillingDetails: createMockFunction('getBillingDetails'),
addPaymentMethod: createMockFunction('addPaymentMethod'),
Expand Down
109 changes: 109 additions & 0 deletions client/src/services/bms/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ interface BmsInvoice {
status: InvoiceStatus;
organizationId: OrganizationID;
number: string;
receiptNumber: string;
}

enum InvoiceStatus {
Expand Down Expand Up @@ -366,6 +367,111 @@ interface CreateCustomOrderRequestQueryData {
organizationName?: string;
}

enum InvoiceType {
Sellsy = 'sellsy',

Check warning on line 371 in client/src/services/bms/types.ts

View workflow job for this annotation

GitHub Actions / spelling / cspell

Unknown word (Sellsy)

Check warning on line 371 in client/src/services/bms/types.ts

View workflow job for this annotation

GitHub Actions / spelling / cspell

Unknown word (sellsy)
Stripe = 'stripe',
}

interface Invoice {
getType(): InvoiceType;
getId(): string;
getDate(): DateTime;
getNumber(): string;
getAmount(): number;
getOrganizationId(): string;
getStatus(): InvoiceStatus;
getLink(): string;
}

class SellsyInvoice implements Invoice {

Check warning on line 386 in client/src/services/bms/types.ts

View workflow job for this annotation

GitHub Actions / spelling / cspell

Unknown word (Sellsy)
invoice: CustomOrderDetailsResultData;

constructor(invoice: CustomOrderDetailsResultData) {
this.invoice = invoice;
}

getType(): InvoiceType {
return InvoiceType.Sellsy;

Check warning on line 394 in client/src/services/bms/types.ts

View workflow job for this annotation

GitHub Actions / spelling / cspell

Unknown word (Sellsy)
}

getId(): string {
return this.invoice.id.toString();
}

getDate(): DateTime {
return this.invoice.created;
}

getNumber(): string {
return this.invoice.number;
}

getAmount(): number {
return this.invoice.amountWithTaxes;
}

// TODO: Replace with real organization ID
getOrganizationId(): string {
return 'organizationId';
}

getStatus(): InvoiceStatus {
return this.invoice.status;
}

getLink(): string {
return this.invoice.link;
}

getLicenseStart(): DateTime | undefined {
return this.invoice.licenseStart;
}

getLicenseEnd(): DateTime | undefined {
return this.invoice.licenseEnd;
}
}

class StripeInvoice implements Invoice {
invoice: BmsInvoice;

constructor(invoice: BmsInvoice) {
this.invoice = invoice;
}

getType(): InvoiceType {
return InvoiceType.Stripe;
}

getId(): string {
return this.invoice.id;
}

getDate(): DateTime {
return this.invoice.start;
}

getNumber(): string {
return this.invoice.number;
}

getAmount(): number {
return this.invoice.total;
}

getOrganizationId(): string {
return this.invoice.organizationId;
}

getStatus(): InvoiceStatus {
return this.invoice.status;
}

getLink(): string {
return this.invoice.pdfLink;
}
}

export {
AddPaymentMethodQueryData,
AuthenticationToken,
Expand All @@ -390,6 +496,7 @@ export {
CustomOrderStatusResultData,
DataType,
DeletePaymentMethodQueryData,
Invoice,
InvoiceStatus,
ListOrganizationsResultData,
LoginQueryData,
Expand All @@ -399,7 +506,9 @@ export {
OrganizationStatusResultData,
PaymentMethod,
PersonalInformationResultData,
SellsyInvoice,

Check warning on line 509 in client/src/services/bms/types.ts

View workflow job for this annotation

GitHub Actions / spelling / cspell

Unknown word (Sellsy)
SetDefaultPaymentMethodQueryData,
StripeInvoice,
UpdateAuthenticationQueryData,
UpdateBillingDetailsQueryData,
UpdateEmailQueryData,
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/client-area/dashboard/DashboardPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ onMounted(async () => {
}
}

const invoicesResponse = await BmsAccessInstance.get().getInvoices();
const invoicesResponse = await BmsAccessInstance.get().getMonthlySubscriptionInvoices();
if (!invoicesResponse.isError && invoicesResponse.data && invoicesResponse.data.type === DataType.Invoices) {
invoices.value = invoicesResponse.data.invoices
.filter((invoice) => isDefaultOrganization(props.organization) || invoice.organizationId === props.organization.parsecId)
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/client-area/invoices/InvoicesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const querying = ref(true);

onMounted(async () => {
querying.value = true;
const response = await BmsAccessInstance.get().getInvoices();
const response = await BmsAccessInstance.get().getMonthlySubscriptionInvoices();
if (!response.isError && response.data && response.data.type === DataType.Invoices) {
invoices.value = response.data.invoices
.filter((invoice) => isDefaultOrganization(props.organization) || invoice.organizationId === props.organization.parsecId)
Expand Down

0 comments on commit 39ab2b6

Please sign in to comment.