added technical data to xinon workorder and workordermph now has a unassign button
This commit is contained in:
@@ -826,4 +826,69 @@ class ManualInvoiceController extends TTCrud
|
||||
'vatrate' => $vatrate->rate
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getCustomerBillingInfoAction() {
|
||||
$addressId = $_GET['address_id'] ?? null;
|
||||
$vatgroupId = $_GET['vatgroup_id'] ?? 2;
|
||||
|
||||
if (!$addressId) {
|
||||
self::returnJson(['success' => false, 'message' => 'Address ID required']);
|
||||
return;
|
||||
}
|
||||
|
||||
$address = new Address($addressId);
|
||||
if (!$address->id) {
|
||||
self::returnJson(['success' => false, 'message' => 'Address not found']);
|
||||
return;
|
||||
}
|
||||
|
||||
$vatarea = 'domestic';
|
||||
if ($address->country_id) {
|
||||
$country = new Country($address->country_id);
|
||||
if ($country->id && $country->isocode != TT_HOMECOUNTRY_ISOCODE) {
|
||||
$vatarea = $country->is_eu ? 'eu' : 'other';
|
||||
}
|
||||
}
|
||||
|
||||
if ($address->uid && substr(strtolower(preg_replace('/[^a-z0-9]/i', '', $address->uid)), 0, 3) == 'atu') {
|
||||
$vatarea = 'domestic';
|
||||
}
|
||||
|
||||
$vatrate = VatrateModel::getFirst(['vatgroup_id' => $vatgroupId, 'area' => $vatarea]);
|
||||
$taxText = $vatrate ? $vatrate->invoice_text : '';
|
||||
|
||||
$db = $this->db();
|
||||
$sepaLimit = null;
|
||||
$res = $db->query("SELECT manual_invoice_sepa_limit FROM Address WHERE id = " . intval($addressId));
|
||||
if ($res && $row = $res->fetch_assoc()) {
|
||||
$sepaLimit = $row['manual_invoice_sepa_limit'] ? floatval($row['manual_invoice_sepa_limit']) : null;
|
||||
}
|
||||
|
||||
self::returnJson([
|
||||
'success' => true,
|
||||
'billing_type' => $address->billing_type ?: 'invoice',
|
||||
'manual_invoice_sepa_limit' => $sepaLimit,
|
||||
'vatarea' => $vatarea,
|
||||
'tax_text' => $taxText,
|
||||
'bank_account_bank' => $address->bank_account_bank,
|
||||
'bank_account_owner' => $address->bank_account_owner,
|
||||
'bank_account_iban' => $address->bank_account_iban,
|
||||
'bank_account_bic' => $address->bank_account_bic,
|
||||
'sepa_date' => $address->sepa_date,
|
||||
'sepa_id' => $address->sepa_id
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getTaxTextAction() {
|
||||
$vatgroupId = $_GET['vatgroup_id'] ?? 2;
|
||||
$vatarea = $_GET['vatarea'] ?? 'domestic';
|
||||
|
||||
$vatrate = VatrateModel::getFirst(['vatgroup_id' => $vatgroupId, 'area' => $vatarea]);
|
||||
|
||||
self::returnJson([
|
||||
'success' => true,
|
||||
'tax_text' => $vatrate ? $vatrate->invoice_text : '',
|
||||
'vatrate' => $vatrate ? $vatrate->rate : 20
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user