merchi_sdk_ts 0.0.1-a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +13 -0
- package/.eslintrc.cjs +43 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/constants/auto_assign_production_on_actions.js +7 -0
- package/dist/constants/call_to_actions.js +15 -0
- package/dist/constants/call_to_actions.test.js +4 -0
- package/dist/constants/discount_types.js +4 -0
- package/dist/constants/discount_types.test.js +4 -0
- package/dist/constants/domain_types.js +13 -0
- package/dist/constants/domain_types.test.js +4 -0
- package/dist/constants/errors.js +32 -0
- package/dist/constants/event_types.js +6 -0
- package/dist/constants/event_types.test.js +4 -0
- package/dist/constants/field_types.js +14 -0
- package/dist/constants/field_types.test.js +4 -0
- package/dist/constants/input_types.js +14 -0
- package/dist/constants/input_types.test.js +4 -0
- package/dist/constants/inventory_status.test.js +4 -0
- package/dist/constants/inventory_statuses.js +7 -0
- package/dist/constants/invoice_types.js +6 -0
- package/dist/constants/invoice_types.test.js +4 -0
- package/dist/constants/item_types.js +6 -0
- package/dist/constants/item_types.test.js +4 -0
- package/dist/constants/job/drafting_status.js +8 -0
- package/dist/constants/job/drafting_status.test.js +4 -0
- package/dist/constants/job/payment_status.js +8 -0
- package/dist/constants/job/payment_status.test.js +4 -0
- package/dist/constants/job/production_status.js +13 -0
- package/dist/constants/job/production_status.test.js +4 -0
- package/dist/constants/job/shipment_status.js +12 -0
- package/dist/constants/job/shipment_status.test.js +4 -0
- package/dist/constants/job/supply_chain_request_status.js +7 -0
- package/dist/constants/job/supply_chain_request_status.test.js +4 -0
- package/dist/constants/job_priorities.js +7 -0
- package/dist/constants/job_priorities.test.js +4 -0
- package/dist/constants/job_status.js +50 -0
- package/dist/constants/job_status.test.js +4 -0
- package/dist/constants/job_types.js +16 -0
- package/dist/constants/job_types.test.js +4 -0
- package/dist/constants/notification_sections.js +14 -0
- package/dist/constants/notification_sections.test.js +4 -0
- package/dist/constants/notification_types.js +98 -0
- package/dist/constants/notification_types.test.js +4 -0
- package/dist/constants/notification_urgencies.js +7 -0
- package/dist/constants/notification_urgencies.test.js +4 -0
- package/dist/constants/payment_types.js +11 -0
- package/dist/constants/payment_types.test.js +4 -0
- package/dist/constants/platform.js +5 -0
- package/dist/constants/platform.test.js +8 -0
- package/dist/constants/product_types.js +26 -0
- package/dist/constants/product_types.test.js +4 -0
- package/dist/constants/rights.js +6 -0
- package/dist/constants/rights.test.js +4 -0
- package/dist/constants/robots_meta_directives.js +1 -0
- package/dist/constants/robots_meta_directives.test.js +4 -0
- package/dist/constants/roles.js +25 -0
- package/dist/constants/roles.test.js +4 -0
- package/dist/constants/shipment_companies.js +19 -0
- package/dist/constants/shipment_companies.test.js +4 -0
- package/dist/constants/shipment_services.js +4 -0
- package/dist/constants/shipment_services.test.js +4 -0
- package/dist/constants/system_roles.js +4 -0
- package/dist/constants/system_roles.test.js +4 -0
- package/dist/constants/theme_foundations.js +7 -0
- package/dist/constants/theme_foundations.test.js +4 -0
- package/dist/constants/theme_status.js +6 -0
- package/dist/constants/theme_status.test.js +4 -0
- package/dist/constants/user_types.js +18 -0
- package/dist/constants/user_types.test.js +4 -0
- package/dist/constants/white_label_accessibilities.js +6 -0
- package/dist/constants/white_label_accessibilities.test.js +4 -0
- package/dist/cookie.js +16 -0
- package/dist/cookie.test.js +12 -0
- package/dist/entities/address.js +166 -0
- package/dist/entities/address.test.js +6 -0
- package/dist/entities/assignment.js +185 -0
- package/dist/entities/assignment.test.js +38 -0
- package/dist/entities/automatic_payment_relationship.js +77 -0
- package/dist/entities/automatic_payment_relationship.test.js +6 -0
- package/dist/entities/backup.js +44 -0
- package/dist/entities/backup.test.js +6 -0
- package/dist/entities/bank.js +116 -0
- package/dist/entities/bank.test.js +6 -0
- package/dist/entities/cart.js +203 -0
- package/dist/entities/cart.test.js +52 -0
- package/dist/entities/cart_item.js +153 -0
- package/dist/entities/cart_item.test.js +34 -0
- package/dist/entities/cart_shipment_group.js +62 -0
- package/dist/entities/cart_shipment_quote.js +85 -0
- package/dist/entities/category.js +92 -0
- package/dist/entities/category.test.js +52 -0
- package/dist/entities/company.js +648 -0
- package/dist/entities/company.test.js +6 -0
- package/dist/entities/company_invitation.js +82 -0
- package/dist/entities/company_invitation.test.js +6 -0
- package/dist/entities/component.js +209 -0
- package/dist/entities/component.test.js +12 -0
- package/dist/entities/component_tag.js +50 -0
- package/dist/entities/component_tag.test.js +6 -0
- package/dist/entities/component_version.js +80 -0
- package/dist/entities/component_version.test.js +6 -0
- package/dist/entities/country_tax.js +110 -0
- package/dist/entities/country_tax.test.js +11 -0
- package/dist/entities/discount.js +77 -0
- package/dist/entities/discount.test.js +20 -0
- package/dist/entities/discount_group.js +74 -0
- package/dist/entities/discount_group.test.js +6 -0
- package/dist/entities/domain.js +535 -0
- package/dist/entities/domain.test.js +75 -0
- package/dist/entities/domain_invitation.js +90 -0
- package/dist/entities/domain_invitation.test.js +6 -0
- package/dist/entities/domain_tag.js +100 -0
- package/dist/entities/domain_tag.test.js +6 -0
- package/dist/entities/draft.js +180 -0
- package/dist/entities/draft.test.js +39 -0
- package/dist/entities/draft_comment.js +132 -0
- package/dist/entities/draft_comment.test.js +6 -0
- package/dist/entities/draft_template.js +105 -0
- package/dist/entities/draft_template.test.js +6 -0
- package/dist/entities/email_address.js +68 -0
- package/dist/entities/email_address.test.js +6 -0
- package/dist/entities/email_counter.js +56 -0
- package/dist/entities/email_counter.test.js +6 -0
- package/dist/entities/enrolled_domain.js +85 -0
- package/dist/entities/enrolled_domain.test.js +6 -0
- package/dist/entities/exchange_rate.js +62 -0
- package/dist/entities/exchange_rate.test.js +6 -0
- package/dist/entities/file.js +383 -0
- package/dist/entities/file.test.js +38 -0
- package/dist/entities/internal_tag.js +120 -0
- package/dist/entities/internal_tag.test.js +6 -0
- package/dist/entities/inventory.js +120 -0
- package/dist/entities/inventory.test.js +26 -0
- package/dist/entities/inventory_unit_variation.js +64 -0
- package/dist/entities/inventory_unit_variation.test.js +6 -0
- package/dist/entities/invoice.js +420 -0
- package/dist/entities/invoice.test.js +39 -0
- package/dist/entities/item.js +102 -0
- package/dist/entities/item.test.js +17 -0
- package/dist/entities/job.js +744 -0
- package/dist/entities/job.test.js +103 -0
- package/dist/entities/job_comment.js +120 -0
- package/dist/entities/job_comment.test.js +6 -0
- package/dist/entities/matching_inventory.js +77 -0
- package/dist/entities/menu.js +78 -0
- package/dist/entities/menu.test.js +6 -0
- package/dist/entities/menu_item.js +76 -0
- package/dist/entities/menu_item.test.js +6 -0
- package/dist/entities/notification.js +234 -0
- package/dist/entities/notification.test.js +6 -0
- package/dist/entities/page.js +84 -0
- package/dist/entities/page.test.js +6 -0
- package/dist/entities/payment.js +141 -0
- package/dist/entities/payment.test.js +18 -0
- package/dist/entities/payment_device.js +87 -0
- package/dist/entities/payment_device.test.js +6 -0
- package/dist/entities/phone_number.js +98 -0
- package/dist/entities/phone_number.test.js +6 -0
- package/dist/entities/product.js +806 -0
- package/dist/entities/product.test.js +811 -0
- package/dist/entities/production_comment.js +120 -0
- package/dist/entities/production_comment.test.js +6 -0
- package/dist/entities/quote.js +208 -0
- package/dist/entities/quote.test.js +107 -0
- package/dist/entities/quote_item.js +121 -0
- package/dist/entities/quote_item.test.js +56 -0
- package/dist/entities/seo_domain_page.js +82 -0
- package/dist/entities/seo_domain_page.test.js +6 -0
- package/dist/entities/session.js +77 -0
- package/dist/entities/session.test.js +6 -0
- package/dist/entities/shipment.js +401 -0
- package/dist/entities/shipment.test.js +28 -0
- package/dist/entities/shipment_item.js +49 -0
- package/dist/entities/shipment_item.test.js +6 -0
- package/dist/entities/shipment_item_fulfillment.js +48 -0
- package/dist/entities/shipment_item_fulfillment.test.js +6 -0
- package/dist/entities/shipment_method.js +146 -0
- package/dist/entities/shipment_method.test.js +6 -0
- package/dist/entities/shipment_method_variation.js +104 -0
- package/dist/entities/shipment_method_variation.test.js +6 -0
- package/dist/entities/short_url.js +95 -0
- package/dist/entities/short_url.test.js +6 -0
- package/dist/entities/subscription_plan.js +172 -0
- package/dist/entities/subscription_plan.test.js +6 -0
- package/dist/entities/supply_domain.js +73 -0
- package/dist/entities/supply_domain.test.js +6 -0
- package/dist/entities/system_role.js +50 -0
- package/dist/entities/system_role.test.js +6 -0
- package/dist/entities/theme.js +614 -0
- package/dist/entities/theme.test.js +39 -0
- package/dist/entities/theme_css_setting.js +67 -0
- package/dist/entities/theme_css_setting.test.js +6 -0
- package/dist/entities/user.js +749 -0
- package/dist/entities/user.test.js +157 -0
- package/dist/entities/user_company.js +78 -0
- package/dist/entities/user_company.test.js +6 -0
- package/dist/entities/variation.js +147 -0
- package/dist/entities/variation.test.js +6 -0
- package/dist/entities/variation_field.js +313 -0
- package/dist/entities/variation_field.test.js +69 -0
- package/dist/entities/variation_fields_option.js +190 -0
- package/dist/entities/variation_fields_option.test.js +47 -0
- package/dist/entities/variation_option.js +129 -0
- package/dist/entities/variation_option.test.js +6 -0
- package/dist/entities/variations_group.js +111 -0
- package/dist/entities/variations_group.test.js +6 -0
- package/dist/entity.js +888 -0
- package/dist/merchi.js +259 -0
- package/dist/merchi.test.js +35 -0
- package/dist/request.js +132 -0
- package/dist/request.test.js +46 -0
- package/dist/test_util.js +19 -0
- package/dist/toasts.js +27 -0
- package/dist/toasts.test.js +46 -0
- package/dist/util/float.js +24 -0
- package/dist/util/query_string.js +11 -0
- package/dist/util/query_string.test.js +6 -0
- package/dist/util/validation.js +3 -0
- package/dist/util/validation.test.js +12 -0
- package/dist/uuid.js +8 -0
- package/dist/uuid.test.js +13 -0
- package/jest.config.js +17 -0
- package/package.json +44 -0
- package/src/constants/auto_assign_production_on_actions.ts +6 -0
- package/src/constants/call_to_actions.test.ts +5 -0
- package/src/constants/call_to_actions.ts +14 -0
- package/src/constants/discount_types.test.ts +5 -0
- package/src/constants/discount_types.ts +3 -0
- package/src/constants/domain_types.test.ts +5 -0
- package/src/constants/domain_types.ts +12 -0
- package/src/constants/errors.ts +32 -0
- package/src/constants/event_types.test.ts +5 -0
- package/src/constants/event_types.ts +5 -0
- package/src/constants/field_types.test.ts +5 -0
- package/src/constants/field_types.ts +13 -0
- package/src/constants/input_types.test.ts +5 -0
- package/src/constants/input_types.ts +13 -0
- package/src/constants/inventory_status.test.ts +5 -0
- package/src/constants/inventory_statuses.ts +6 -0
- package/src/constants/invoice_types.test.ts +5 -0
- package/src/constants/invoice_types.ts +5 -0
- package/src/constants/item_types.test.ts +5 -0
- package/src/constants/item_types.ts +5 -0
- package/src/constants/job/drafting_status.test.ts +5 -0
- package/src/constants/job/drafting_status.ts +7 -0
- package/src/constants/job/payment_status.test.ts +5 -0
- package/src/constants/job/payment_status.ts +7 -0
- package/src/constants/job/production_status.test.ts +5 -0
- package/src/constants/job/production_status.ts +12 -0
- package/src/constants/job/shipment_status.test.ts +5 -0
- package/src/constants/job/shipment_status.ts +11 -0
- package/src/constants/job/supply_chain_request_status.test.ts +5 -0
- package/src/constants/job/supply_chain_request_status.ts +6 -0
- package/src/constants/job_priorities.test.ts +5 -0
- package/src/constants/job_priorities.ts +6 -0
- package/src/constants/job_status.test.ts +5 -0
- package/src/constants/job_status.ts +49 -0
- package/src/constants/job_types.test.ts +5 -0
- package/src/constants/job_types.ts +15 -0
- package/src/constants/notification_sections.test.ts +5 -0
- package/src/constants/notification_sections.ts +13 -0
- package/src/constants/notification_types.test.ts +5 -0
- package/src/constants/notification_types.ts +97 -0
- package/src/constants/notification_urgencies.test.ts +5 -0
- package/src/constants/notification_urgencies.ts +7 -0
- package/src/constants/payment_types.test.ts +5 -0
- package/src/constants/payment_types.ts +10 -0
- package/src/constants/platform.test.ts +15 -0
- package/src/constants/platform.ts +6 -0
- package/src/constants/product_types.test.ts +6 -0
- package/src/constants/product_types.ts +25 -0
- package/src/constants/rights.test.ts +5 -0
- package/src/constants/rights.ts +5 -0
- package/src/constants/robots_meta_directives.test.ts +5 -0
- package/src/constants/robots_meta_directives.ts +11 -0
- package/src/constants/roles.test.ts +5 -0
- package/src/constants/roles.ts +38 -0
- package/src/constants/shipment_companies.test.ts +5 -0
- package/src/constants/shipment_companies.ts +18 -0
- package/src/constants/shipment_services.test.ts +5 -0
- package/src/constants/shipment_services.ts +3 -0
- package/src/constants/system_roles.test.ts +5 -0
- package/src/constants/system_roles.ts +3 -0
- package/src/constants/theme_foundations.test.ts +5 -0
- package/src/constants/theme_foundations.ts +6 -0
- package/src/constants/theme_status.test.ts +5 -0
- package/src/constants/theme_status.ts +5 -0
- package/src/constants/user_types.test.ts +5 -0
- package/src/constants/user_types.ts +17 -0
- package/src/constants/white_label_accessibilities.test.ts +5 -0
- package/src/constants/white_label_accessibilities.ts +6 -0
- package/src/cookie.test.ts +11 -0
- package/src/cookie.ts +16 -0
- package/src/entities/address.test.ts +7 -0
- package/src/entities/address.ts +65 -0
- package/src/entities/assignment.test.ts +39 -0
- package/src/entities/assignment.ts +92 -0
- package/src/entities/automatic_payment_relationship.test.ts +8 -0
- package/src/entities/automatic_payment_relationship.ts +26 -0
- package/src/entities/backup.test.ts +7 -0
- package/src/entities/backup.ts +14 -0
- package/src/entities/bank.test.ts +7 -0
- package/src/entities/bank.ts +45 -0
- package/src/entities/cart.test.ts +50 -0
- package/src/entities/cart.ts +89 -0
- package/src/entities/cart_item.test.ts +33 -0
- package/src/entities/cart_item.ts +77 -0
- package/src/entities/cart_shipment_group.ts +21 -0
- package/src/entities/cart_shipment_quote.ts +33 -0
- package/src/entities/category.test.ts +57 -0
- package/src/entities/category.ts +37 -0
- package/src/entities/company.test.ts +7 -0
- package/src/entities/company.ts +275 -0
- package/src/entities/company_invitation.test.ts +7 -0
- package/src/entities/company_invitation.ts +33 -0
- package/src/entities/component.test.ts +14 -0
- package/src/entities/component.ts +92 -0
- package/src/entities/component_tag.test.ts +7 -0
- package/src/entities/component_tag.ts +17 -0
- package/src/entities/component_version.test.ts +7 -0
- package/src/entities/component_version.ts +30 -0
- package/src/entities/country_tax.test.ts +13 -0
- package/src/entities/country_tax.ts +46 -0
- package/src/entities/discount.test.ts +18 -0
- package/src/entities/discount.ts +34 -0
- package/src/entities/discount_group.test.ts +7 -0
- package/src/entities/discount_group.ts +28 -0
- package/src/entities/domain.test.ts +79 -0
- package/src/entities/domain.ts +246 -0
- package/src/entities/domain_invitation.test.ts +7 -0
- package/src/entities/domain_invitation.ts +36 -0
- package/src/entities/domain_tag.test.ts +7 -0
- package/src/entities/domain_tag.ts +42 -0
- package/src/entities/draft.test.ts +43 -0
- package/src/entities/draft.ts +88 -0
- package/src/entities/draft_comment.test.ts +7 -0
- package/src/entities/draft_comment.ts +54 -0
- package/src/entities/draft_template.test.ts +7 -0
- package/src/entities/draft_template.ts +40 -0
- package/src/entities/email_address.test.ts +7 -0
- package/src/entities/email_address.ts +24 -0
- package/src/entities/email_counter.test.ts +7 -0
- package/src/entities/email_counter.ts +20 -0
- package/src/entities/enrolled_domain.test.ts +7 -0
- package/src/entities/enrolled_domain.ts +40 -0
- package/src/entities/exchange_rate.test.ts +7 -0
- package/src/entities/exchange_rate.ts +22 -0
- package/src/entities/file.test.ts +43 -0
- package/src/entities/file.ts +172 -0
- package/src/entities/internal_tag.test.ts +7 -0
- package/src/entities/internal_tag.ts +51 -0
- package/src/entities/inventory.test.ts +28 -0
- package/src/entities/inventory.ts +56 -0
- package/src/entities/inventory_unit_variation.test.ts +7 -0
- package/src/entities/inventory_unit_variation.ts +29 -0
- package/src/entities/invoice.test.ts +43 -0
- package/src/entities/invoice.ts +179 -0
- package/src/entities/item.test.ts +19 -0
- package/src/entities/item.ts +44 -0
- package/src/entities/job.test.ts +95 -0
- package/src/entities/job.ts +349 -0
- package/src/entities/job_comment.test.ts +7 -0
- package/src/entities/job_comment.ts +50 -0
- package/src/entities/matching_inventory.ts +29 -0
- package/src/entities/menu.test.ts +7 -0
- package/src/entities/menu.ts +30 -0
- package/src/entities/menu_item.test.ts +7 -0
- package/src/entities/menu_item.ts +29 -0
- package/src/entities/notification.test.ts +7 -0
- package/src/entities/notification.ts +99 -0
- package/src/entities/page.test.ts +7 -0
- package/src/entities/page.ts +32 -0
- package/src/entities/payment.test.ts +19 -0
- package/src/entities/payment.ts +65 -0
- package/src/entities/payment_device.test.ts +7 -0
- package/src/entities/payment_device.ts +30 -0
- package/src/entities/phone_number.test.ts +7 -0
- package/src/entities/phone_number.ts +36 -0
- package/src/entities/product.test.ts +750 -0
- package/src/entities/product.ts +427 -0
- package/src/entities/production_comment.test.ts +7 -0
- package/src/entities/production_comment.ts +50 -0
- package/src/entities/quote.test.ts +98 -0
- package/src/entities/quote.ts +140 -0
- package/src/entities/quote_item.test.ts +50 -0
- package/src/entities/quote_item.ts +71 -0
- package/src/entities/seo_domain_page.test.ts +7 -0
- package/src/entities/seo_domain_page.ts +33 -0
- package/src/entities/session.test.ts +7 -0
- package/src/entities/session.ts +28 -0
- package/src/entities/shipment.test.ts +24 -0
- package/src/entities/shipment.ts +185 -0
- package/src/entities/shipment_item.test.ts +7 -0
- package/src/entities/shipment_item.ts +15 -0
- package/src/entities/shipment_item_fulfillment.test.ts +8 -0
- package/src/entities/shipment_item_fulfillment.ts +15 -0
- package/src/entities/shipment_method.test.ts +7 -0
- package/src/entities/shipment_method.ts +61 -0
- package/src/entities/shipment_method_variation.test.ts +7 -0
- package/src/entities/shipment_method_variation.ts +39 -0
- package/src/entities/short_url.test.ts +7 -0
- package/src/entities/short_url.ts +36 -0
- package/src/entities/subscription_plan.test.ts +7 -0
- package/src/entities/subscription_plan.ts +73 -0
- package/src/entities/supply_domain.test.ts +7 -0
- package/src/entities/supply_domain.ts +27 -0
- package/src/entities/system_role.test.ts +7 -0
- package/src/entities/system_role.ts +17 -0
- package/src/entities/theme.test.ts +38 -0
- package/src/entities/theme.ts +267 -0
- package/src/entities/theme_css_setting.test.ts +7 -0
- package/src/entities/theme_css_setting.ts +23 -0
- package/src/entities/user.test.ts +154 -0
- package/src/entities/user.ts +394 -0
- package/src/entities/user_company.test.ts +7 -0
- package/src/entities/user_company.ts +27 -0
- package/src/entities/variation.test.ts +7 -0
- package/src/entities/variation.ts +61 -0
- package/src/entities/variation_field.test.ts +76 -0
- package/src/entities/variation_field.ts +169 -0
- package/src/entities/variation_fields_option.test.ts +46 -0
- package/src/entities/variation_fields_option.ts +95 -0
- package/src/entities/variation_option.test.ts +7 -0
- package/src/entities/variation_option.ts +52 -0
- package/src/entities/variations_group.test.ts +7 -0
- package/src/entities/variations_group.ts +41 -0
- package/src/entity.ts +1002 -0
- package/src/merchi.test.ts +25 -0
- package/src/merchi.ts +379 -0
- package/src/request.test.ts +43 -0
- package/src/request.ts +124 -0
- package/src/test_util.ts +18 -0
- package/src/toasts.test.ts +38 -0
- package/src/toasts.ts +34 -0
- package/src/util/float.ts +12 -0
- package/src/util/query_string.test.ts +7 -0
- package/src/util/query_string.ts +11 -0
- package/src/util/validation.test.ts +16 -0
- package/src/util/validation.ts +2 -0
- package/src/uuid.test.ts +15 -0
- package/src/uuid.ts +8 -0
- package/tsconfig.json +23 -0
- package/webpack.config.cjs +27 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _ProductionComment;
|
|
3
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
4
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
9
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
10
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
11
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
12
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
18
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
19
|
+
import { Entity } from '../entity';
|
|
20
|
+
export var ProductionComment = (_dec = ProductionComment.property({
|
|
21
|
+
type: Date
|
|
22
|
+
}), _dec2 = ProductionComment.property(), _dec3 = ProductionComment.property({
|
|
23
|
+
type: Date
|
|
24
|
+
}), _dec4 = ProductionComment.property(), _dec5 = ProductionComment.property(), _dec6 = ProductionComment.property(), _dec7 = ProductionComment.property(), _dec8 = ProductionComment.property(), _dec9 = ProductionComment.property({
|
|
25
|
+
arrayType: "MerchiFile"
|
|
26
|
+
}), _dec10 = ProductionComment.property(), _dec11 = ProductionComment.property({
|
|
27
|
+
arrayType: 'User'
|
|
28
|
+
}), _dec12 = ProductionComment.property({
|
|
29
|
+
arrayType: 'Notification'
|
|
30
|
+
}), _dec13 = ProductionComment.property(), (_class = (_ProductionComment = /*#__PURE__*/function (_Entity) {
|
|
31
|
+
_inherits(ProductionComment, _Entity);
|
|
32
|
+
function ProductionComment() {
|
|
33
|
+
var _this;
|
|
34
|
+
_classCallCheck(this, ProductionComment);
|
|
35
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
36
|
+
args[_key] = arguments[_key];
|
|
37
|
+
}
|
|
38
|
+
_this = _callSuper(this, ProductionComment, [].concat(args));
|
|
39
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "archived", _descriptor, _assertThisInitialized(_this));
|
|
40
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "id", _descriptor2, _assertThisInitialized(_this));
|
|
41
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "date", _descriptor3, _assertThisInitialized(_this));
|
|
42
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "urgency", _descriptor4, _assertThisInitialized(_this));
|
|
43
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "text", _descriptor5, _assertThisInitialized(_this));
|
|
44
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "isUrgentQuestion", _descriptor6, _assertThisInitialized(_this));
|
|
45
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "sendSms", _descriptor7, _assertThisInitialized(_this));
|
|
46
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "sendEmail", _descriptor8, _assertThisInitialized(_this));
|
|
47
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "files", _descriptor9, _assertThisInitialized(_this));
|
|
48
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "user", _descriptor10, _assertThisInitialized(_this));
|
|
49
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "forwards", _descriptor11, _assertThisInitialized(_this));
|
|
50
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "notifications", _descriptor12, _assertThisInitialized(_this));
|
|
51
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "assignment", _descriptor13, _assertThisInitialized(_this));
|
|
52
|
+
return _this;
|
|
53
|
+
}
|
|
54
|
+
return _createClass(ProductionComment);
|
|
55
|
+
}(Entity), _defineProperty(_ProductionComment, "resourceName", 'production_comments'), _defineProperty(_ProductionComment, "singularName", 'productionComment'), _defineProperty(_ProductionComment, "pluralName", 'productionComments'), _ProductionComment), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "archived", [_dec], {
|
|
56
|
+
configurable: true,
|
|
57
|
+
enumerable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
initializer: null
|
|
60
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "id", [_dec2], {
|
|
61
|
+
configurable: true,
|
|
62
|
+
enumerable: true,
|
|
63
|
+
writable: true,
|
|
64
|
+
initializer: null
|
|
65
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "date", [_dec3], {
|
|
66
|
+
configurable: true,
|
|
67
|
+
enumerable: true,
|
|
68
|
+
writable: true,
|
|
69
|
+
initializer: null
|
|
70
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, "urgency", [_dec4], {
|
|
71
|
+
configurable: true,
|
|
72
|
+
enumerable: true,
|
|
73
|
+
writable: true,
|
|
74
|
+
initializer: null
|
|
75
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class.prototype, "text", [_dec5], {
|
|
76
|
+
configurable: true,
|
|
77
|
+
enumerable: true,
|
|
78
|
+
writable: true,
|
|
79
|
+
initializer: null
|
|
80
|
+
}), _descriptor6 = _applyDecoratedDescriptor(_class.prototype, "isUrgentQuestion", [_dec6], {
|
|
81
|
+
configurable: true,
|
|
82
|
+
enumerable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
initializer: null
|
|
85
|
+
}), _descriptor7 = _applyDecoratedDescriptor(_class.prototype, "sendSms", [_dec7], {
|
|
86
|
+
configurable: true,
|
|
87
|
+
enumerable: true,
|
|
88
|
+
writable: true,
|
|
89
|
+
initializer: null
|
|
90
|
+
}), _descriptor8 = _applyDecoratedDescriptor(_class.prototype, "sendEmail", [_dec8], {
|
|
91
|
+
configurable: true,
|
|
92
|
+
enumerable: true,
|
|
93
|
+
writable: true,
|
|
94
|
+
initializer: null
|
|
95
|
+
}), _descriptor9 = _applyDecoratedDescriptor(_class.prototype, "files", [_dec9], {
|
|
96
|
+
configurable: true,
|
|
97
|
+
enumerable: true,
|
|
98
|
+
writable: true,
|
|
99
|
+
initializer: null
|
|
100
|
+
}), _descriptor10 = _applyDecoratedDescriptor(_class.prototype, "user", [_dec10], {
|
|
101
|
+
configurable: true,
|
|
102
|
+
enumerable: true,
|
|
103
|
+
writable: true,
|
|
104
|
+
initializer: null
|
|
105
|
+
}), _descriptor11 = _applyDecoratedDescriptor(_class.prototype, "forwards", [_dec11], {
|
|
106
|
+
configurable: true,
|
|
107
|
+
enumerable: true,
|
|
108
|
+
writable: true,
|
|
109
|
+
initializer: null
|
|
110
|
+
}), _descriptor12 = _applyDecoratedDescriptor(_class.prototype, "notifications", [_dec12], {
|
|
111
|
+
configurable: true,
|
|
112
|
+
enumerable: true,
|
|
113
|
+
writable: true,
|
|
114
|
+
initializer: null
|
|
115
|
+
}), _descriptor13 = _applyDecoratedDescriptor(_class.prototype, "assignment", [_dec13], {
|
|
116
|
+
configurable: true,
|
|
117
|
+
enumerable: true,
|
|
118
|
+
writable: true,
|
|
119
|
+
initializer: null
|
|
120
|
+
})), _class));
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _Quote;
|
|
3
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
4
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
9
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
10
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
11
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
12
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
18
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
19
|
+
import { Invoice } from './invoice';
|
|
20
|
+
import { Entity } from '../entity';
|
|
21
|
+
import { kahanSum } from '../util/float';
|
|
22
|
+
export var Quote = (_dec = Quote.property({
|
|
23
|
+
type: Date
|
|
24
|
+
}), _dec2 = Quote.property(), _dec3 = Quote.property(), _dec4 = Quote.property({
|
|
25
|
+
type: Date
|
|
26
|
+
}), _dec5 = Quote.property({
|
|
27
|
+
arrayType: 'Shipment'
|
|
28
|
+
}), _dec6 = Quote.property({
|
|
29
|
+
arrayType: 'QuoteItem'
|
|
30
|
+
}), _dec7 = Quote.property({
|
|
31
|
+
arrayType: 'Assignment'
|
|
32
|
+
}), _dec8 = Quote.property({
|
|
33
|
+
type: Invoice
|
|
34
|
+
}), (_class = (_Quote = /*#__PURE__*/function (_Entity) {
|
|
35
|
+
_inherits(Quote, _Entity);
|
|
36
|
+
function Quote() {
|
|
37
|
+
var _this;
|
|
38
|
+
_classCallCheck(this, Quote);
|
|
39
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
40
|
+
args[_key] = arguments[_key];
|
|
41
|
+
}
|
|
42
|
+
_this = _callSuper(this, Quote, [].concat(args));
|
|
43
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "archived", _descriptor, _assertThisInitialized(_this));
|
|
44
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "currency", _descriptor2, _assertThisInitialized(_this));
|
|
45
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "id", _descriptor3, _assertThisInitialized(_this));
|
|
46
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "agreedDeadline", _descriptor4, _assertThisInitialized(_this));
|
|
47
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "shipments", _descriptor5, _assertThisInitialized(_this));
|
|
48
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "quoteItems", _descriptor6, _assertThisInitialized(_this));
|
|
49
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "assignments", _descriptor7, _assertThisInitialized(_this));
|
|
50
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "invoice", _descriptor8, _assertThisInitialized(_this));
|
|
51
|
+
_defineProperty(_assertThisInitialized(_this), "quoteTotal", function (options) {
|
|
52
|
+
var _ref = options ? options : {},
|
|
53
|
+
_ref$strictEmbed = _ref.strictEmbed,
|
|
54
|
+
strictEmbed = _ref$strictEmbed === void 0 ? true : _ref$strictEmbed;
|
|
55
|
+
var _assertThisInitialize = _assertThisInitialized(_this),
|
|
56
|
+
_assertThisInitialize2 = _assertThisInitialize.quoteItems,
|
|
57
|
+
quoteItems = _assertThisInitialize2 === void 0 ? [] : _assertThisInitialize2,
|
|
58
|
+
_assertThisInitialize3 = _assertThisInitialize.shipments,
|
|
59
|
+
shipments = _assertThisInitialize3 === void 0 ? [] : _assertThisInitialize3;
|
|
60
|
+
if (strictEmbed && _this.quoteItems === undefined) {
|
|
61
|
+
throw new Error('quoteItems is undefined, did you forget to embed it?');
|
|
62
|
+
}
|
|
63
|
+
if (strictEmbed && _this.shipments === undefined) {
|
|
64
|
+
throw new Error('shipments is undefined, did you forget to embed it?');
|
|
65
|
+
}
|
|
66
|
+
var quoteItemsTotal = kahanSum(quoteItems.map(function (qI) {
|
|
67
|
+
return parseFloat(qI.calculateTotal(options));
|
|
68
|
+
})).toFixed(3);
|
|
69
|
+
var shipmentItemsTotal = kahanSum(shipments.map(function (s) {
|
|
70
|
+
return parseFloat(s.calculateTotal(options));
|
|
71
|
+
})).toFixed(3);
|
|
72
|
+
return (parseFloat(quoteItemsTotal) + parseFloat(shipmentItemsTotal)).toFixed(3);
|
|
73
|
+
});
|
|
74
|
+
_defineProperty(_assertThisInitialized(_this), "calculateTotal", _this.quoteTotal);
|
|
75
|
+
_defineProperty(_assertThisInitialized(_this), "calculateSubTotal", function (options) {
|
|
76
|
+
var _ref2 = options ? options : {},
|
|
77
|
+
_ref2$strictEmbed = _ref2.strictEmbed,
|
|
78
|
+
strictEmbed = _ref2$strictEmbed === void 0 ? true : _ref2$strictEmbed;
|
|
79
|
+
var _assertThisInitialize4 = _assertThisInitialized(_this),
|
|
80
|
+
_assertThisInitialize5 = _assertThisInitialize4.quoteItems,
|
|
81
|
+
quoteItems = _assertThisInitialize5 === void 0 ? [] : _assertThisInitialize5,
|
|
82
|
+
_assertThisInitialize6 = _assertThisInitialize4.shipments,
|
|
83
|
+
shipments = _assertThisInitialize6 === void 0 ? [] : _assertThisInitialize6;
|
|
84
|
+
if (strictEmbed && _this.quoteItems === undefined) {
|
|
85
|
+
throw new Error('quoteItems is undefined, did you forget to embed it?');
|
|
86
|
+
}
|
|
87
|
+
if (strictEmbed && _this.shipments === undefined) {
|
|
88
|
+
throw new Error('shipments is undefined, did you forget to embed it?');
|
|
89
|
+
}
|
|
90
|
+
var quoteItemsTotal = kahanSum(quoteItems.map(function (qI) {
|
|
91
|
+
return parseFloat(qI.calculateSubTotal(options));
|
|
92
|
+
}));
|
|
93
|
+
var shipmentItemsTotal = kahanSum(shipments.map(function (s) {
|
|
94
|
+
return parseFloat(s.calculateSubTotal(options));
|
|
95
|
+
}));
|
|
96
|
+
return (quoteItemsTotal + shipmentItemsTotal).toFixed(3);
|
|
97
|
+
});
|
|
98
|
+
_defineProperty(_assertThisInitialized(_this), "calculateTaxAmount", function (options) {
|
|
99
|
+
var _ref3 = options ? options : {},
|
|
100
|
+
_ref3$strictEmbed = _ref3.strictEmbed,
|
|
101
|
+
strictEmbed = _ref3$strictEmbed === void 0 ? true : _ref3$strictEmbed;
|
|
102
|
+
var _assertThisInitialize7 = _assertThisInitialized(_this),
|
|
103
|
+
_assertThisInitialize8 = _assertThisInitialize7.quoteItems,
|
|
104
|
+
quoteItems = _assertThisInitialize8 === void 0 ? [] : _assertThisInitialize8,
|
|
105
|
+
_assertThisInitialize9 = _assertThisInitialize7.shipments,
|
|
106
|
+
shipments = _assertThisInitialize9 === void 0 ? [] : _assertThisInitialize9;
|
|
107
|
+
if (strictEmbed && _this.quoteItems === undefined) {
|
|
108
|
+
throw new Error('quoteItems is undefined, did you forget to embed it?');
|
|
109
|
+
}
|
|
110
|
+
if (strictEmbed && _this.shipments === undefined) {
|
|
111
|
+
throw new Error('shipments is undefined, did you forget to embed it?');
|
|
112
|
+
}
|
|
113
|
+
var quoteItemsTotal = kahanSum(quoteItems.map(function (qI) {
|
|
114
|
+
return parseFloat(qI.calculateTaxAmount(options));
|
|
115
|
+
}));
|
|
116
|
+
var shipmentItemsTotal = kahanSum(shipments.map(function (s) {
|
|
117
|
+
return parseFloat(s.calculateTaxAmount(options));
|
|
118
|
+
}));
|
|
119
|
+
return (quoteItemsTotal + shipmentItemsTotal).toFixed(3);
|
|
120
|
+
});
|
|
121
|
+
_defineProperty(_assertThisInitialized(_this), "findQuoteItemIndex", function (quoteItemId) {
|
|
122
|
+
if (_this.quoteItems === undefined) {
|
|
123
|
+
throw new Error('quoteItems is undefined, did you forget to embed it?');
|
|
124
|
+
}
|
|
125
|
+
function checkEqualId(quoteItem) {
|
|
126
|
+
return quoteItem.id === quoteItemId;
|
|
127
|
+
}
|
|
128
|
+
return _this.quoteItems.findIndex(checkEqualId);
|
|
129
|
+
});
|
|
130
|
+
_defineProperty(_assertThisInitialized(_this), "removeQuoteItem", function (quoteItem) {
|
|
131
|
+
if (_this.quoteItems === undefined) {
|
|
132
|
+
throw new Error('quoteItems is undefined, did you forget to embed it?');
|
|
133
|
+
}
|
|
134
|
+
if (quoteItem.id === undefined) {
|
|
135
|
+
throw new Error('quoteItem.id is undefined, did you forget to embed it?');
|
|
136
|
+
}
|
|
137
|
+
var index = _this.findQuoteItemIndex(quoteItem.id);
|
|
138
|
+
if (index > -1) {
|
|
139
|
+
_this.quoteItems.splice(index, 1);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
_defineProperty(_assertThisInitialized(_this), "deadlineTimeDifference", function () {
|
|
143
|
+
if (_this.agreedDeadline === undefined) {
|
|
144
|
+
var err = 'agreedDeadline is undefined, did you forget to embed it?';
|
|
145
|
+
throw new Error(err);
|
|
146
|
+
}
|
|
147
|
+
if (_this.assignments === undefined) {
|
|
148
|
+
var _err = 'assignments is undefiend, did you forget to embed it?';
|
|
149
|
+
throw new Error(_err);
|
|
150
|
+
}
|
|
151
|
+
if (_this.assignments.length < 1) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
if (_this.agreedDeadline === null) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
var assignment = _this.assignments[0];
|
|
158
|
+
if (assignment.productionDeadline === undefined) {
|
|
159
|
+
var _err2 = 'productionDeadline is undefined, did you forget to embed' + 'it?';
|
|
160
|
+
throw new Error(_err2);
|
|
161
|
+
}
|
|
162
|
+
var productionDeadline = assignment.productionDeadline;
|
|
163
|
+
return productionDeadline.valueOf() - _this.agreedDeadline.valueOf();
|
|
164
|
+
});
|
|
165
|
+
return _this;
|
|
166
|
+
}
|
|
167
|
+
return _createClass(Quote);
|
|
168
|
+
}(Entity), _defineProperty(_Quote, "resourceName", 'quotes'), _defineProperty(_Quote, "singularName", 'quote'), _defineProperty(_Quote, "pluralName", 'quotes'), _Quote), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "archived", [_dec], {
|
|
169
|
+
configurable: true,
|
|
170
|
+
enumerable: true,
|
|
171
|
+
writable: true,
|
|
172
|
+
initializer: null
|
|
173
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "currency", [_dec2], {
|
|
174
|
+
configurable: true,
|
|
175
|
+
enumerable: true,
|
|
176
|
+
writable: true,
|
|
177
|
+
initializer: null
|
|
178
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "id", [_dec3], {
|
|
179
|
+
configurable: true,
|
|
180
|
+
enumerable: true,
|
|
181
|
+
writable: true,
|
|
182
|
+
initializer: null
|
|
183
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, "agreedDeadline", [_dec4], {
|
|
184
|
+
configurable: true,
|
|
185
|
+
enumerable: true,
|
|
186
|
+
writable: true,
|
|
187
|
+
initializer: null
|
|
188
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class.prototype, "shipments", [_dec5], {
|
|
189
|
+
configurable: true,
|
|
190
|
+
enumerable: true,
|
|
191
|
+
writable: true,
|
|
192
|
+
initializer: null
|
|
193
|
+
}), _descriptor6 = _applyDecoratedDescriptor(_class.prototype, "quoteItems", [_dec6], {
|
|
194
|
+
configurable: true,
|
|
195
|
+
enumerable: true,
|
|
196
|
+
writable: true,
|
|
197
|
+
initializer: null
|
|
198
|
+
}), _descriptor7 = _applyDecoratedDescriptor(_class.prototype, "assignments", [_dec7], {
|
|
199
|
+
configurable: true,
|
|
200
|
+
enumerable: true,
|
|
201
|
+
writable: true,
|
|
202
|
+
initializer: null
|
|
203
|
+
}), _descriptor8 = _applyDecoratedDescriptor(_class.prototype, "invoice", [_dec8], {
|
|
204
|
+
configurable: true,
|
|
205
|
+
enumerable: true,
|
|
206
|
+
writable: true,
|
|
207
|
+
initializer: null
|
|
208
|
+
})), _class));
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Merchi } from '../merchi';
|
|
2
|
+
test('can make Quote', function () {
|
|
3
|
+
var merchi = new Merchi();
|
|
4
|
+
var quote = new merchi.Quote();
|
|
5
|
+
expect(quote).toBeTruthy();
|
|
6
|
+
});
|
|
7
|
+
test('calculation', function () {
|
|
8
|
+
var merchi = new Merchi();
|
|
9
|
+
var quote = new merchi.Quote();
|
|
10
|
+
var gst = new merchi.CountryTax();
|
|
11
|
+
gst.taxName = 'GST';
|
|
12
|
+
gst.taxPercent = 10;
|
|
13
|
+
var noTax = merchi.CountryTax.getNoTax();
|
|
14
|
+
|
|
15
|
+
// quote items did not filled before calculation seems like a embed issue
|
|
16
|
+
expect(quote.quoteTotal).toThrow();
|
|
17
|
+
expect(quote.calculateSubTotal).toThrow();
|
|
18
|
+
expect(quote.calculateTaxAmount).toThrow();
|
|
19
|
+
quote.quoteItems = [new merchi.QuoteItem(), new merchi.QuoteItem()];
|
|
20
|
+
quote.quoteItems[0].unitPrice = 400;
|
|
21
|
+
quote.quoteItems[0].quantity = 2;
|
|
22
|
+
quote.quoteItems[0].taxType = gst;
|
|
23
|
+
quote.quoteItems[1].unitPrice = 25;
|
|
24
|
+
quote.quoteItems[1].quantity = 2;
|
|
25
|
+
quote.quoteItems[1].taxType = noTax;
|
|
26
|
+
|
|
27
|
+
// shipments did not filled before calculation seems like a embed issue
|
|
28
|
+
expect(quote.quoteTotal).toThrow();
|
|
29
|
+
expect(quote.calculateSubTotal).toThrow();
|
|
30
|
+
expect(quote.calculateTaxAmount).toThrow();
|
|
31
|
+
quote.shipments = [new merchi.Shipment()];
|
|
32
|
+
quote.shipments[0].cost = 100;
|
|
33
|
+
quote.shipments[0].taxType = gst;
|
|
34
|
+
|
|
35
|
+
// 800 * 1.1 + 25 * 2 + 100 * 1.1 = 1040
|
|
36
|
+
expect(quote.quoteTotal()).toBe('1040.000');
|
|
37
|
+
expect(quote.quoteTotal({
|
|
38
|
+
'strictEmbed': false
|
|
39
|
+
})).toBe('1040.000');
|
|
40
|
+
expect(quote.calculateTotal()).toBe('1040.000');
|
|
41
|
+
expect(quote.calculateTotal({
|
|
42
|
+
'strictEmbed': false
|
|
43
|
+
})).toBe('1040.000');
|
|
44
|
+
|
|
45
|
+
// 800 + 25 * 2 + 100
|
|
46
|
+
expect(quote.calculateSubTotal()).toBe('950.000');
|
|
47
|
+
expect(quote.calculateSubTotal({
|
|
48
|
+
'strictEmbed': false
|
|
49
|
+
})).toBe('950.000');
|
|
50
|
+
|
|
51
|
+
// 800 * 0.1 + 100 * 0.1
|
|
52
|
+
expect(quote.calculateTaxAmount()).toBe('90.000');
|
|
53
|
+
expect(quote.calculateTaxAmount({
|
|
54
|
+
'strictEmbed': false
|
|
55
|
+
})).toBe('90.000');
|
|
56
|
+
});
|
|
57
|
+
test('findQuoteItemIndex', function () {
|
|
58
|
+
var merchi = new Merchi();
|
|
59
|
+
var quote = new merchi.Quote();
|
|
60
|
+
expect(function () {
|
|
61
|
+
return quote.findQuoteItemIndex(43);
|
|
62
|
+
}).toThrow();
|
|
63
|
+
quote.quoteItems = [];
|
|
64
|
+
expect(quote.findQuoteItemIndex(43)).toEqual(-1);
|
|
65
|
+
quote.quoteItems = [new merchi.QuoteItem()];
|
|
66
|
+
quote.quoteItems[0].id = 43;
|
|
67
|
+
expect(quote.findQuoteItemIndex(43)).toEqual(0);
|
|
68
|
+
});
|
|
69
|
+
test('removeQuoteItem', function () {
|
|
70
|
+
var merchi = new Merchi();
|
|
71
|
+
var quote = new merchi.Quote();
|
|
72
|
+
var quoteItem = new merchi.QuoteItem();
|
|
73
|
+
quoteItem.id = 43;
|
|
74
|
+
expect(function () {
|
|
75
|
+
return quote.removeQuoteItem(quoteItem);
|
|
76
|
+
}).toThrow();
|
|
77
|
+
quoteItem.id = undefined;
|
|
78
|
+
expect(function () {
|
|
79
|
+
return quote.removeQuoteItem(quoteItem);
|
|
80
|
+
}).toThrow();
|
|
81
|
+
quoteItem.id = 43;
|
|
82
|
+
quote.quoteItems = [];
|
|
83
|
+
expect(quote.removeQuoteItem(quoteItem)).toBe(undefined);
|
|
84
|
+
expect(quote.quoteItems).toEqual([]);
|
|
85
|
+
quote.quoteItems = [quoteItem];
|
|
86
|
+
expect(quote.removeQuoteItem(quoteItem)).toBe(undefined);
|
|
87
|
+
expect(quote.quoteItems).toEqual([]);
|
|
88
|
+
quoteItem.id = undefined;
|
|
89
|
+
expect(function () {
|
|
90
|
+
return quote.removeQuoteItem(quoteItem);
|
|
91
|
+
}).toThrow();
|
|
92
|
+
});
|
|
93
|
+
test('deadlineTimeDifference', function () {
|
|
94
|
+
var merchi = new Merchi();
|
|
95
|
+
var quote = new merchi.Quote();
|
|
96
|
+
expect(quote.deadlineTimeDifference).toThrow();
|
|
97
|
+
quote.agreedDeadline = null;
|
|
98
|
+
expect(quote.deadlineTimeDifference).toThrow();
|
|
99
|
+
quote.assignments = [];
|
|
100
|
+
expect(quote.deadlineTimeDifference()).toBe(null);
|
|
101
|
+
quote.assignments = [new merchi.Assignment()];
|
|
102
|
+
expect(quote.deadlineTimeDifference()).toBe(null);
|
|
103
|
+
quote.agreedDeadline = new Date(1);
|
|
104
|
+
expect(quote.deadlineTimeDifference).toThrow();
|
|
105
|
+
quote.assignments[0].productionDeadline = new Date(2);
|
|
106
|
+
expect(quote.deadlineTimeDifference()).toEqual(1);
|
|
107
|
+
});
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _QuoteItem;
|
|
3
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
4
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
9
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
10
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
11
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
12
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
18
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
19
|
+
import { CountryTax } from './country_tax';
|
|
20
|
+
import { Entity } from '../entity';
|
|
21
|
+
export var QuoteItem = (_dec = QuoteItem.property({
|
|
22
|
+
type: Date
|
|
23
|
+
}), _dec2 = QuoteItem.property(), _dec3 = QuoteItem.property(), _dec4 = QuoteItem.property(), _dec5 = QuoteItem.property({
|
|
24
|
+
type: String
|
|
25
|
+
}), _dec6 = QuoteItem.property({
|
|
26
|
+
type: Number
|
|
27
|
+
}), _dec7 = QuoteItem.property({
|
|
28
|
+
type: Number
|
|
29
|
+
}), _dec8 = QuoteItem.property({
|
|
30
|
+
type: CountryTax
|
|
31
|
+
}), _dec9 = QuoteItem.property(), (_class = (_QuoteItem = /*#__PURE__*/function (_Entity) {
|
|
32
|
+
_inherits(QuoteItem, _Entity);
|
|
33
|
+
function QuoteItem() {
|
|
34
|
+
var _this;
|
|
35
|
+
_classCallCheck(this, QuoteItem);
|
|
36
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
37
|
+
args[_key] = arguments[_key];
|
|
38
|
+
}
|
|
39
|
+
_this = _callSuper(this, QuoteItem, [].concat(args));
|
|
40
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "archived", _descriptor, _assertThisInitialized(_this));
|
|
41
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "id", _descriptor2, _assertThisInitialized(_this));
|
|
42
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "type", _descriptor3, _assertThisInitialized(_this));
|
|
43
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "quantity", _descriptor4, _assertThisInitialized(_this));
|
|
44
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "description", _descriptor5, _assertThisInitialized(_this));
|
|
45
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "unitPrice", _descriptor6, _assertThisInitialized(_this));
|
|
46
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "taxAmount", _descriptor7, _assertThisInitialized(_this));
|
|
47
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "taxType", _descriptor8, _assertThisInitialized(_this));
|
|
48
|
+
_initializerDefineProperty(_assertThisInitialized(_this), "quote", _descriptor9, _assertThisInitialized(_this));
|
|
49
|
+
_defineProperty(_assertThisInitialized(_this), "calculateSubTotal", function (options) {
|
|
50
|
+
var _ref = options ? options : {},
|
|
51
|
+
_ref$strictEmbed = _ref.strictEmbed,
|
|
52
|
+
strictEmbed = _ref$strictEmbed === void 0 ? true : _ref$strictEmbed;
|
|
53
|
+
if (strictEmbed) {
|
|
54
|
+
if (_this.unitPrice === undefined) {
|
|
55
|
+
throw new Error('unitPrice is undefined, did you forget to embed it?');
|
|
56
|
+
}
|
|
57
|
+
if (_this.quantity === undefined) {
|
|
58
|
+
throw new Error('quantity is undefined, did you forget to embed it?');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
var quant = _this.quantity ? _this.quantity : 0;
|
|
62
|
+
var unitPrice = _this.unitPrice ? _this.unitPrice : 0;
|
|
63
|
+
return (quant * unitPrice).toFixed(3);
|
|
64
|
+
});
|
|
65
|
+
_defineProperty(_assertThisInitialized(_this), "calculateTaxAmount", function (options) {
|
|
66
|
+
var taxPercent = _this.taxType && _this.taxType.taxPercent ? _this.taxType.taxPercent : 0;
|
|
67
|
+
var taxRate = taxPercent ? Number(taxPercent) / 100 : 0;
|
|
68
|
+
return (parseFloat(_this.calculateSubTotal(options)) * taxRate).toFixed(3);
|
|
69
|
+
});
|
|
70
|
+
_defineProperty(_assertThisInitialized(_this), "calculateTotal", function (options) {
|
|
71
|
+
return (parseFloat(_this.calculateSubTotal(options)) + parseFloat(_this.calculateTaxAmount(options))).toFixed(3);
|
|
72
|
+
});
|
|
73
|
+
return _this;
|
|
74
|
+
}
|
|
75
|
+
return _createClass(QuoteItem);
|
|
76
|
+
}(Entity), _defineProperty(_QuoteItem, "resourceName", 'quote_items'), _defineProperty(_QuoteItem, "singularName", 'quoteItem'), _defineProperty(_QuoteItem, "pluralName", 'quoteItems'), _QuoteItem), (_descriptor = _applyDecoratedDescriptor(_class.prototype, "archived", [_dec], {
|
|
77
|
+
configurable: true,
|
|
78
|
+
enumerable: true,
|
|
79
|
+
writable: true,
|
|
80
|
+
initializer: null
|
|
81
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "id", [_dec2], {
|
|
82
|
+
configurable: true,
|
|
83
|
+
enumerable: true,
|
|
84
|
+
writable: true,
|
|
85
|
+
initializer: null
|
|
86
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "type", [_dec3], {
|
|
87
|
+
configurable: true,
|
|
88
|
+
enumerable: true,
|
|
89
|
+
writable: true,
|
|
90
|
+
initializer: null
|
|
91
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, "quantity", [_dec4], {
|
|
92
|
+
configurable: true,
|
|
93
|
+
enumerable: true,
|
|
94
|
+
writable: true,
|
|
95
|
+
initializer: null
|
|
96
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class.prototype, "description", [_dec5], {
|
|
97
|
+
configurable: true,
|
|
98
|
+
enumerable: true,
|
|
99
|
+
writable: true,
|
|
100
|
+
initializer: null
|
|
101
|
+
}), _descriptor6 = _applyDecoratedDescriptor(_class.prototype, "unitPrice", [_dec6], {
|
|
102
|
+
configurable: true,
|
|
103
|
+
enumerable: true,
|
|
104
|
+
writable: true,
|
|
105
|
+
initializer: null
|
|
106
|
+
}), _descriptor7 = _applyDecoratedDescriptor(_class.prototype, "taxAmount", [_dec7], {
|
|
107
|
+
configurable: true,
|
|
108
|
+
enumerable: true,
|
|
109
|
+
writable: true,
|
|
110
|
+
initializer: null
|
|
111
|
+
}), _descriptor8 = _applyDecoratedDescriptor(_class.prototype, "taxType", [_dec8], {
|
|
112
|
+
configurable: true,
|
|
113
|
+
enumerable: true,
|
|
114
|
+
writable: true,
|
|
115
|
+
initializer: null
|
|
116
|
+
}), _descriptor9 = _applyDecoratedDescriptor(_class.prototype, "quote", [_dec9], {
|
|
117
|
+
configurable: true,
|
|
118
|
+
enumerable: true,
|
|
119
|
+
writable: true,
|
|
120
|
+
initializer: null
|
|
121
|
+
})), _class));
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Merchi } from '../merchi';
|
|
2
|
+
test('can make QuoteItem', function () {
|
|
3
|
+
var merchi = new Merchi();
|
|
4
|
+
var quoteItem = new merchi.QuoteItem();
|
|
5
|
+
expect(quoteItem).toBeTruthy();
|
|
6
|
+
});
|
|
7
|
+
test('total calculation', function () {
|
|
8
|
+
var merchi = new Merchi();
|
|
9
|
+
var quoteItem = new merchi.QuoteItem();
|
|
10
|
+
var gst = new merchi.CountryTax();
|
|
11
|
+
gst.taxName = 'GST';
|
|
12
|
+
gst.taxPercent = 10;
|
|
13
|
+
var noTax = merchi.CountryTax.getNoTax();
|
|
14
|
+
quoteItem.unitPrice = 10;
|
|
15
|
+
quoteItem.quantity = 1;
|
|
16
|
+
|
|
17
|
+
// tax type not provided yet should be a embed issue
|
|
18
|
+
expect(quoteItem.calculateTotal()).toEqual('10.000');
|
|
19
|
+
expect(quoteItem.calculateTotal({
|
|
20
|
+
strictEmbed: false
|
|
21
|
+
})).toEqual('10.000');
|
|
22
|
+
|
|
23
|
+
// quote total include tax type properly
|
|
24
|
+
quoteItem.taxType = gst;
|
|
25
|
+
expect(quoteItem.calculateTotal()).toEqual('11.000');
|
|
26
|
+
quoteItem.taxType = noTax;
|
|
27
|
+
expect(quoteItem.calculateTotal()).toEqual('10.000');
|
|
28
|
+
|
|
29
|
+
// null and undefined price and quantity will throw error unless not strictly
|
|
30
|
+
// require embed
|
|
31
|
+
quoteItem.unitPrice = null;
|
|
32
|
+
expect(quoteItem.calculateTotal({
|
|
33
|
+
strictEmbed: false
|
|
34
|
+
})).toEqual('0.000');
|
|
35
|
+
quoteItem.unitPrice = 1;
|
|
36
|
+
quoteItem.quantity = undefined;
|
|
37
|
+
expect(function () {
|
|
38
|
+
return quoteItem.calculateTotal();
|
|
39
|
+
}).toThrow();
|
|
40
|
+
expect(quoteItem.calculateTotal({
|
|
41
|
+
strictEmbed: false
|
|
42
|
+
})).toEqual('0.000');
|
|
43
|
+
quoteItem.unitPrice = undefined;
|
|
44
|
+
quoteItem.quantity = 1;
|
|
45
|
+
expect(function () {
|
|
46
|
+
return quoteItem.calculateTotal();
|
|
47
|
+
}).toThrow();
|
|
48
|
+
expect(quoteItem.calculateTotal({
|
|
49
|
+
strictEmbed: false
|
|
50
|
+
})).toEqual('0.000');
|
|
51
|
+
|
|
52
|
+
// make sure float number recorded correctly
|
|
53
|
+
quoteItem.quantity = 3.55;
|
|
54
|
+
quoteItem.unitPrice = 87.12;
|
|
55
|
+
expect(quoteItem.calculateTotal()).toEqual('309.276');
|
|
56
|
+
});
|