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
6 changes: 3 additions & 3 deletions src/app/api/quickbooks/invoice/invoice.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ export class InvoiceService extends BaseService {
// check if the flag is on for create new item
const settingService = new SettingService(this.user)
const setting = await settingService.getOneByPortalId([
'createInvoiceItemFlag',
'createNewProductFlag',
])

if (!setting?.createInvoiceItemFlag) {
if (!setting?.createNewProductFlag) {
console.info(
'WebhookService#getInvoiceItemRef | Create new invoice item flag is false',
'WebhookService#getInvoiceItemRef | Create new product flag is false',
)
return { ref: oneOffItem }
}
Expand Down
10 changes: 5 additions & 5 deletions src/app/api/quickbooks/setting/setting.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ export async function getSettings(req: NextRequest) {
const settingService = new SettingService(user)
const type = req.nextUrl.searchParams.get('type')
const parsedType = z.nativeEnum(SettingType).safeParse(type)
const returnigFields: (keyof typeof QBSetting)[] = []
const returningFields: (keyof typeof QBSetting)[] = []

if (parsedType.success) {
// return attributes as per the type. If type not provided, return all attributes
returnigFields.push('id', 'initialSettingMap')
returningFields.push('id', 'initialSettingMap')
if (parsedType.data === SettingType.INVOICE)
returnigFields.push('absorbedFeeFlag', 'useCompanyNameFlag')
returningFields.push('absorbedFeeFlag', 'useCompanyNameFlag')
if (parsedType.data === SettingType.PRODUCT)
returnigFields.push('createNewProductFlag', 'createInvoiceItemFlag')
returningFields.push('createNewProductFlag')
}
const setting = await settingService.getOneByPortalId(returnigFields)
const setting = await settingService.getOneByPortalId(returningFields)
return NextResponse.json({ setting })
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ export default function ProductMapping({
<div className="mt-2 mb-6">
<div className="mb-5">
<Checkbox
label="Add newly created products to Quickbooks"
description="Automatically create matching items in QuickBooks with product name,
description, and price when new products are created in Copilot."
label="Sync Copilot products to QuickBooks"
description="Automatically create and update QuickBooks items when products are created or used in Copilot."
checked={setting.settingState.createNewProductFlag}
onChange={() =>
setting.changeSettings(
Expand All @@ -70,20 +69,6 @@ export default function ProductMapping({
}
/>
</div>
<div className="mb-5">
<Checkbox
label="Create an item in QuickBooks if Copilot product is not found"
description="Create missing QuickBooks items when syncing invoices containing
Copilot products that don't yet exist in QuickBooks."
checked={setting.settingState.createInvoiceItemFlag}
onChange={() =>
setting.changeSettings(
'createInvoiceItemFlag',
!setting.settingState.createInvoiceItemFlag,
)
}
/>
</div>

{/* Product Mapping table */}
<ProductMappingTable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "qb_settings" DROP COLUMN "create_invoice_item_flag";
Loading
Loading