subscription added

This commit is contained in:
2026-04-20 17:02:33 -05:00
parent 88582cbc77
commit 93db2f237f
3 changed files with 21 additions and 6 deletions

View File

@@ -47,7 +47,9 @@ export function addItem(containerId, { item = null, type = 'invoice', laborRate
temp.innerHTML = item.description;
previewDesc = temp.textContent.substring(0, 50) + (temp.textContent.length > 50 ? '...' : '');
}
const typeLabel = (item && item.qbo_item_id == '5') ? 'Labor' : 'Parts';
const typeLabel = (item && item.qbo_item_id == '5') ? 'Labor'
: (item && item.qbo_item_id == '115') ? 'Subscription'
: 'Parts';
const itemDiv = document.createElement('div');
itemDiv.className = 'border border-gray-300 rounded-lg mb-3 bg-white';
@@ -87,6 +89,7 @@ export function addItem(containerId, { item = null, type = 'invoice', laborRate
<select data-item="${itemId}" data-field="qbo_item_id" class="w-full px-2 py-2 border border-gray-300 rounded-md text-sm bg-white" onchange="window.itemEditor.handleTypeChange(this, '${prefix}', ${itemId})">
<option value="9" ${item && item.qbo_item_id == '9' ? 'selected' : ''}>Parts</option>
<option value="5" ${item && item.qbo_item_id == '5' ? 'selected' : ''}>Labor</option>
<option value="115" ${item && item.qbo_item_id == '115' ? 'selected' : ''}>Subscription</option>
</select>
</div>
@@ -177,7 +180,9 @@ function updateItemPreview(itemDiv) {
if (amountPreview && amountInput) amountPreview.textContent = amountInput.value || '$0.00';
if (typePreview && typeInput) {
typePreview.textContent = typeInput.value == '5' ? 'Labor' : 'Parts';
typePreview.textContent = typeInput.value == '5' ? 'Labor'
: typeInput.value == '115' ? 'Subscription'
: 'Parts';
}
if (descPreview && editorDiv && editorDiv.quillInstance) {

View File

@@ -520,7 +520,9 @@ router.post('/:id/export', async (req, res) => {
const rate = parseFloat(item.rate.replace(/[^0-9.]/g, '')) || 0;
const amount = parseFloat(item.amount.replace(/[^0-9.]/g, '')) || 0;
const itemRefId = item.qbo_item_id || '9';
const itemRefName = itemRefId == '5' ? "Labor:Labor" : "Parts:Parts";
const itemRefName = itemRefId == QBO_LABOR_ID ? "Labor:Labor"
: itemRefId == '115' ? "Subscription"
: "Parts:Parts";
return {
"DetailType": "SalesItemLineDetail",
@@ -653,7 +655,9 @@ router.post('/:id/update-qbo', async (req, res) => {
const rate = parseFloat(item.rate.replace(/[^0-9.]/g, '')) || 0;
const amount = parseFloat(item.amount.replace(/[^0-9.]/g, '')) || 0;
const itemRefId = item.qbo_item_id || QBO_PARTS_ID;
const itemRefName = itemRefId == QBO_LABOR_ID ? "Labor:Labor" : "Parts:Parts";
const itemRefName = itemRefId == QBO_LABOR_ID ? "Labor:Labor"
: itemRefId == '115' ? "Subscription"
: "Parts:Parts";
return {
"DetailType": "SalesItemLineDetail",

View File

@@ -8,6 +8,7 @@ const { getOAuthClient, getQboBaseUrl, makeQboApiCall } = require('../config/qbo
// QBO Item IDs
const QBO_LABOR_ID = '5';
const QBO_PARTS_ID = '9';
const QBO_SUBSCRIPTION_ID = '115';
function getClientInfo() {
const oauthClient = getOAuthClient();
@@ -54,7 +55,9 @@ async function exportInvoiceToQbo(invoiceId, dbClient) { // <-- Nutzt jetzt dbCl
const qty = parseNum(item.quantity) || 1;
const amount = rate * qty;
const itemRefId = item.qbo_item_id || QBO_PARTS_ID;
const itemRefName = itemRefId == QBO_LABOR_ID ? "Labor:Labor" : "Parts:Parts";
const itemRefName = itemRefId == QBO_LABOR_ID ? "Labor:Labor"
: itemRefId == QBO_SUBSCRIPTION_ID ? "Subscription"
: "Parts:Parts";
return {
"DetailType": "SalesItemLineDetail",
@@ -157,7 +160,9 @@ async function syncInvoiceToQbo(invoiceId, dbClient) { // <-- Nutzt jetzt dbClie
const qty = parseNum(item.quantity) || 1;
const amount = rate * qty;
const itemRefId = item.qbo_item_id || QBO_PARTS_ID;
const itemRefName = itemRefId == QBO_LABOR_ID ? "Labor:Labor" : "Parts:Parts";
const itemRefName = itemRefId == QBO_LABOR_ID ? "Labor:Labor"
: itemRefId == QBO_SUBSCRIPTION_ID ? "Subscription"
: "Parts:Parts";
return {
"DetailType": "SalesItemLineDetail",
@@ -216,6 +221,7 @@ async function syncInvoiceToQbo(invoiceId, dbClient) { // <-- Nutzt jetzt dbClie
module.exports = {
QBO_LABOR_ID,
QBO_PARTS_ID,
QBO_SUBSCRIPTION_ID,
getClientInfo,
exportInvoiceToQbo,
syncInvoiceToQbo