Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 9 additions & 11 deletions src/app/api/quickbooks/invoice/invoice.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ export class InvoiceService extends BaseService {
await this.createQBInvoice(invoicePayload)

// update/ create the record in sync log table
const totalWithTax = actualTotalAmount + totalTax
await this.logSync(
invoiceResource.id,
{
Expand All @@ -459,7 +460,7 @@ export class InvoiceService extends BaseService {
},
EventType.CREATED,
{
amount: (actualTotalAmount * 100).toFixed(2), // convert to cents for logs
amount: (totalWithTax * 100).toFixed(2),
taxAmount: (totalTax * 100).toFixed(2), // convert to cents for logs
customerName: recipientInfo.displayName,
customerEmail: recipientInfo.email,
Expand All @@ -473,13 +474,13 @@ export class InvoiceService extends BaseService {
if (invoiceResource.status === InvoiceStatus.PAID) {
const paymentService = new PaymentService(this.user)
const qbPaymentPayload = {
TotalAmt: actualTotalAmount,
TotalAmt: totalWithTax,
CustomerRef: {
value: customerRefValue,
},
Line: [
{
Amount: actualTotalAmount,
Amount: totalWithTax,
LinkedTxn: [
{
TxnId: invoiceRes.Invoice.Id,
Expand Down Expand Up @@ -638,15 +639,11 @@ export class InvoiceService extends BaseService {
)
}

const syncLog = await this.syncLogService.getOneByCopilotIdAndEventType(
payload.data.id,
EventType.VOIDED,
)

if (syncLog?.status === LogStatus.SUCCESS) {
console.info(
'WebhookService#webhookInvoiceVoided | Invoice already voided',
if (invoiceSync.status !== InvoiceStatus.OPEN) {
console.error(
'WebhookService#handleInvoiceVoided | Invoices void was requested for non-open record',
)
return // return early if invoice is not open
}

// get invoice sync log
Expand Down Expand Up @@ -726,6 +723,7 @@ export class InvoiceService extends BaseService {
console.error(
'WebhookService#handleInvoiceDeleted | Invoices delete was requested for non-voided record',
)
return // return early if invoice is not voided
}

// get invoice sync log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const MapItemComponent = ({
currency: 'USD',
}).format(
currentlyMapped.unitPrice
? parseFloat(currentlyMapped.unitPrice)
? parseFloat(currentlyMapped.unitPrice) / 100
: 0,
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/hook/useQuickbooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
) => {
const [loading, setLoading] = useState(false)
const [isReconnecting, setIsReconnecting] = useState(reconnect)
const { setAppParams } = useApp()
const { setAppParams, portalConnectionStatus } = useApp()

useEffect(() => {
const supabase = SupabaseClient.getInstance()
Expand Down Expand Up @@ -93,7 +93,7 @@
return () => {
supabase.removeChannel(realtimeSyncChannel)
}
}, [])

Check warning on line 96 in src/hook/useQuickbooks.ts

View workflow job for this annotation

GitHub Actions / Run linters

React Hook useEffect has missing dependencies: 'setAppParams' and 'tokenPayload?.workspaceId'. Either include them or remove the dependency array

// handle reconnect logic
useEffect(() => {
Expand All @@ -105,7 +105,7 @@
if (reconnect) {
handleAppConnect()
}
}, [reconnect])

Check warning on line 108 in src/hook/useQuickbooks.ts

View workflow job for this annotation

GitHub Actions / Run linters

React Hook useEffect has a missing dependency: 'handleConnect'. Either include it or remove the dependency array

const getAuthUrl = async (type?: string) => {
const redirectUrl = copilotDashboardUrl
Expand All @@ -128,7 +128,7 @@

// set time-out in case if user closes the popped up window. This will prevent the app from the infinite "connecting" state
const timeout = setTimeout(() => {
if (!hasConnection) {
if (!portalConnectionStatus) {
setLoading(false)
}
}, 120000) // timeout after 2 minutes
Expand Down
2 changes: 1 addition & 1 deletion src/utils/intuitAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export default class IntuitAPI {

async _voidInvoice(payload: QBDestructiveInvoicePayloadSchema) {
console.info(
`IntuitAPI#voidInvoice | invoice void creation start for realmId: ${this.tokens.intuitRealmId}. Payload: `,
`IntuitAPI#voidInvoice | invoice void start for realmId: ${this.tokens.intuitRealmId}. Payload: `,
payload,
)
const url = `${intuitBaseUrl}/v3/company/${this.tokens.intuitRealmId}/invoice?operation=void&minorversion=${intuitApiMinorVersion}`
Expand Down
Loading