Skip to content
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

BTHAB-3: Merging workstream branch to master #1005

Merged
merged 199 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
199 commits
Select commit Hold shift + click to select a range
a1603eb
BTHAB-37: Add direct link to CiviCase Instances
olayiwola-compucorp Feb 1, 2023
b783b66
BTHAB-45: Show case instances without searching
olayiwola-compucorp Feb 8, 2023
7860cfb
BTHAB-38: Regenerate civix file
olayiwola-compucorp Feb 2, 2023
3a21a79
BTHAB-38: Apply PHPCS lints and ignore basetestcases
olayiwola-compucorp Feb 2, 2023
3cba90c
BTHAB-38: Manage optiongroup used to store case instance features
olayiwola-compucorp Feb 2, 2023
15f5a71
BTHAB-38: Create new entity to link case category with features
olayiwola-compucorp Feb 6, 2023
00644b1
BTHAB-38: Allow users to en/disable feature for a case category
olayiwola-compucorp Feb 6, 2023
7a821f4
BTHAB-18: Add upgrader to create quotation status option group
olayiwola-compucorp Feb 9, 2023
40f65e2
BTHAB-18: Add new entity case_sales_order to store quotations
olayiwola-compucorp Feb 9, 2023
5702ce1
BTHAB-18: Add new entity to store quotation line items
olayiwola-compucorp Feb 9, 2023
cbd85f8
BTHAB-18: Prefix table mame with extension name
olayiwola-compucorp Feb 13, 2023
6eff805
BTHAB-20: Use features option_value value instead of ID
olayiwola-compucorp Feb 15, 2023
c4cd3b0
BTHAB-20: Move shared function to abstract class
olayiwola-compucorp Feb 16, 2023
8da64e1
BTHAB-20: Display enabled features menu
olayiwola-compucorp Feb 16, 2023
300cad1
BRHAB-20: Avoid creating sales_order table if exist
olayiwola-compucorp Feb 20, 2023
39a4a9e
BTHAB-20: Add base angular module for case features
olayiwola-compucorp Feb 16, 2023
8f65d44
BTHAB-20: Display quotations that do not belong to any case
olayiwola-compucorp Feb 16, 2023
6c28918
BTHAB-20: Prefix angular resources with extension name
olayiwola-compucorp Feb 17, 2023
68aebb6
BTHAB-20: Add default entity links
olayiwola-compucorp Feb 17, 2023
5e4434b
BTHAB-23: Refactor method to retrieve feature case instance
olayiwola-compucorp Feb 27, 2023
85ab7a8
BTHAB-23: Expose extra options required for quotations create page
olayiwola-compucorp Feb 27, 2023
b0a53fa
BTHAB-23: Add a new directive to redirect user to previous page
olayiwola-compucorp Feb 27, 2023
ca69f0b
BTHAB-23: Add Util class to manage currency table
olayiwola-compucorp Feb 27, 2023
3a9730c
BTHAB-23: Add endpoint to upsert sales order
olayiwola-compucorp Feb 27, 2023
13d911b
BTHAB-23: Add endpoint to compute sales order total amount
olayiwola-compucorp Feb 27, 2023
d0074ed
BTHAB-23: Return case_type_category from case getdetails API action
olayiwola-compucorp Feb 27, 2023
6008a3d
BTHAB-23: Add controller and page to create new sales order
olayiwola-compucorp Feb 27, 2023
49acca0
BTHAB-23: Apply PHPCS linter fix
olayiwola-compucorp Feb 28, 2023
a88d974
BTHAB-78: Add test to custom sales order API actions
olayiwola-compucorp Mar 1, 2023
91b3e5c
BTHAB-78: ComputeTotalAction should support empty line items
olayiwola-compucorp Mar 2, 2023
5d434db
BTHAB-21: Add filter to quotation list view
olayiwola-compucorp Feb 22, 2023
aad803f
BTHAB-24: Add method to get case dashboard link
olayiwola-compucorp Mar 2, 2023
45ebb40
BTHAB-24: Add page to view single quotation
olayiwola-compucorp Mar 2, 2023
5552bf2
BTHAB-24: Use caseutil to direct user to case dashboard
olayiwola-compucorp Mar 3, 2023
dfb68c9
BTHAB-29: Refactor shared service into own folder
olayiwola-compucorp Mar 3, 2023
94a36f6
BTHAB-29: Filter quotations by case id
olayiwola-compucorp Mar 3, 2023
40fb3a5
BTHAB-29: Display quotations belonging to a case on case dashboard
olayiwola-compucorp Mar 3, 2023
b1619a7
BTHAB-28: Prefill case/opportunity field for new quotations
olayiwola-compucorp Mar 6, 2023
f31ba23
BTHAB-26: Allow delete of quotations
olayiwola-compucorp Mar 7, 2023
995e48b
BTHAB-25: Allow edit of quotations
olayiwola-compucorp Mar 7, 2023
253c8b4
BTHAB-25: Set quotations list as default page
olayiwola-compucorp Mar 7, 2023
7b56cf0
BTHAB-46: Allow user to apply bulk discount to quotations
olayiwola-compucorp Mar 9, 2023
6180ad2
BTHAB-44: Add quotations field to contribution settings
olayiwola-compucorp Mar 8, 2023
af646cb
BTHAB-47: Remove title from quotation view
olayiwola-compucorp Mar 13, 2023
960f588
BTHAB-47: Resolve prospect contact tab not loading
olayiwola-compucorp Mar 13, 2023
3e3cfeb
BTHAB-47: Create view to list contact quotations
olayiwola-compucorp Mar 13, 2023
ad42e0e
BTHAB-47: Display contact quotations on contact tab
olayiwola-compucorp Mar 13, 2023
cd48c8a
BTHAB-21: Allow quotation to be filtered by description
olayiwola-compucorp Mar 27, 2023
35dc2d0
BTHAB-43: Create Sales Order template workflow
olayiwola-compucorp Mar 22, 2023
ae4a0bb
BTHAB-43: Create salesorder invoice template on update/install
olayiwola-compucorp Mar 22, 2023
02b625d
BTHAB-43: Allow users to use sales_order fields as tokens
olayiwola-compucorp Mar 22, 2023
d3370d9
BTHAB-43: Fix quotation notes form hook
olayiwola-compucorp Mar 22, 2023
a5dff6a
BTHAB-43: Allow user to send or download salesorder Invoice
olayiwola-compucorp Mar 22, 2023
2371e9e
BTHAB-43: Prevents error when token is being resolved for unittest
olayiwola-compucorp Mar 22, 2023
91094a0
BTHAB-43: Add test to ensure invoice download/mail works as expected
olayiwola-compucorp Mar 22, 2023
bc1b0fd
BTHAB-43: Add salesorder invoice Download and Email menu
olayiwola-compucorp Mar 22, 2023
f83d97c
BTHAB-25: Allow user to save quotation edit with default date
olayiwola-compucorp Mar 28, 2023
47449d0
BTHAB-25: Correct message shown to user after succesful update of quo…
olayiwola-compucorp Mar 28, 2023
7456d0b
BTHAB-33: Add new case sales order contribution entity
olayiwola-compucorp Mar 14, 2023
dfd3dfe
BTHAB-33: Add menu item for creating sales order contribution
olayiwola-compucorp Mar 27, 2023
5d416ae
BTHAB-33: Add page for creating sales order contribution
olayiwola-compucorp Mar 27, 2023
6f68374
BTHAB-34: Add popup screen to create bulk sales order contribution
olayiwola-compucorp Mar 30, 2023
934992e
BTHAB-34: Add Service and API action to create sales order contribution
olayiwola-compucorp Mar 30, 2023
865ff57
BTHAB-34: Add test to ensure the right contribution value is created …
olayiwola-compucorp Mar 30, 2023
27e800d
BTHAB-34: Only one client per case sales order
olayiwola-compucorp Mar 30, 2023
eac8cbf
BTHAB-34: Create Bulk contributions in batches
olayiwola-compucorp Apr 3, 2023
3964d4c
BTHAB-34: Refactor CreateAction API
olayiwola-compucorp Apr 3, 2023
ee708c8
BTHAB-34: Refactor CaseSalesOrderContribution service
olayiwola-compucorp Apr 3, 2023
4f6225e
BTHAB-34: pass ids to salesorder create action API as salesOrderIds
olayiwola-compucorp Apr 3, 2023
a480f08
BTHAB-34: Add more test case scenarios to the salesOrder lin item gen…
olayiwola-compucorp Apr 3, 2023
e70d813
BTHAB-34: Refactor method name and also encapsulate non public methods
olayiwola-compucorp Apr 4, 2023
a1a1ba6
BTHAB-34: Only rollback transaction for individual sales order contri…
olayiwola-compucorp Apr 4, 2023
bcd7c16
BTHAB-48: Add page to list quotation invoices
olayiwola-compucorp Apr 3, 2023
b7306cd
BTHAB-48: Display invoice on civicase instance tab when enabled
olayiwola-compucorp Apr 3, 2023
ac0b8f1
BTHAB-48: Add Invoice tab to case instance dashboard
olayiwola-compucorp Apr 3, 2023
3b5fbaf
BTHAB-33: Initiliaze new Contibution page with sales order line items
olayiwola-compucorp Apr 5, 2023
6c0f4b3
BTHAB-33: Link sales order with contribution and update sales order
olayiwola-compucorp Apr 5, 2023
cad67cc
BTHAB-101: Fix browser navigating to case dashboard on datepicker day…
olayiwola-compucorp Apr 14, 2023
7227a4d
BTHAB-101: Reduce field field sizes and reduce show filter button toggle
olayiwola-compucorp Apr 14, 2023
2c6f53f
BTHAB-101: Allow user to clear all filter fileds
olayiwola-compucorp Apr 14, 2023
03b31b0
BTHAB-102: Allow creating contact on the client field
olayiwola-compucorp Apr 18, 2023
197eb16
BRHAB-102: Update financial type when product is selected
olayiwola-compucorp Apr 19, 2023
803ffae
BTHAB-102: Increase element sizes and update validation messages
olayiwola-compucorp Apr 19, 2023
d8e0c28
BTHAB-102: Limit sales order owner field to a contact
olayiwola-compucorp Apr 19, 2023
653161e
BTHAB-102: Clear product name when product ID is empty
olayiwola-compucorp Apr 19, 2023
8164cd5
BTHAB-113: Display terms on invoice only if tax and invoicing is enabled
olayiwola-compucorp Apr 19, 2023
b9619fa
BTHAB-113: Prevent sales_order tokens from being assigned null vallues
olayiwola-compucorp Apr 19, 2023
a0e5835
BTHAB-105: Remove table borders on quotations view
olayiwola-compucorp Apr 17, 2023
8012afb
BTHAB-105: Link contact name to dashbard on quotation view
olayiwola-compucorp Apr 17, 2023
e07ad3c
BTHAB-105: Link owner name to owner contact dashboard
olayiwola-compucorp Apr 20, 2023
4649268
BTHAB-119: Include tax rate in discount line item
olayiwola-compucorp Apr 20, 2023
50dc6bf
BTHAB-119: Ensure input is of same type before comparing
olayiwola-compucorp Apr 20, 2023
a19ccc3
BTHAB-119: Set sales order bulk contribution status to pending
olayiwola-compucorp Apr 20, 2023
f464ba7
BTHAB-119: Display correct lineitem total for previous contribution
olayiwola-compucorp Apr 20, 2023
4f6c7ae
BTHAB-129: Ensure quotation financial type can be updated
olayiwola-compucorp Apr 25, 2023
c2dd982
BTHAB-38: Remove pledges from supported case instance features
olayiwola-compucorp Apr 25, 2023
acc7c9a
BTHAB-109: Close tab if there's no previous page to navigate to
olayiwola-compucorp Apr 25, 2023
7a98c4f
BTHAB-109: Prevent financial_type and product input field from hiding…
olayiwola-compucorp Apr 25, 2023
0847597
BTHAB-109: Space date range input fields
olayiwola-compucorp Apr 25, 2023
da9df7b
BTHAB-124: Redirect back to previous page on quotation edit
olayiwola-compucorp Apr 27, 2023
9798c2a
BTHAB-124: Keep submit button disabled when save is successful
olayiwola-compucorp Apr 27, 2023
a5d2588
BTHAB-124: Fix typo in Quotation view page
olayiwola-compucorp Apr 27, 2023
d475019
BTHAB-130: Prevent quantity field from throwing error due to excess d…
olayiwola-compucorp Apr 26, 2023
74501a2
BTHAB-130: Prevent incorrect quotation contribution total
olayiwola-compucorp Apr 27, 2023
798bda4
BTHAB-126: Display contact Quotation tab if Quotation feature is enab…
olayiwola-compucorp May 1, 2023
d7fe0ea
BTHAB-155: Update quotation contribution status field label
olayiwola-compucorp May 1, 2023
0305ef6
BTHAB-155: Set status field to current quotaion status
olayiwola-compucorp May 1, 2023
5764f76
BTHAB-155: Set default value for status and fianlcialtype from first …
olayiwola-compucorp May 1, 2023
bb85565
BTHAB-155: Format date on quotation view
olayiwola-compucorp May 1, 2023
f4b1cb0
BTHAB-43: Update Quotation invoice template
olayiwola-compucorp May 2, 2023
5d89771
BTHAB-43: Specify default tepmlate format and set domain locatoin field
olayiwola-compucorp May 2, 2023
4db63b2
BTHAB-153: Add Helper text to quotation notes field
olayiwola-compucorp Apr 29, 2023
46beca0
BTHAB-152: Display only essesntial bulk actions
olayiwola-compucorp Apr 29, 2023
d5b9f8f
BTHAB-152: Recalculate lineitem total before saving
olayiwola-compucorp Apr 29, 2023
29216ae
BTHAB-147: Format displayed total in selected currency format
olayiwola-compucorp Apr 29, 2023
0d03a28
BTHAB-147: Add help text to notes and descrition field
olayiwola-compucorp Apr 29, 2023
625c898
BTHAB-147: Use case client as default quotation client
olayiwola-compucorp Apr 29, 2023
9d11ea0
BTHAB-128: Allow creation of single contribution without restricing t…
olayiwola-compucorp Apr 27, 2023
d3db578
BTHAB-128: Use numbers of bulk contribution created from API result
olayiwola-compucorp Apr 27, 2023
ee6000f
BTHAB-128: Ensure Quotation Contribution amount will be greater than 0
olayiwola-compucorp Apr 27, 2023
674c727
BTHAB-128: Allow creation of bulk contribution without restricing the…
olayiwola-compucorp Apr 28, 2023
4966b72
BTHAB-152: Use Quotation as case_sales_order title
olayiwola-compucorp May 3, 2023
bbec84d
BTHAB-152: Ensure logo_image on quotaion invoice is responsive
olayiwola-compucorp May 3, 2023
19e83cb
BTHAB-152: Add domain name to quotation invoice
olayiwola-compucorp May 3, 2023
805bbe7
BTHAB-119: Round off quotation lineitem money fields to 2 decimal places
olayiwola-compucorp May 3, 2023
f877966
BTHAB-119: Prefix discount action link with percent icon
olayiwola-compucorp May 4, 2023
59f093f
BTHAB-146: Move quotation create screen action button to footer of panel
olayiwola-compucorp May 12, 2023
bf89e2f
BTHAB-146: Update sales_order entity title
olayiwola-compucorp May 12, 2023
572f0dd
BTHAB-146: Hide remain_balance radio if theres no left over balance
olayiwola-compucorp May 12, 2023
0a59c36
BTHAB-146: Report numbers of contribution not created to user
olayiwola-compucorp May 12, 2023
69dac6b
BTHAB-146: Allow user to add/remove lineitem on quotation contributio…
olayiwola-compucorp May 12, 2023
01edc81
BTHAB-106: Contribution Create action should support financial type I…
olayiwola-compucorp May 19, 2023
ff99ed9
BTHAB-106: Update quotation edit page title
olayiwola-compucorp May 19, 2023
24beb1e
BTHAB-106: Set Owner field to current quotation owner
olayiwola-compucorp May 19, 2023
24dbc95
BTHAB-106: Allow quotation description to be multiline
olayiwola-compucorp May 19, 2023
a675023
BTHAB-170: Ensure each contribution create is persisted
olayiwola-compucorp May 22, 2023
5ae6842
BTHAB-170: Prevent previous line_item from colliding with new line_item
olayiwola-compucorp May 22, 2023
10b8481
BTHAB-170: Add test to enusre bulk contribtuion create action works a…
olayiwola-compucorp May 23, 2023
bdcfa4f
BTHAB-106: Prevent setting owner to current_user on edit screen
olayiwola-compucorp May 23, 2023
34d63c7
BTHAB-200: Display only relevant quotations for the viewed contact
olayiwola-compucorp Jul 13, 2023
e53cbd9
BTHAB-200: Refresh Case order table post delete
olayiwola-compucorp Jul 17, 2023
2c31699
BTHAB-3: Export quotation saved search
olayiwola-compucorp May 16, 2023
0d779da
BTHAB-181: Add send invoice by email action
erawat Aug 23, 2023
6b83336
BTHAB-181: Require afform extension
erawat Aug 23, 2023
d9ac17d
BTHAB-178: Allow creating custom field for membership type
erawat Aug 25, 2023
cf41dcb
BTHAB-178: Add Product Discounts custom field that extend Membership …
erawat Aug 25, 2023
ab93555
BTHAB-204: Apply contact membership type product discount to sale ord…
erawat Sep 1, 2023
9158eec
BTHAB-180: Only perform delete if id line item is not empty
erawat Sep 11, 2023
980a6b6
BTHAB-184: Add Contribution opportunity details custom group
olayiwola-compucorp Sep 13, 2023
46d0d51
BTHAB-184: Convert oportunity deatils field to entity reference fields
olayiwola-compucorp Sep 13, 2023
c616df3
BTHAB-184: Add case sales order getlist endpoint
olayiwola-compucorp Sep 13, 2023
d183789
BTHAB-184: Display linked invoices using opportunity details custom f…
olayiwola-compucorp Sep 13, 2023
9179b69
BTHAB-184: Link sales order with contribution using opoortunity detai…
olayiwola-compucorp Sep 13, 2023
fa5a163
BTHAB-184: Allow CIviCRM to manage the custom group
olayiwola-compucorp Sep 18, 2023
325d571
BTHAB-184: Convert opportunity details field to entity ref on custom …
olayiwola-compucorp Sep 18, 2023
628fa96
BTHAB-184: Remove CaseSalesOrderContribution entity
olayiwola-compucorp Sep 19, 2023
0caf5ce
BTHAB-184: Include ID in casesalesorder getlist label
olayiwola-compucorp Sep 19, 2023
b5f5816
BTHAB-185: Remove unnecessary upgrader
erawat Sep 20, 2023
5e67e53
BTHAB-185: Upgrade civix from version 22.05.2 to 23.02.1
erawat Sep 20, 2023
1fc2974
BTHAB-185: Add new entities to case sales order
erawat Sep 20, 2023
6d61c24
BTHAB-185: Add option groups/values for invoicing and payment statuses
erawat Sep 20, 2023
6f9f9d6
BTHAB-185: Add CaseSaleOrderContribution service
erawat Sep 20, 2023
6196280
BTHAB-185: Add compu action for invoiced and paid amounts
erawat Sep 20, 2023
37fd572
BTHAB-185: Calculate payments/invoicing statuses when creating a cont…
erawat Sep 20, 2023
ff83a6d
BTHAB-185: Calculate payments/invoicing statuses when creating/updati…
erawat Sep 20, 2023
2397e37
BTHAB-185: Display invoicing/payment amounts and statuses on the quot…
erawat Sep 20, 2023
6d54564
BTHAB-185: Include invoicing/payment statuses the view quotations scr…
erawat Sep 20, 2023
b9c5c4d
BTHAB-185: Update case sales orcer invoicing/payment statuses when cr…
erawat Sep 20, 2023
448f9d5
BTHAB-185: Ignore mixin
erawat Sep 20, 2023
afffe53
BTHAB-185: Mock invoicing status, payment status
erawat Sep 21, 2023
159825b
BTHAB-185: Return if sale order is empty
erawat Sep 21, 2023
5d803e8
BTHAB-182: Attach quotation invoice to contribution mail
olayiwola-compucorp Sep 12, 2023
7534b0b
BTHAB-182: Use Invoice render service
olayiwola-compucorp Sep 21, 2023
23f17dd
BTHAB-186: Rename service class
erawat Sep 21, 2023
43e4548
BTHAB-186: Add case opportunity custom fields
erawat Sep 22, 2023
29c02fc
BTHAB-186: Update case opportunity details
erawat Sep 22, 2023
b454abf
BTHAB-185: Update statuses on contribution deletion
erawat Sep 22, 2023
e4f2ba5
BTHAB-206: Fix failing upgrader
olayiwola-compucorp Sep 25, 2023
b962ce8
BTHAB-206: Set payment and invoice status for new sales order
olayiwola-compucorp Sep 25, 2023
3138d5a
BTHAB-206: Add searchtask to send bulk invoice with quotation
olayiwola-compucorp Sep 25, 2023
daf29c6
BTHAB-206: Hide PDF selector and suport invoicehelper customization
olayiwola-compucorp Sep 26, 2023
4ac5d72
BTHAB-145: Add button to create invoice
olayiwola-compucorp Sep 26, 2023
adc9243
BTHAB-145: Refactor how client_id is populated from case
olayiwola-compucorp Sep 27, 2023
48d22e4
CIWEMB-514: Fix not able to create non-salesorder contribution
olayiwola-compucorp Sep 29, 2023
e8dd0b0
CIWEMB-525: Ensure hook will only run where expected
olayiwola-compucorp Oct 6, 2023
ca4ee2c
BTHAB-202: Ensure the product price doesnt exceed the max price
olayiwola-compucorp Oct 10, 2023
4d43982
BTHAB-257: Fetch discount information for case client
olayiwola-compucorp Oct 16, 2023
7e62cab
BTHAB-257: Ensure quotation is attached to mail by default
olayiwola-compucorp Oct 17, 2023
98e811d
BTHAB-271: Fix invoice and payment status bugs for quotations
shahrukh-compuco Oct 23, 2023
630ad2b
BTHAB-183: Add deposit paid status for quotations
shahrukh-compuco Oct 30, 2023
0ca8697
BTHAB-253: Add validation for discount amount field
shahrukh-compuco Nov 20, 2023
24e6818
BTHAB-248: Remove unnecessary API 4 backend permission checks
olayiwola-compucorp Nov 30, 2023
058b014
BTHAB-158: Fix invoice list issues
Jan 28, 2024
036e7c8
BTHAB-257: Only display discount alert if discount is applied
olayiwola-compucorp Oct 18, 2023
a778855
BTHAB-257: Redirect quotation invoice receipt task to quotation list
olayiwola-compucorp Oct 18, 2023
0f1da16
BTHAB-257: Validate product max price on edit
olayiwola-compucorp Oct 18, 2023
0414fda
BTHAB-257: Ensure the PDF option is always hidden in send invoice screen
olayiwola-compucorp Oct 19, 2023
b3453d4
BTHAB-257: Allow user to access quotation from Webform
olayiwola-compucorp Oct 20, 2023
1b486f5
BTHAB-3: Fix failing linters
olayiwola-compucorp Feb 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CRM/Civicase/BAO/CaseCategoryFeatures.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* CaseCategoryFeatures BAO.
*/
class CRM_Civicase_BAO_CaseCategoryFeatures extends CRM_Civicase_DAO_CaseCategoryFeatures {

/**
* Create a new CaseCategoryFeatures based on array-data.
*
* @param array $params
* Key-value pairs.
*
* @return CRM_Civicase_DAO_CaseCategoryFeatures|null
* Case category feature.
*/
public static function create(array $params) {
$className = 'CRM_Civicase_DAO_CaseCategoryFeatures';
$entityName = 'CaseCategoryFeatures';
$hook = empty($params['id']) ? 'create' : 'edit';

CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $className();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);

return $instance;
}

}
90 changes: 90 additions & 0 deletions CRM/Civicase/BAO/CaseSalesOrder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

