Merge branch 'faktax' into 'master'
Tax API calls. See merge request 076/community/076Server!15
このコミットが含まれているのは:
コミット
c691b54eff
|
@ -1703,4 +1703,171 @@ class InvoiceController extends Controller {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tax
|
||||
public function getTaxes(Request $request) { // /api/rpc/invoice/taxes/getall
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
if ($check == 0) {
|
||||
return 'Err!';
|
||||
}
|
||||
else {
|
||||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
if ($valid['inv_makeinvoice'] == 1) {
|
||||
if ($valid['inv_manuser'] == 1) {
|
||||
return DB::table('inv_taxes')
|
||||
->select(
|
||||
'id',
|
||||
'user_id',
|
||||
'name',
|
||||
'percentage'
|
||||
)
|
||||
->get();
|
||||
|
||||
}
|
||||
else {
|
||||
return DB::table('inv_taxes')
|
||||
->select(
|
||||
'id',
|
||||
'name',
|
||||
'percentage'
|
||||
)
|
||||
->where('user_id', $check)
|
||||
->get();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTax($id, Request $request) { // /api/rpc/invoice/taxes/get/id
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
if ($check == 0) {
|
||||
return 'Err!';
|
||||
}
|
||||
else {
|
||||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
if ($valid['inv_makeinvoice'] == 1) {
|
||||
if ($valid['inv_manuser'] == 1) {
|
||||
return DB::table('inv_taxes')
|
||||
->select('*')
|
||||
->where('id', $id)
|
||||
->get();
|
||||
}
|
||||
else {
|
||||
return DB::table('inv_taxes')
|
||||
->select('*')
|
||||
->where('id', $id)
|
||||
->where('user_id', $check)
|
||||
->get();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function newTax(Request $request) { // /api/rpc/invoice/taxes/new
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
if ($check == 0) {
|
||||
return 'Err!';
|
||||
}
|
||||
else {
|
||||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
if ($valid['inv_makeinvoice'] == 1) {
|
||||
if ($valid['inv_manuser'] == 1) {
|
||||
$add = DB::table('inv_taxes')
|
||||
->insertGetId([
|
||||
'user_id' => $request->user_id,
|
||||
'name' => $request->name,
|
||||
'percentage' => $request->percentage
|
||||
]);
|
||||
}
|
||||
else {
|
||||
$add = DB::table('inv_taxes')
|
||||
->insertGetId([
|
||||
'user_id' => $check,
|
||||
'name' => $request->name,
|
||||
'percentage' => $request->percentage
|
||||
]);
|
||||
}
|
||||
|
||||
return $add;
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function editTax(Request $request) { // /api/rpc/invoice/taxes/edit
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
if ($check == 0) {
|
||||
return 'Err!';
|
||||
}
|
||||
else {
|
||||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
if ($valid['inv_makeinvoice'] == 1) {
|
||||
if ($valid['inv_manuser'] == 1) {
|
||||
DB::table('inv_taxes')
|
||||
->where('id', $request->id)
|
||||
->update([
|
||||
'user_id' => $request->user_id,
|
||||
'name' => $request->name,
|
||||
'percentage' => $request->percentage
|
||||
]);
|
||||
}
|
||||
else {
|
||||
DB::table('inv_taxes')
|
||||
->where('id', $request->id)
|
||||
->where('user_id', $check)
|
||||
->update([
|
||||
'user_id' => $check,
|
||||
'name' => $request->name,
|
||||
'percentage' => $request->percentage
|
||||
]);
|
||||
}
|
||||
|
||||
return 'Success!';
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteTax(Request $request) { // /api/rpc/invoice/taxes/delete
|
||||
$check = $this->objAuth->checkLegit($request->username, $request->password);
|
||||
|
||||
if ($check == 0) {
|
||||
return 'Err!';
|
||||
}
|
||||
else {
|
||||
$valid = $this->objAuth->getPermissions($request->username, $request->password);
|
||||
|
||||
if ($valid['inv_makeinvoice'] == 1) {
|
||||
if ($valid['inv_manuser'] == 1) {
|
||||
DB::table('inv_taxes')->where('id', $request->id)->delete();
|
||||
}
|
||||
else {
|
||||
DB::table('inv_taxes')->where('id', $request->id)->where('user_id', $check)->delete();
|
||||
}
|
||||
|
||||
return 'Done.';
|
||||
}
|
||||
else {
|
||||
return 'Permission denied.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,26 +30,31 @@ Route::get('/api/rpc/invoice/invoices/getall', 'InvoiceController@getInvoices');
|
|||
Route::get('/api/rpc/invoice/periods/getall', 'InvoiceController@getPeriods');
|
||||
Route::get('/api/rpc/invoice/products/getall', 'InvoiceController@getProducts');
|
||||
Route::get('/api/rpc/invoice/services/getall', 'InvoiceController@getServices');
|
||||
Route::get('/api/rpc/invoice/taxes/getall', 'InvoiceController@getTaxes');
|
||||
|
||||
Route::get('/api/rpc/invoice/invoices/get/{id}', 'InvoiceController@getInvoice');
|
||||
Route::get('/api/rpc/invoice/periods/get/{id}', 'InvoiceController@getPeriod');
|
||||
Route::get('/api/rpc/invoice/products/get/{id}', 'InvoiceController@getProduct');
|
||||
Route::get('/api/rpc/invoice/services/get/{id}', 'InvoiceController@getService');
|
||||
Route::get('/api/rpc/invoice/taxes/get/{id}', 'InvoiceController@getTax');
|
||||
|
||||
Route::post('/api/rpc/invoice/invoices/delete', 'InvoiceController@deleteInvoice');
|
||||
Route::post('/api/rpc/invoice/invoices/deleteitem', 'InvoiceController@deleteInvoiceItem');
|
||||
Route::post('/api/rpc/invoice/periods/delete', 'InvoiceController@deletePeriod');
|
||||
Route::post('/api/rpc/invoice/products/delete', 'InvoiceController@deleteProduct');
|
||||
Route::post('/api/rpc/invoice/services/delete', 'InvoiceController@deleteService');
|
||||
Route::post('/api/rpc/invoice/taxes/delete', 'InvoiceController@deleteTax');
|
||||
|
||||
Route::post('/api/rpc/invoice/invoices/edit', 'InvoiceController@editInvoice');
|
||||
Route::post('/api/rpc/invoice/invoices/edititem', 'InvoiceController@editInvoiceItem');
|
||||
Route::post('/api/rpc/invoice/periods/edit', 'InvoiceController@editPeriod');
|
||||
Route::post('/api/rpc/invoice/products/edit', 'InvoiceController@editProduct');
|
||||
Route::post('/api/rpc/invoice/services/edit', 'InvoiceController@editService');
|
||||
Route::post('/api/rpc/invoice/taxes/edit', 'InvoiceController@editTax');
|
||||
|
||||
Route::post('/api/rpc/invoice/invoices/new', 'InvoiceController@newInvoice');
|
||||
Route::post('/api/rpc/invoice/invoices/newitem', 'InvoiceController@newInvoiceItem');
|
||||
Route::post('/api/rpc/invoice/periods/new', 'InvoiceController@newPeriod');
|
||||
Route::post('/api/rpc/invoice/products/new', 'InvoiceController@newProduct');
|
||||
Route::post('/api/rpc/invoice/services/new', 'InvoiceController@newService');
|
||||
Route::post('/api/rpc/invoice/taxes/new', 'InvoiceController@newTax');
|
||||
|
|
新しいイシューから参照