mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 22:07:33 -05:00 
			
		
		
		
	Updated mail queries
This commit is contained in:
		
							parent
							
								
									5fbf1eea1e
								
							
						
					
					
						commit
						be00f173c4
					
				@ -51,9 +51,9 @@ class EmailHistoryController extends BaseController
 | 
			
		||||
        /** @var \App\Models\User $user */
 | 
			
		||||
        $user = auth()->user();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        $data = SystemLog::where('company_id', $user->company()->id)
 | 
			
		||||
        ->where('category_id', SystemLog::CATEGORY_MAIL)
 | 
			
		||||
        ->whereJsonContains('log->history->entity', $this->encodePrimaryKey($request->entity))
 | 
			
		||||
        ->whereJsonContains('log->history->entity_id', $this->encodePrimaryKey($request->entity_id))
 | 
			
		||||
        ->orderBy('id', 'DESC')
 | 
			
		||||
        ->cursor()
 | 
			
		||||
 | 
			
		||||
@ -90,7 +90,7 @@ class Peppol extends AbstractService
 | 
			
		||||
        'NO' => 'VAT',
 | 
			
		||||
        'AD' => 'VAT',
 | 
			
		||||
        'AL' => 'VAT',
 | 
			
		||||
        'AT' => 'VAT',
 | 
			
		||||
        'AT' => 'VAT', //Pending Tests.
 | 
			
		||||
        'BA' => 'VAT',
 | 
			
		||||
        'BE' => 'VAT',
 | 
			
		||||
        'BG' => 'VAT',
 | 
			
		||||
@ -102,12 +102,12 @@ class Peppol extends AbstractService
 | 
			
		||||
        'SA' => 'TIN', //South Africa
 | 
			
		||||
        'CY' => 'VAT',
 | 
			
		||||
        'CZ' => 'VAT',
 | 
			
		||||
        'DE' => 'VAT', //tested - requires Payment Means to be defined.
 | 
			
		||||
        'DE' => 'VAT', //tested - Requires Payment Means to be defined.
 | 
			
		||||
        'DK' => 'ERST',
 | 
			
		||||
        'EE' => 'VAT',
 | 
			
		||||
        'ES' => 'VAT', //tested - B2G pending
 | 
			
		||||
        'FI' => 'VAT',
 | 
			
		||||
        'FR' => 'VAT',
 | 
			
		||||
        'FR' => 'VAT', //tested - Need to ensure Siren/Siret routing
 | 
			
		||||
        'GR' => 'VAT',
 | 
			
		||||
        'HR' => 'VAT',
 | 
			
		||||
        'HU' => 'VAT',
 | 
			
		||||