/**
* CaseSalesOrder BAO.
*/
class CRM_Civicase_BAO_CaseSalesOrder extends CRM_Civicase_DAO_CaseSalesOrder {

/**
* Create a new CaseSalesOrder based on array-data.
*
* @param array $params
* Key-value pairs.
*
* @return CRM_Civicase_DAO_CaseSalesOrder|null
* Case sales order instance.
*/
public static function create(array $params) {
$className = 'CRM_Civicase_DAO_CaseSalesOrder';
$entityName = 'CaseSalesOrder';
$hook = empty($params['id']) ? 'create' : 'edit';

CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $className();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);

return $instance;
}

/**
* Computes the sales order line item total.
*
* @param array $items
* Array of sales order line items.
*
* @return array
* ['totalAfterTax' => <value>, 'totalBeforeTax' => <value>]
*/
public static function computeTotal(array $items) {
$totalBeforeTax = round(array_reduce($items, fn ($a, $b) => $a + self::getSubTotal($b), 0), 2);
$totalAfterTax = round(array_reduce($items,
fn ($a, $b) => $a + (($b['tax_rate'] * self::getSubTotal($b)) / 100),
0
) + $totalBeforeTax, 2);

return [
'taxRates' => self::computeTaxRates($items),
'totalAfterTax' => $totalAfterTax,
'totalBeforeTax' => $totalBeforeTax,
];
}

