feat(114): accounting configs refactor + invoice configs CRUD

Phase 114 complete (v3.7 Invoices):
- /settings/accounting jako hub-rozdroze (Paragony / Faktury)
- /settings/accounting/receipts + /invoices osobne podstrony list i edycji
- InvoiceConfigRepository + Controller (CRUD z walidacja delegacji)
- Seed Domyslny VAT (NOT EXISTS idempotent)
- invoice-config-form.js (toggle is_delegated -> integration_id)
- confirm-delete.js (globalny modul OrderProAlerts.confirm)
- Legacy aliasy starych endpointow /settings/accounting/save|toggle|delete

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-10 22:32:29 +02:00
parent 2382018739
commit 6129042ff6
22 changed files with 1663 additions and 192 deletions

View File

@@ -0,0 +1,47 @@
(function () {
'use strict';
function bind(btn) {
if (btn.dataset.confirmBound === '1') return;
btn.dataset.confirmBound = '1';
btn.addEventListener('click', function () {
var form = btn.closest('form');
if (!form) return;
var title = form.getAttribute('data-confirm-title') || 'Usun pozycje';
var message = form.getAttribute('data-confirm-message') || 'Czy na pewno chcesz usunac ten wpis?';
if (window.OrderProAlerts && typeof window.OrderProAlerts.confirm === 'function') {
var submitted = false;
var doSubmit = function () {
if (submitted) return;
submitted = true;
form.submit();
};
var result = window.OrderProAlerts.confirm({
title: title,
message: message,
danger: true,
confirmLabel: 'Usun',
onConfirm: doSubmit
});
if (result && typeof result.then === 'function') {
result.then(function (ok) { if (ok) doSubmit(); });
}
} else if (window.confirm(message)) {
form.submit();
}
});
}
function init() {
document.querySelectorAll('.js-delete-btn').forEach(bind);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();

View File

@@ -0,0 +1,35 @@
(function () {
'use strict';
function sync(checkbox, wrapper) {
if (!checkbox || !wrapper) return;
var select = wrapper.querySelector('select[name="integration_id"]');
if (checkbox.checked) {
wrapper.style.display = '';
if (select) select.required = true;
} else {
wrapper.style.display = 'none';
if (select) {
select.required = false;
select.value = '';
}
}
}
function init() {
var checkbox = document.querySelector('[data-invoice-delegated]');
var wrapper = document.querySelector('[data-invoice-delegation]');
if (!checkbox || !wrapper) return;
sync(checkbox, wrapper);
checkbox.addEventListener('change', function () {
sync(checkbox, wrapper);
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();