@ -1026,6 +1026,15 @@ class Peppol extends AbstractService
 | 
			
		||||
    private function AT(): self
 | 
			
		||||
    {
 | 
			
		||||
        //special fields for sending to AT:GOV
 | 
			
		||||
                
 | 
			
		||||
        if($this->invoice->client->classification == 'government') {
 | 
			
		||||
            //routing "b" for production "test" for test environment
 | 
			
		||||
            $this->setStorecoveMeta($this->buildRouting('AT:GOV', "test"));
 | 
			
		||||
 | 
			
		||||
            //for government clients this must be set.
 | 
			
		||||
            $this->setCustomerAssignedAccountId(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return $this;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -356,7 +356,7 @@ $x = '<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
*/
 | 
			
		||||
    public function testCreateCHClient()
 | 
			
		||||
    public function XXestCreateCHClient()
 | 
			
		||||
    {
 | 
			
		||||
      
 | 
			
		||||
      Client::unguard();
 | 
			
		||||
@ -616,30 +616,31 @@ $x = '<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function createDEData()
 | 
			
		||||
    private function createATData()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
      $this->routing_id = 290868;
 | 
			
		||||
      $this->routing_id = 293801;
 | 
			
		||||
 | 
			
		||||
      $settings = CompanySettings::defaults();
 | 
			
		||||
      $settings->company_logo = 'https://pdf.invoicing.co/favicon-v2.png';
 | 
			
		||||
      $settings->website = 'www.invoiceninja.de';
 | 
			
		||||
      $settings->website = 'www.invoiceninja.at';
 | 
			
		||||
      $settings->address1 = 'Musterstraße 1';
 | 
			
		||||
      $settings->address2 = 'Etage 2, Büro 3';
 | 
			
		||||
      $settings->city = 'Berlin';
 | 
			
		||||
      $settings->state = 'Berlin';
 | 
			
		||||
      $settings->postal_code = '10115';
 | 
			
		||||
      $settings->phone = '030 1234567';
 | 
			
		||||
      $settings->address2 = 'Stockwerk 2, Büro 3';
 | 
			
		||||
      $settings->city = 'Vienna';
 | 
			
		||||
      $settings->state = 'Vienna';
 | 
			
		||||
      $settings->postal_code = '1010';
 | 
			
		||||
      $settings->phone = '+43 1 23456789';
 | 
			
		||||
      $settings->email = $this->faker->unique()->safeEmail();
 | 
			
		||||
      $settings->country_id = '276'; // Germany's ISO country code
 | 
			
		||||
      $settings->vat_number = 'DE123456789';
 | 
			
		||||
      $settings->id_number = 'HRB 12345';
 | 
			
		||||
      $settings->country_id = '40'; // Austria's ISO country code
 | 
			
		||||
      $settings->vat_number = 'ATU92335648';
 | 
			
		||||
      $settings->id_number = 'FN 123456x';
 | 
			
		||||
      $settings->use_credits_payment = 'always';
 | 
			
		||||
      $settings->timezone_id = '1'; // CET (Central European Time)
 | 
			
		||||
      $settings->entity_send_time = 0;
 | 
			
		||||
      $settings->e_invoice_type = 'PEPPOL';
 | 
			
		||||
      $settings->currency_id = '3';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      $company = Company::factory()->create([
 | 
			
		||||
        'account_id' => $this->account->id,
 | 
			
		||||
        'settings' => $settings,
 | 
			
		||||
@ -662,31 +663,32 @@ $x = '<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
        'company_id' => $company->id,
 | 
			
		||||
        'user_id' => $this->user->id,
 | 
			
		||||
        'name' => 'Beispiel Firma GmbH',
 | 
			
		||||
      'website' => 'https://www.beispiel-firma.de',
 | 
			
		||||
        'website' => 'https://www.beispiel-firma.at',
 | 
			
		||||
        'private_notes' => 'Dies sind private Notizen zum Testkunden.',
 | 
			
		||||
        'balance' => 0,
 | 
			
		||||
        'paid_to_date' => 0,
 | 
			
		||||
      'vat_number' => 'DE654321987',
 | 
			
		||||
      'id_number' => 'HRB 12345', // Typical format for German company registration numbers
 | 
			
		||||
        'vat_number' => 'ATU87654321',
 | 
			
		||||
        'id_number' => 'FN 123456x', // Example format for Austrian company registration numbers
 | 
			
		||||
        'custom_value1' => '2024-07-22 10:00:00',
 | 
			
		||||
        'custom_value2' => 'blau',
 | 
			
		||||
        'custom_value3' => 'musterwort',
 | 
			
		||||
        'custom_value4' => 'test@example.com',
 | 
			
		||||
        'address1' => 'Musterstraße 123',
 | 
			
		||||
        'address2' => '2. Etage, Büro 45',
 | 
			
		||||
      'city' => 'München',
 | 
			
		||||
      'state' => 'Bayern',
 | 
			
		||||
      'postal_code' => '80331',
 | 
			
		||||
      'country_id' => '276', // Germany
 | 
			
		||||
        'city' => 'Vienna',
 | 
			
		||||
        'state' => 'Vienna',
 | 
			
		||||
        'postal_code' => '1010',
 | 
			
		||||
        'country_id' => '40', // Austria
 | 
			
		||||
        'shipping_address1' => 'Musterstraße 123',
 | 
			
		||||
        'shipping_address2' => '2. Etage, Büro 45',
 | 
			
		||||
      'shipping_city' => 'München',
 | 
			
		||||
      'shipping_state' => 'Bayern',
 | 
			
		||||
      'shipping_postal_code' => '80331',
 | 
			
		||||
      'shipping_country_id' => '276', // Germany
 | 
			
		||||
        'shipping_city' => 'Vienna',
 | 
			
		||||
        'shipping_state' => 'Vienna',
 | 
			
		||||
        'shipping_postal_code' => '1010',
 | 
			
		||||
        'shipping_country_id' => '40', // Austria
 | 
			
		||||
        'settings' => ClientSettings::Defaults(),
 | 
			
		||||
        'client_hash' => \Illuminate\Support\Str::random(32),
 | 
			
		||||
        'routing_id' => '',
 | 
			
		||||
        'classification' => 'business',
 | 
			
		||||
      ]);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -695,8 +697,8 @@ $x = '<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
      $item->notes = "Product Description";
 | 
			
		||||
      $item->cost = 10;
 | 
			
		||||
      $item->quantity = 10;
 | 
			
		||||
    $item->tax_rate1 = 19;
 | 
			
		||||
    $item->tax_name1 = 'mwst';
 | 
			
		||||
      $item->tax_rate1 = 20;
 | 
			
		||||
      $item->tax_name1 = 'VAT';
 | 
			
		||||
 | 
			
		||||
      $invoice = Invoice::factory()->create([
 | 
			
		||||
          'company_id' => $company->id,
 | 
			
		||||
@ -720,12 +722,44 @@ $x = '<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
      $invoice = $invoice->calc()->getInvoice();
 | 
			
		||||
      $invoice->service()->markSent()->save();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      return $invoice;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function testFrRules()
 | 
			
		||||
    public function testAtRules()
 | 
			
		||||
    {
 | 
			
		||||
      $this->routing_id = 293801;
 | 
			
		||||
 | 
			
		||||
      $invoice = $this->createATData();
 | 
			
		||||
 | 
			
		||||
      $e_invoice = new \InvoiceNinja\EInvoice\Models\Peppol\Invoice();
 | 
			
		||||
 | 
			
		||||
      $stub = json_decode('{"Invoice":{"Note":"Nooo","PaymentMeans":[{"ID":{"value":"afdasfasdfasdfas"},"PayeeFinancialAccount":{"Name":"PFA-NAME","ID":{"value":"DE89370400440532013000"},"AliasName":"PFA-Alias","AccountTypeCode":{"value":"CHECKING"},"AccountFormatCode":{"value":"IBAN"},"CurrencyCode":{"value":"EUR"},"FinancialInstitutionBranch":{"ID":{"value":"DEUTDEMMXXX"},"Name":"Deutsche Bank"}}}]}}');
 | 
			
		||||
      foreach($stub as $key => $value) {
 | 
			
		||||
          $e_invoice->{$key} = $value;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      $invoice->e_invoice = $e_invoice;
 | 
			
		||||
      $invoice->save();
 | 
			
		||||
 | 
			
		||||
      $this->assertInstanceOf(Invoice::class, $invoice);
 | 
			
		||||
      $this->assertInstanceof(\InvoiceNinja\EInvoice\Models\Peppol\Invoice::class, $e_invoice);
 | 
			
		||||
 | 
			
		||||
      $p = new Peppol($invoice);
 | 
			
		||||
 | 
			
		||||
      $p->run();
 | 
			
		||||
      $xml  = $p->toXml();
 | 
			
		||||
      nlog($xml);
 | 
			
		||||
 | 
			
		||||
      $identifiers = $p->getStorecoveMeta();
 | 
			
		||||
 | 
			
		||||
      $sc = new \App\Services\EDocument\Gateway\Storecove\Storecove();
 | 
			
		||||
      $sc->sendDocument($xml, $this->routing_id, $identifiers);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function RestFrRules()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        $invoice = $this->createFRData();
 | 
			
		||||
@ -756,7 +790,6 @@ $x = '<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function RtestEsRules()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user