/**
* Computes the sub total of a single line item.
*
* @param array $item
* Single sales order line item.
*
* @return int
* The line item subtotal.
*/
public static function getSubTotal(array $item) {
return $item['unit_price'] * $item['quantity'] * ((100 - ($item['discounted_percentage'] ?? 0)) / 100) ?? 0;
}

/**
* Computes the tax rates of each line item.
*
* @param array $items
* Single sales order line item.
*
* @return array
* Returned sorted array of line items tax rates.
*/
public static function computeTaxRates(array $items) {
$items = array_filter($items, fn ($a) => $a['tax_rate'] > 0);
usort($items, fn ($a, $b) => $a['tax_rate'] <=> $b['tax_rate']);

return array_map(
fn ($a) =>
[
'rate' => round($a['tax_rate'], 2),
'value' => round(($a['tax_rate'] * self::getSubTotal($a)) / 100, 2),
],
$items
);
}

}
31 changes: 31 additions & 0 deletions CRM/Civicase/BAO/CaseSalesOrderLine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* CaseSalesOrderLine BAO.
*/
class CRM_Civicase_BAO_CaseSalesOrderLine extends CRM_Civicase_DAO_CaseSalesOrderLine {

/**
* Create a new CaseSalesOrderLine based on array-data.
*
* @param array $params
* Key-value pairs.
*
* @return CRM_Civicase_DAO_CaseSalesOrderLine|null
* CRM_Civicase_DAO_CaseSalesOrderLine
*/
public static function create(array $params) {
$className = 'CRM_Civicase_DAO_CaseSalesOrderLine';
$entityName = 'CaseSalesOrderLine';
$hook = empty($params['id']) ? 'create' : 'edit';

CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
$instance = new $className();
$instance->copyValues($params);
$instance->save();
CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);

return $instance;
}

}
208 changes: 208 additions & 0 deletions CRM/Civicase/DAO/CaseCategoryFeatures.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<?php

