Phase 115 complete (vertical slice "zamowienie z NIP -> faktura PDF"):
- Task 1: InvoiceRepository + InvoiceService (dual-flow orchestrator) +
InvoiceIssueException + FakturowniaApiClient::createInvoice + buildPdfUrl
- Task 2: InvoiceController + OrdersController::toggleInvoiceRequested +
OrdersRepository::setInvoiceRequested + auto-import invoice_requested z
Allegro (invoice.required) i shopPRO (5-key flexible parser) + show.php
(toggle w zakladce Platnosci + warunkowy przycisk Wystaw fakture)
- Task 3: Lista wystawionych /settings/accounting/invoices/issued z filtrami
+ invoice_preview + invoice_pdf Dompdf template + hub link
- Task 3b (dodany): NIP lookup przez MF Biala Lista (publiczne API, bez
rejestracji) — MfWhitelistApiClient w src/Core/Http/ + /api/nip/lookup +
przycisk "Pobierz z GUS" w formularzu
Auto-fixes podczas smoke testu (5):
- GUS endpoint Fakturowni nie istnial (HTML 404 -> "json is not valid");
switch na MF Biala Liste
- PHP 8.5 curl_close() deprecation wycieka HTML przed JSON; usuniete z
MfWhitelistApiClient i FakturowniaApiClient (3 miejsca)
- Fakturownia 422 payment_to_kind_days (nieistniejace pole) -> usuniete
- Generic "error" w 422 -> parser plaskuje errors: {pole: [...]} +
error_log z 1000 znakow raw body
- Fakturownia security odrzuca seller_*/department_id jako "create new
department"; usuniete z payloadu (Fakturownia uzywa danych konta)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
63 lines
2.3 KiB
JavaScript
63 lines
2.3 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
function init() {
|
|
var checkbox = document.querySelector('[data-invoice-requested-toggle]');
|
|
if (!checkbox || checkbox.dataset.bound === '1') {
|
|
return;
|
|
}
|
|
checkbox.dataset.bound = '1';
|
|
|
|
var orderId = checkbox.dataset.orderId || '';
|
|
var token = checkbox.dataset.csrfToken || '';
|
|
var buttonWrap = document.querySelector('[data-invoice-button-wrap]');
|
|
|
|
checkbox.addEventListener('change', function () {
|
|
var newValue = checkbox.checked ? 1 : 0;
|
|
checkbox.disabled = true;
|
|
|
|
var formData = new FormData();
|
|
formData.append('_token', token);
|
|
formData.append('invoice_requested', String(newValue));
|
|
|
|
fetch('/orders/' + encodeURIComponent(orderId) + '/invoice-requested/toggle', {
|
|
method: 'POST',
|
|
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
|
body: formData,
|
|
credentials: 'same-origin'
|
|
})
|
|
.then(function (resp) {
|
|
if (!resp.ok) {
|
|
throw new Error('HTTP ' + resp.status);
|
|
}
|
|
return resp.json();
|
|
})
|
|
.then(function (data) {
|
|
if (!data || !data.success) {
|
|
throw new Error(data && data.error ? data.error : 'Blad serwera');
|
|
}
|
|
if (buttonWrap) {
|
|
buttonWrap.style.display = newValue ? '' : 'none';
|
|
}
|
|
})
|
|
.catch(function (err) {
|
|
checkbox.checked = !checkbox.checked;
|
|
if (window.OrderProAlerts && typeof window.OrderProAlerts.error === 'function') {
|
|
window.OrderProAlerts.error('Nie udalo sie zmienic flagi faktury: ' + (err && err.message ? err.message : ''));
|
|
} else {
|
|
console.error('invoice-requested toggle failed', err);
|
|
}
|
|
})
|
|
.finally(function () {
|
|
checkbox.disabled = false;
|
|
});
|
|
});
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', init);
|
|
} else {
|
|
init();
|
|
}
|
|
})();
|