implement using last comment instructions
- User
implement using last comment instructions
Assistant
Based on the discussion in the PR comments, here's how to implement the requested feature to allow VAT-only lines in invoices and credit notes:
- First, add a new constant in the configuration:
php// In some appropriate configuration file or init script define('MAIN_ALLOW_VAT_ONLY_LINES', 1); // Set to 0 to disable- Modify the invoice card.php to handle VAT-only lines:
php// In htdocs/compta/facture/card.php // Around line 270, modify the validation check: if ($object->type == Facture::TYPE_CREDIT_NOTE) { // If VAT-only lines are allowed and this is a VAT-only credit note if (!empty($conf->global->MAIN_ALLOW_VAT_ONLY_LINES) && $object->total_ht == 0 && $object->total_tva < 0) { // Allow validation of VAT-only credit notes } // Standard credit note validation else if ($object->total_ttc >= 0) { setEventMessages($langs->trans("ErrorInvoiceAvoirMustBeNegative"), null, 'errors'); $action = ''; } }- Add the VAT-only option to the line type selector (in the template or form handling code):
php// In the form where line types are selected if (!empty($conf->global->MAIN_ALLOW_VAT_ONLY_LINES)) { $form->select_type_of_lines('vat_only', $langs->trans("VATOnly"), 'vatonly'); }- Modify the line handling code to accept VAT-only lines:
php
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.