/**
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*
* Generated from uk.co.compucorp.civicase/xml/schema/CRM/Civicase/CaseCategoryFeatures.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:480eebcac1f7ce6976ee6dd5a87112e8)
*/
use CRM_Civicase_ExtensionUtil as E;

/**
* Database access object for the CaseCategoryFeatures entity.
*/
class CRM_Civicase_DAO_CaseCategoryFeatures extends CRM_Core_DAO {
const EXT = E::LONG_NAME;
const TABLE_ADDED = '';

/**
* Static instance to hold the table name.
*
* @var string
*/
public static $_tableName = 'civicrm_case_category_features';

/**
* Should CiviCRM log any modifications to this table in the civicrm_log table.
*
* @var bool
*/
public static $_log = TRUE;

/**
* Unique CaseCategoryFeatures ID
*
* @var int|string|null
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $id;

/**
* One of the values of the case_type_categories option group
*
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $category_id;

/**
* One of the values of the case_type_category_features option group
*
* @var int|string
* (SQL type: int unsigned)
* Note that values will be retrieved from the database as a string.
*/
public $feature_id;

/**
* Class constructor.
*/
public function __construct() {
$this->__table = 'civicrm_case_category_features';
parent::__construct();
}

/**
* Returns localized title of this entity.
*
* @param bool $plural
* Whether to return the plural version of the title.
*/
public static function getEntityTitle($plural = FALSE) {
return $plural ? E::ts('Case Category Featureses') : E::ts('Case Category Features');
}

/**
* Returns all the column names of this table
*
* @return array
*/
public static function &fields() {
if (!isset(Civi::$statics[__CLASS__]['fields'])) {
Civi::$statics[__CLASS__]['fields'] = [
'id' => [
'name' => 'id',
'type' => CRM_Utils_Type::T_INT,
'description' => E::ts('Unique CaseCategoryFeatures ID'),
'required' => TRUE,
'where' => 'civicrm_case_category_features.id',
'table_name' => 'civicrm_case_category_features',
'entity' => 'CaseCategoryFeatures',
'bao' => 'CRM_Civicase_DAO_CaseCategoryFeatures',
'localizable' => 0,
'html' => [
'type' => 'Number',
],
'readonly' => TRUE,
'add' => NULL,
],
'category_id' => [
'name' => 'category_id',
'type' => CRM_Utils_Type::T_INT,
'description' => E::ts('One of the values of the case_type_categories option group'),
'required' => TRUE,
'where' => 'civicrm_case_category_features.category_id',
'table_name' => 'civicrm_case_category_features',
'entity' => 'CaseCategoryFeatures',
'bao' => 'CRM_Civicase_DAO_CaseCategoryFeatures',
'localizable' => 0,
'pseudoconstant' => [
'optionGroupName' => 'case_type_categories',
'optionEditPath' => 'civicrm/admin/options/case_type_categories',
],
'add' => NULL,
],
'feature_id' => [
'name' => 'feature_id',
'type' => CRM_Utils_Type::T_INT,
'description' => E::ts('One of the values of the case_type_category_features option group'),
'required' => TRUE,
'where' => 'civicrm_case_category_features.feature_id',
'table_name' => 'civicrm_case_category_features',
'entity' => 'CaseCategoryFeatures',
'bao' => 'CRM_Civicase_DAO_CaseCategoryFeatures',
'localizable' => 0,
'pseudoconstant' => [
'optionGroupName' => 'case_type_category_features',
'optionEditPath' => 'civicrm/admin/options/case_type_category_features',
],
'add' => NULL,
],
];
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
}
return Civi::$statics[__CLASS__]['fields'];
}

/**
* Return a mapping from field-name to the corresponding key (as used in fields()).
*
* @return array
* Array(string $name => string $uniqueName).
*/
public static function &fieldKeys() {
if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
}
return Civi::$statics[__CLASS__]['fieldKeys'];
}

/**
* Returns the names of this table
*
* @return string
*/
public static function getTableName() {
return self::$_tableName;
}

/**
* Returns if this table needs to be logged
*
* @return bool
*/
public function getLog() {
return self::$_log;
}

/**
* Returns the list of fields that can be imported
*
* @param bool $prefix
*
* @return array
*/
public static function &import($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'case_category_features', $prefix, []);
return $r;
}

/**
* Returns the list of fields that can be exported
*
* @param bool $prefix
*
* @return array
*/
public static function &export($prefix = FALSE) {
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'case_category_features', $prefix, []);
return $r;
}

/**
* Returns the list of indices
*
* @param bool $localize
*
* @return array
*/
public static function indices($localize = TRUE) {
$indices = [];
return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
}

}
Loading
Loading