diff --git a/packages/accounting_automation/src/invoice-filing.ts b/packages/accounting_automation/src/invoice-filing.ts index afd49f5..9752099 100644 --- a/packages/accounting_automation/src/invoice-filing.ts +++ b/packages/accounting_automation/src/invoice-filing.ts @@ -48,7 +48,7 @@ export async function runInvoiceFiling(deps: { pool: Pool; drive: FilingDrive; l const { rows } = await pool.query<{ id: string; drive_file_id: string; vendor_name: string; amount: string; paid_on: string; account_name: string }>( `select i.id, i.drive_file_id, i.vendor_name, i.amount::text, i.paid_on::text, p.account_name from acc_invoices i join qbo_purchase p on p.id = i.qbo_txn_id - where i.paid_on is not null and p.account_name is not null + where i.paid_on is not null and p.account_name is not null and i.drive_file_id is not null and (i.drive_folder is null or i.drive_folder like 'Инвойсы/${UNPAID_FOLDER}/%') order by i.paid_on limit ${BATCH}`, );