-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: inbound email expenses #9042
base: v5-develop
Are you sure you want to change the base?
Feature: inbound email expenses #9042
Conversation
Edited:
|
@turbo124 please check the handling of changing the name of a mailbox and give me feedback on this. I descided to not use a regex aproach and instead work with checks, if the provided string have a specific ending. Therefore the frontend can create a more easy combination of choosing the ending (dropdown) and let the user descide, which text he/she wants to use for the mailbox (text-input-field). app/Http/ValidationRules/Company/ValidExpenseMailbox.php |
@@ -55,6 +56,8 @@ public function rules() | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Safe to never check the expenes mailbox in the Store Request as this is configured afterwards.... so only need a check on update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turbo124 I guess I missed this one :(
Just removing all the checks for the expense_mailbox?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turbo124 should this not be keep in place, to suppor this, when using api create company?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulwer review complete!
…inja into feature-inbound-email-expenses
// @turbo124 TODO: how to check for services.mailgun.webhook_signing_key on company level, when custom credentials are defined | ||
// TODO: validation for client mail credentials by recipient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would imagine here we would need a company.settings.variable to store this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please explain, what would you like to store here?
edit: sorry i missed my own question. I will create a setting entry for it. do you have any name suggestions or further things to considder?
return response()->json(['message' => 'Blocked.'], 403); | ||
} | ||
|
||
$company = MultiDB::findAndSetDbByExpenseMailbox($input["To"]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm on this one, this particular field would then also require to be unique in the system, ie company.expense_mailbox
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, thats right :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be resolved or are there any further questions on this topic?
'gocardless' => env('GOCARDLESS_KEYS', ''), | ||
'square' => env('SQUARE_KEYS', ''), | ||
'eway' => env('EWAY_KEYS', ''), | ||
'paytrace' => env('PAYTRACE_KEYS', ''), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this got removed accidentally, could you add back please?
'mollie', env('MOLLIE_KEYS',''),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh sorry, it is down below on line 102
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i saw, that you have 'mollie', env('MOLLIE_KEYS','') onstead of 'mollie' => env('MOLLIE_KEYS','') in your repo. which one is the right one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments and issues to resolve!
…inja into feature-inbound-email-expenses
@paulwer I'm planning to finish the e-invoice import by end of the week. So you could integrate by calling |
@LarsK1 what happ3ns, when the document has no Zugferd Signature? Any sugestions? Error catching or predetermining if the data required is available? |
@paulwer The easiest way, would be to first check the file ending (.pdf, .xml), then, if it's a valid ending to pass it over to the ZugferdEDocument class, which validates the file or returns an error, if the file is not valid. For the long term, we will have to create a detection library to determine, which e-invoicing standard the provided document is. |
I would raise this exception: https://github.com/horstoeko/zugferd/blob/18de152080610d6d77eda97e375bfb8ec03ef4f8/src/ZugferdDocumentReader.php#L230 |
@paulwer the first case wouldn't matter. Since the class will ignore duplicate documents (by vendor, invoice number, sum and date matching) |
@turbo124 @LarsK1 therefore It will stay like currently, that all docuements will be imported as distinct expense. and only those cases which can be matched by Zugferd will result in reuse. @LarsK1 my solution does saves the email, as well as the document to the expense. Is it possible to pass the email.html document also to your sevice to enable saving this data in your expenses also. / or maybe return the expense, so I can save this document into it |
event(new ExpenseWasCreated($expense, $expense->company, Ninja::eventVars(null))); // @turbo124 please check, I copied from API-Controller | ||
event('eloquent.created: App\Models\Expense', $expense); // @turbo124 please check, I copied from API-Controller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turbo124 when creating an expense through the api the following events are thrown:
event(new ExpenseWasCreated($expense, $expense->company, Ninja::eventVars(null))); // @turbo124 please check, I copied from API-Controller
event('eloquent.created: App\Models\Expense', $expense); // @turbo124 please check, I copied from API-Controller
should they also be present here?
@LarsK1 regarding multiple documents within one email. Do you think this should be wanted behavior, because of edge case? Or do you have any other idea :) |
@paulwer I thought about your idea regarding AGB. Most system have an "inbox" folder, where one can filter the ingested documents. Otherwise, we should have the ability to create "template" expenses, which can be deleted without any remains or accepted and then converted to a "full" expense. |
this PR is a draft for importing inbound emails as expenses.
I would like to use this draft to may ask some questions and to develop this feature.
waiting for: Feature: Brevo Email Provider #9053
Any more providers to cover?
Status (Tests):
Dev Environment
Webhook Relay on Localhost
I have used webhook relay to simulate a internet contactable url to test the webhook behavior with each provider.
Documentation
Company Configuration
If you are starting with the IngresEngine, you should have to take a look at some major points. First of all the mailbox recieving the email has to be allowed, which can be configured at the company level. The IngresEngine can denie incomming emails, when the configuration and data related to your vendors allows it to.
Vendor Matching
Incomming emails are beeing attempted to match against a vendor by checking the vendor contact emails.
SetUp Inbound Providers
SetUp Mailgun
To ensure delivery, you have to configure all used mailgun regions with a recieving configuration using store & notify.
3a. Go to Recieving Section and click on "Create Route"
3b. Create your route by selecting your mailbox configured in invoiceninja and add notify endpoint /api/v1/mailgun_inbound_webhook
SetUp Brevo
To ensure delivery you have to configure brevo inbound parsing according to: https://developers.brevo.com/docs/inbound-parse-webhooks
SetUp Postmark
To ensure delivery you have to configure brevo inbound parsing according to: https://developers.brevo.com/docs/inbound-parse-webhooks
// TODO
SetUp with Own MailServer
If you want to use your own mailbox, you have to eigher redirect the mail to a mailbox of one of the providers above or use a provider for inbound directly.
We recommend to use one of these providers hosted on a subdomain f.ex. invoicing.xxx.com directly or to use the auto-generated mailbox of postmark when you are using redirect.