Skip to content

Commit

Permalink
Update orbis-moneybird.php
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed May 2, 2024
1 parent 02d470a commit 0731240
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion orbis-moneybird.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,36 @@ function ( $sales_invoice ) {
return;
}

/**
* Invoicing moment.
*
* @link https://www.credit-care.com/blogs/wanneer-factureren/
*/
$billing_strategy = 'progress';

if ( str_contains( $item->project_name, 'Online marketing' ) ) {
$billing_strategy = 'afterwards';
}

if ( str_contains( $item->project_name, 'Scrum' ) ) {
$billing_strategy = 'afterwards';
}

if ( str_contains( $item->project_name, 'Strippenkaart' ) ) {
$billing_strategy = 'in_advance';
}

$project_references = [];

$project_references[] = $project_reference = '#project_' . $item->project_id;

$project_billable_time = $item->project_billable_time;
$project_billed_time = $item->project_billed_time;
$project_invoice_time = $project_billable_time - $project_billed_time;
$project_invoice_time = $project_billable_time;

if ( 'progress' === $billing_strategy ) {
$project_invoice_time = min( $item->project_timesheet_time, $item->project_billable_time ) - $project_billed_time;
}

$references = [];

Expand All @@ -220,6 +243,15 @@ function ( $sales_invoice ) {
}

$references[] = $item->project_name;

if ( $project_invoice_time < $project_billable_time ) {
$references[] = \sprintf(
'%s / %s uren',
orbis_time( min( $item->project_timesheet_time, $item->project_billable_time ) ),
orbis_time( $item->project_billable_time )
);
}

$references[] = \get_post_meta( $item->project_post_id, '_orbis_invoice_reference', true );

if ( null !== $sales_invoice->reference && '' !== $sales_invoice->reference ) {
Expand Down

0 comments on commit 0731240

Please sign in to comment.