stockor 0.1.9 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +254 -72
- data/Guardfile +1 -1
- data/README.md +24 -3
- data/app.json +28 -0
- data/client/skr/Extension.coffee +18 -0
- data/client/skr/components/BankAccountFinder.cjsx +34 -0
- data/client/skr/components/Currency.cjsx +19 -0
- data/client/skr/components/CustomerFinder.cjsx +37 -0
- data/client/skr/components/CustomerLink.cjsx +13 -0
- data/client/skr/components/CustomerProjectFinder.cjsx +49 -0
- data/client/skr/components/GlAccountChooser.cjsx +38 -0
- data/client/skr/components/InvoiceFinder.cjsx +37 -0
- data/client/skr/components/InvoiceLink.cjsx +13 -0
- data/client/skr/components/LocationChooser.cjsx +37 -0
- data/client/skr/components/PaymentCategoryFinder.cjsx +34 -0
- data/client/skr/components/PrintFormChooser.cjsx +29 -0
- data/client/skr/components/SalesOrderFinder.cjsx +38 -0
- data/client/skr/components/ScreenControls.cjsx +20 -0
- data/client/skr/components/SkuFinder.cjsx +30 -0
- data/client/skr/components/SkuLines.cjsx +76 -0
- data/client/skr/components/SystemSettings.cjsx +26 -0
- data/client/skr/components/TermsChooser.cjsx +40 -0
- data/client/skr/components/ToolbarButton.cjsx +7 -0
- data/client/skr/components/TotalsLine.cjsx +21 -0
- data/client/skr/components/TriStateIcon.cjsx +12 -0
- data/client/skr/components/UOMChooser.cjsx +24 -0
- data/client/skr/components/UserPreferences.cjsx +30 -0
- data/client/skr/components/VendorFinder.cjsx +40 -0
- data/client/skr/components/address/Address.cjsx +10 -10
- data/client/skr/components/styles.scss +16 -0
- data/client/skr/index.js +3 -1
- data/client/skr/models/Address.coffee +9 -1
- data/client/skr/models/BankAccount.coffee +17 -0
- data/client/skr/models/Base.coffee +6 -0
- data/client/skr/models/Customer.coffee +17 -10
- data/client/skr/models/CustomerProject.coffee +29 -0
- data/client/skr/models/GlAccount.coffee +22 -10
- data/client/skr/models/GlManualEntry.coffee +4 -2
- data/client/skr/models/GlPeriod.coffee +4 -6
- data/client/skr/models/GlPosting.coffee +7 -7
- data/client/skr/models/GlTransaction.coffee +3 -3
- data/client/skr/models/IaLine.coffee +9 -9
- data/client/skr/models/IaReason.coffee +4 -4
- data/client/skr/models/InvLine.coffee +30 -11
- data/client/skr/models/InventoryAdjustment.coffee +8 -6
- data/client/skr/models/Invoice.coffee +89 -18
- data/client/skr/models/Location.coffee +27 -6
- data/client/skr/models/Payment.coffee +36 -0
- data/client/skr/models/PaymentCategory.coffee +12 -0
- data/client/skr/models/PaymentTerm.coffee +17 -4
- data/client/skr/models/PickTicket.coffee +7 -5
- data/client/skr/models/PoLine.coffee +15 -15
- data/client/skr/models/PoReceipt.coffee +8 -6
- data/client/skr/models/PorLine.coffee +11 -11
- data/client/skr/models/PricingProvider.coffee +6 -0
- data/client/skr/models/PtLine.coffee +13 -13
- data/client/skr/models/PurchaseOrder.coffee +11 -9
- data/client/skr/models/SalesOrder.coffee +59 -22
- data/client/skr/models/Sku.coffee +17 -15
- data/client/skr/models/SkuLoc.coffee +14 -9
- data/client/skr/models/SkuTran.coffee +10 -10
- data/client/skr/models/SkuVendor.coffee +9 -9
- data/client/skr/models/SoLine.coffee +27 -20
- data/client/skr/models/TimeEntry.coffee +75 -0
- data/client/skr/models/Uom.coffee +27 -6
- data/client/skr/models/Vendor.coffee +14 -12
- data/client/skr/models/VoLine.coffee +11 -11
- data/client/skr/models/Voucher.coffee +7 -5
- data/client/skr/models/mixins/HasVisibleId.coffee +7 -0
- data/client/skr/models/mixins/PrintSupport.coffee +6 -0
- data/client/skr/models/mixins/SkuLine.coffee +61 -0
- data/client/skr/screens/Commands.coffee +29 -0
- data/client/skr/screens/bank-maint/BankMaint.cjsx +43 -0
- data/client/skr/screens/bank-maint/index.js +5 -0
- data/client/skr/screens/chart-of-accounts/ChartOfAccounts.cjsx +40 -0
- data/client/skr/screens/chart-of-accounts/index.js +1 -0
- data/client/skr/screens/chart-of-accounts/index.scss +12 -0
- data/client/skr/screens/customer-maint/CustomerMaint.cjsx +35 -36
- data/client/skr/screens/customer-projects/CustomerProjects.cjsx +70 -0
- data/client/skr/screens/customer-projects/index.js +5 -0
- data/client/skr/screens/customer-projects/index.scss +25 -0
- data/client/skr/screens/fresh-books-import/ApiInfo.cjsx +35 -0
- data/client/skr/screens/fresh-books-import/ChooseRecords.cjsx +116 -0
- data/client/skr/screens/fresh-books-import/FreshBooksImport.cjsx +31 -0
- data/client/skr/screens/fresh-books-import/Import.coffee +52 -0
- data/client/skr/screens/fresh-books-import/ViewRecords.cjsx +96 -0
- data/client/skr/screens/fresh-books-import/index.js +1 -0
- data/client/skr/screens/fresh-books-import/index.scss +39 -0
- data/client/skr/screens/gl-accounts/GlAccounts.cjsx +31 -0
- data/client/skr/screens/gl-accounts/index.js +5 -0
- data/client/skr/screens/gl-transactions/GlTransactions.cjsx +46 -0
- data/client/skr/screens/gl-transactions/index.js +1 -0
- data/client/skr/screens/gl-transactions/index.scss +12 -0
- data/client/skr/screens/invoice/Invoice.cjsx +92 -0
- data/client/skr/screens/invoice/Payment.cjsx +28 -0
- data/client/skr/screens/invoice/index.js +5 -0
- data/client/skr/screens/locations/Locations.cjsx +31 -0
- data/client/skr/screens/locations/index.js +5 -0
- data/client/skr/screens/payment-category/PaymentCategory.cjsx +28 -0
- data/client/skr/screens/payment-category/index.js +5 -0
- data/client/skr/screens/payment-category/index.scss +9 -0
- data/client/skr/screens/payment-terms/PaymentTerms.cjsx +28 -0
- data/client/skr/screens/payment-terms/index.js +5 -0
- data/client/skr/screens/payment-terms/index.scss +9 -0
- data/client/skr/screens/payments/Payments.cjsx +59 -0
- data/client/skr/screens/payments/index.js +5 -0
- data/client/skr/screens/sales-order/SalesOrder.cjsx +68 -0
- data/client/skr/screens/sales-order/index.js +1 -5
- data/client/skr/screens/sku-maint/SkuMaint.cjsx +53 -0
- data/client/skr/screens/sku-maint/SkuUomList.cjsx +209 -0
- data/client/skr/screens/sku-maint/index.js +2 -5
- data/client/skr/screens/sku-maint/index.scss +37 -6
- data/client/skr/screens/time-invoicing/TimeInvoicing.cjsx +156 -0
- data/client/skr/screens/time-invoicing/index.js +5 -0
- data/client/skr/screens/time-invoicing/index.scss +7 -0
- data/client/skr/screens/time-tracking/EditEntry.cjsx +54 -0
- data/client/skr/screens/time-tracking/Entries.coffee +132 -0
- data/client/skr/screens/time-tracking/Header.cjsx +71 -0
- data/client/skr/screens/time-tracking/Popover.cjsx +70 -0
- data/client/skr/screens/time-tracking/PopoverMiniControls.cjsx +25 -0
- data/client/skr/screens/time-tracking/TimeTracking.cjsx +63 -0
- data/client/skr/screens/time-tracking/WeekSummary.cjsx +16 -0
- data/client/skr/screens/time-tracking/index.js +1 -0
- data/client/skr/screens/time-tracking/index.scss +126 -0
- data/client/skr/screens/vendor-maint/VendorMaint.cjsx +45 -0
- data/client/skr/screens/vendor-maint/index.js +1 -5
- data/client/skr/styles.scss +1 -13
- data/config/puma.rb +4 -0
- data/config/routes.rb +21 -9
- data/config/screens.rb +147 -32
- data/db/migrate/20140202194700_create_skr_gl_transaction_details.rb +35 -0
- data/db/migrate/20140220031800_create_skr_locations.rb +2 -0
- data/db/migrate/20140220190836_create_skr_vendors.rb +1 -0
- data/db/migrate/20140220203029_create_skr_customers.rb +3 -2
- data/db/migrate/20140224034759_create_skr_skus.rb +2 -3
- data/db/migrate/20140322223912_create_skr_sales_orders.rb +4 -3
- data/db/migrate/20140322223920_create_skr_so_lines.rb +4 -5
- data/db/migrate/20140323001446_create_so_details_view.rb +7 -5
- data/db/migrate/20140327202209_create_skr_pt_lines.rb +2 -2
- data/db/migrate/20140327214000_create_customer_project.rb +16 -0
- data/db/migrate/20140327223002_create_time_entries.rb +17 -0
- data/db/migrate/20140327224000_create_skr_invoices.rb +5 -1
- data/db/migrate/20140327224002_create_skr_inv_lines.rb +3 -1
- data/db/migrate/20140422024010_create_skr_inv_details_view.rb +1 -1
- data/db/migrate/20151121211323_create_customer_project_details_views.rb +31 -0
- data/db/migrate/20160216142845_create_gl_account_balances_view.rb +20 -0
- data/db/migrate/20160229002044_create_bank_accounts.rb +18 -0
- data/db/migrate/20160229041711_create_payments.rb +33 -0
- data/db/migrate/20160307022705_create_create_combined_uom_views.rb +18 -0
- data/db/schema.sql +639 -140
- data/db/seed/chart_of_accounts.yml +8 -6
- data/db/seed/payment_categories.yml +12 -0
- data/db/seed/skus.yml +32 -0
- data/db/seed.rb +21 -0
- data/lib/skr/access_roles.rb +19 -6
- data/lib/skr/concerns/has_sku_loc_lines.rb +0 -16
- data/lib/skr/concerns/inv_extensions.rb +24 -0
- data/lib/skr/concerns/is_sku_loc_line.rb +3 -4
- data/lib/skr/concerns/so_extensions.rb +8 -0
- data/lib/skr/concerns/visible_id_identifier.rb +1 -1
- data/lib/skr/db/migration_helpers.rb +2 -4
- data/lib/skr/extension.rb +11 -4
- data/lib/skr/handlers/fresh_books_import.rb +20 -0
- data/lib/skr/handlers/invoice_from_time_entries.rb +49 -0
- data/lib/skr/jobs/fresh_books/base.rb +54 -0
- data/lib/skr/jobs/fresh_books/import.rb +151 -0
- data/lib/skr/jobs/fresh_books/retrieve.rb +62 -0
- data/lib/skr/model.rb +5 -0
- data/lib/skr/models/address.rb +1 -1
- data/lib/skr/models/bank_account.rb +13 -0
- data/lib/skr/models/business_entity.rb +3 -0
- data/lib/skr/models/customer.rb +1 -1
- data/lib/skr/models/customer_project.rb +22 -0
- data/lib/skr/models/gl_account.rb +13 -3
- data/lib/skr/models/gl_period.rb +6 -0
- data/lib/skr/models/gl_posting.rb +7 -4
- data/lib/skr/models/gl_transaction.rb +19 -33
- data/lib/skr/models/ia_line.rb +1 -1
- data/lib/skr/models/inv_line.rb +33 -15
- data/lib/skr/models/invoice.rb +47 -20
- data/lib/skr/models/location.rb +7 -1
- data/lib/skr/models/payment.rb +49 -0
- data/lib/skr/models/payment_category.rb +11 -0
- data/lib/skr/models/payment_term.rb +1 -1
- data/lib/skr/models/por_line.rb +1 -1
- data/lib/skr/models/pt_line.rb +1 -1
- data/lib/skr/models/sales_order.rb +9 -9
- data/lib/skr/models/sku_loc.rb +1 -1
- data/lib/skr/models/sku_tran.rb +6 -11
- data/lib/skr/models/so_line.rb +22 -12
- data/lib/skr/models/time_entry.rb +36 -0
- data/lib/skr/models/uom.rb +11 -10
- data/lib/skr/models/user_proxy.rb +1 -1
- data/lib/skr/number.rb +25 -0
- data/lib/skr/print/form.rb +46 -0
- data/lib/skr/print/template.rb +48 -0
- data/lib/skr/print.rb +11 -0
- data/lib/skr/string.rb +11 -0
- data/lib/skr/version.rb +1 -1
- data/lib/skr.rb +9 -0
- data/spec/fixtures/skr/address.yml +164 -4
- data/spec/fixtures/skr/bank_account.yml +8 -0
- data/spec/fixtures/skr/customer.yml +30 -4
- data/spec/fixtures/skr/customer_project.yml +20 -0
- data/spec/fixtures/skr/gl_account.yml +19 -1
- data/spec/fixtures/skr/gl_period.yml +3 -0
- data/spec/fixtures/skr/gl_posting.yml +22 -1
- data/spec/fixtures/skr/gl_transaction.yml +4 -1
- data/spec/fixtures/skr/inv_line.yml +35 -0
- data/spec/fixtures/skr/invoice.yml +13 -2
- data/spec/fixtures/skr/location.yml +5 -0
- data/spec/fixtures/skr/payment.yml +10 -0
- data/spec/fixtures/skr/payment_category.yml +8 -0
- data/spec/fixtures/skr/payment_term.yml +37 -3
- data/spec/fixtures/skr/sales_order.yml +12 -1
- data/spec/fixtures/skr/sku.yml +78 -1
- data/spec/fixtures/skr/sku_loc.yml +42 -1
- data/spec/fixtures/skr/sku_tran.yml +24 -1
- data/spec/fixtures/skr/so_line.yml +32 -0
- data/spec/fixtures/skr/time_entry.yml +82 -0
- data/spec/fixtures/skr/uom.yml +52 -1
- data/spec/fixtures/skr/vendor.yml +28 -1
- data/spec/fixtures/stockor.png +0 -0
- data/spec/server/bank_account_spec.rb +10 -0
- data/spec/server/customer_project_spec.rb +10 -0
- data/spec/server/handlers/invoice_from_time_entries_spec.rb +49 -0
- data/spec/server/jobs/fresh_books/import_spec.rb +69 -0
- data/spec/server/jobs/fresh_books/retrieve_spec.rb +37 -0
- data/spec/server/models/address_spec.rb +4 -3
- data/spec/server/models/gl_transaction_spec.rb +3 -3
- data/spec/server/models/inv_line_spec.rb +83 -3
- data/spec/server/models/invoice_spec.rb +32 -3
- data/spec/server/models/payment_spec.rb +40 -0
- data/spec/server/models/sales_order_spec.rb +1 -1
- data/spec/server/models/so_line_spec.rb +3 -3
- data/spec/server/models/spec_helper_spec.rb +1 -1
- data/spec/server/payment_spec.rb +10 -0
- data/spec/server/print/form_spec.rb +47 -0
- data/spec/server/print/template_spec.rb +36 -0
- data/spec/server/spec_helper.rb +14 -1
- data/spec/server/time_entry_spec.rb +10 -0
- data/spec/skr/components/SkuLinesSpec.coffee +61 -0
- data/spec/skr/models/BankAccountSpec.coffee +5 -0
- data/spec/skr/models/CustomerProjectSpec.coffee +5 -0
- data/spec/skr/models/CustomerSpec.coffee +2 -2
- data/spec/skr/models/PaymentSpec.coffee +5 -0
- data/spec/skr/models/SalesOrderSpec.coffee +21 -5
- data/spec/skr/models/SoLineSpec.coffee +7 -2
- data/spec/skr/models/TimeEntrySpec.coffee +5 -0
- data/spec/skr/screens/bank-maint/BankMaintSpec.coffee +5 -0
- data/spec/skr/screens/customer-projects/CustomerProjectsSpec.coffee +5 -0
- data/spec/skr/screens/fresh-books-import/FreshBooksImportSpec.coffee +1 -0
- data/spec/skr/screens/gl-accounts/GlAccountsSpec.coffee +5 -0
- data/spec/skr/screens/invoice/InvoiceSpec.coffee +5 -0
- data/spec/skr/screens/locations/LocationsSpec.coffee +5 -0
- data/spec/skr/screens/payment-category/PaymentCategorySpec.coffee +5 -0
- data/spec/skr/screens/payment-terms/PaymentTermsSpec.coffee +5 -0
- data/spec/skr/screens/payments/PaymentsSpec.coffee +5 -0
- data/spec/skr/screens/time-invoicing/TimeInvoicingSpec.coffee +5 -0
- data/spec/skr/screens/time-tracking/TimeTrackingSpec.coffee +14 -0
- data/spec/vcr/freshbooks.yml +698 -0
- data/stockor.gemspec +5 -1
- data/templates/print/fonts/GnuMICR.otf +0 -0
- data/templates/print/layout.tex.erb +39 -0
- data/templates/print/packages/booktabs.sty +182 -0
- data/templates/print/packages/fancybox.sty +966 -0
- data/templates/print/packages/fancyhdr.sty +485 -0
- data/templates/print/packages/graphbox.sty +129 -0
- data/templates/print/packages/lastpage.sty +283 -0
- data/templates/print/packages/lastpage209.sty +70 -0
- data/templates/print/packages/marginnote.sty +412 -0
- data/templates/print/packages/multirow.sty +159 -0
- data/templates/print/packages/rotating.sty +282 -0
- data/templates/print/packages/tabu.sty +2557 -0
- data/templates/print/packages/textpos.sty +361 -0
- data/templates/print/packages/varwidth.sty +318 -0
- data/templates/print/partials/address.tex.erb +6 -0
- data/templates/print/partials/bill_to_ship_to.tex.erb +13 -0
- data/templates/print/partials/header.tex.erb +13 -0
- data/templates/print/partials/invoice_paid_state.tex.erb +2 -0
- data/templates/print/partials/old/inv_lines_grouping.tex.erb +8 -0
- data/templates/print/partials/old/labor_lines_footer.tex.erb +18 -0
- data/templates/print/partials/skus_table.tex.erb +32 -0
- data/templates/print/partials/skus_table_col_hdr.tex.erb +8 -0
- data/templates/print/partials/skus_table_footer.tex.erb +5 -0
- data/templates/print/partials/skus_table_group_footer.tex.erb +4 -0
- data/templates/print/partials/skus_table_invoice_footer.tex.erb +25 -0
- data/templates/print/partials/skus_table_invoice_info_line.tex.erb +16 -0
- data/templates/print/partials/skus_table_labor_col_hdr.tex.erb +8 -0
- data/templates/print/partials/skus_table_labor_group_footer.tex.erb +7 -0
- data/templates/print/partials/skus_table_labor_line.tex.erb +11 -0
- data/templates/print/partials/skus_table_line.tex.erb +6 -0
- data/templates/print/partials/skus_table_other_charge_lines.tex.erb +7 -0
- data/templates/print/partials/so_info_line.tex.erb +14 -0
- data/templates/print/types/invoice/default.tex.erb +13 -0
- data/templates/print/types/invoice/labor.tex.erb +33 -0
- data/templates/print/types/payment/default.tex.erb +64 -0
- data/templates/print/types/sales-order/default.tex.erb +8 -0
- metadata +252 -15
- data/client/skr/components/address/address.html +0 -20
- data/client/skr/models/mixins/CodeField.coffee +0 -5
- data/client/skr/screens/customer-maint/index.scss +0 -11
- data/client/skr/screens/customer-maint/layout.html +0 -32
- data/client/skr/screens/sales-order/SalesOrder.coffee +0 -30
- data/client/skr/screens/sales-order/index.scss +0 -8
- data/client/skr/screens/sales-order/layout.html +0 -30
- data/client/skr/screens/sku-maint/SkuMaint.coffee +0 -18
- data/client/skr/screens/sku-maint/layout.html +0 -16
- data/client/skr/screens/vendor-maint/VendorMaint.coffee +0 -28
- data/client/skr/screens/vendor-maint/index.scss +0 -8
- data/client/skr/screens/vendor-maint/layout.html +0 -32
@@ -11,6 +11,7 @@ module Skr
|
|
11
11
|
# end
|
12
12
|
# so.save
|
13
13
|
#
|
14
|
+
|
14
15
|
# invoice = Invoice.new( sales_order: so )
|
15
16
|
# invoice.lines.from_sales_order!
|
16
17
|
# invoice.save
|
@@ -41,23 +42,20 @@ module Skr
|
|
41
42
|
after_save :check_if_location_changed
|
42
43
|
before_validation :set_defaults, on: :create
|
43
44
|
|
44
|
-
delegate_and_export :customer_code, :customer_name
|
45
|
-
delegate_and_export :location_code, :location_name
|
46
|
-
delegate_and_export :terms_code, :terms_description
|
47
45
|
delegate_and_export :billing_address_name
|
48
46
|
|
49
|
-
|
50
47
|
# joins the so_amount_details view which includes additional fields:
|
51
48
|
# customer_code, customer_name, bill_addr_name, total, num_lines, total_other_charge_amount,
|
52
49
|
# total_tax_amount, total_shipping_amount,subtotal_amount
|
53
|
-
|
54
|
-
|
50
|
+
|
51
|
+
scope :with_details, lambda { | *args |
|
52
|
+
compose_query_using_detail_view(view: 'skr_so_details')
|
55
53
|
}, export: true
|
56
54
|
|
57
55
|
# joins the so_allocation_details which includes the additional fields:
|
58
56
|
# number_of_lines, allocated_total, number_of_lines_allocated, number_of_lines_fully_allocated
|
59
57
|
scope :with_allocation_details, lambda {
|
60
|
-
compose_query_using_detail_view(view: '
|
58
|
+
compose_query_using_detail_view(view: 'skr_so_allocation_details')
|
61
59
|
}
|
62
60
|
|
63
61
|
# a open SalesOrder is one who's state is not "complete" or "canceled"
|
@@ -111,7 +109,8 @@ module Skr
|
|
111
109
|
|
112
110
|
def initialize(attributes = {})
|
113
111
|
super
|
114
|
-
|
112
|
+
# order date must be set, otherwise things like terms that are set from it fail
|
113
|
+
self.order_date ||= Date.today
|
115
114
|
end
|
116
115
|
|
117
116
|
private
|
@@ -157,7 +156,8 @@ module Skr
|
|
157
156
|
|
158
157
|
def set_defaults
|
159
158
|
if customer
|
160
|
-
self.
|
159
|
+
self.form ||= customer.get_form('invoice')
|
160
|
+
self.billing_address = customer.billing_address if self.billing_address.blank?
|
161
161
|
self.shipping_address = customer.shipping_address if self.shipping_address.blank?
|
162
162
|
end
|
163
163
|
end
|
data/lib/skr/models/sku_loc.rb
CHANGED
data/lib/skr/models/sku_tran.rb
CHANGED
@@ -47,11 +47,6 @@ module Skr
|
|
47
47
|
self.qty * ( self.uom_size || 1 )
|
48
48
|
end
|
49
49
|
|
50
|
-
# @return [String] a description intended for use by the #{GlTransaction}
|
51
|
-
# def description_for_gl_transaction(gl)
|
52
|
-
# self.origin_description
|
53
|
-
# end
|
54
|
-
|
55
50
|
private
|
56
51
|
|
57
52
|
# sets {#mac} to the correct amount for the {SkuLoc}.
|
@@ -72,18 +67,19 @@ module Skr
|
|
72
67
|
|
73
68
|
# If {#cost} is non-zero, then create a {GlTransaction}
|
74
69
|
def create_needed_gl_transaction
|
75
|
-
|
70
|
+
Lanes.logger.debug "Recording SkuTran in GL, mac is: #{self.mac}, cost = #{cost}"
|
76
71
|
return if self.cost.nil? || self.cost.zero?
|
77
72
|
GlTransaction.push_or_save(
|
78
|
-
|
79
|
-
|
73
|
+
owner: self, amount: cost,
|
74
|
+
debit: debit_gl_account, credit: credit_gl_account,
|
75
|
+
options: {description: origin_description}
|
80
76
|
)
|
81
77
|
end
|
82
78
|
|
83
79
|
# Adjusts {SkuLoc#qty} by {#ea_qty}
|
84
80
|
def adjust_sku_loc_values
|
85
81
|
sl = self.sku_loc
|
86
|
-
|
82
|
+
Lanes.logger.debug "Adj +#{ea_qty} Sku #{sl.sku.code} location #{location.code} " +
|
87
83
|
"from MAC: #{sl.mac} to #{self.mac}, qty: #{sl.qty} += #{ea_qty} #{combined_uom}"
|
88
84
|
sl.unlock_fields( :qty, :mac ) do
|
89
85
|
sl.mac = self.mac unless self.mac.nan? or self.mac.zero?
|
@@ -92,8 +88,7 @@ module Skr
|
|
92
88
|
end
|
93
89
|
sl.reload
|
94
90
|
sl.allocate_available_qty! if self.allocate_after_save
|
95
|
-
|
96
|
-
Skr::Core.logger.debug "After Adj Qty #{sl.qty}"
|
91
|
+
Lanes.logger.debug "After Adj Qty #{sl.qty}"
|
97
92
|
end
|
98
93
|
|
99
94
|
def ensure_cost_and_qty_present
|
data/lib/skr/models/so_line.rb
CHANGED
@@ -10,9 +10,12 @@ module Skr
|
|
10
10
|
has_one :sku, :through => :sku_loc, export: true
|
11
11
|
has_one :location, :through => :sales_order
|
12
12
|
has_many :pt_lines, :before_add=>:setup_new_pt_line, :inverse_of=>:so_line,
|
13
|
-
extend: Concerns::PT::Lines, :listen=>{save:
|
13
|
+
extend: Concerns::PT::Lines, :listen=>{save: :update_qty_picking}
|
14
14
|
|
15
|
-
|
15
|
+
has_many :inv_lines, :before_add=>:setup_new_inv_line, :inverse_of=>:so_line,
|
16
|
+
extend: Concerns::INV::Lines, :listen=>{save: :update_qty_invoiced}
|
17
|
+
|
18
|
+
has_many :uom_choices, :through => :sku, :source => :uoms, export: true
|
16
19
|
|
17
20
|
validates :sales_order, :sku_loc, set: true
|
18
21
|
|
@@ -23,7 +26,7 @@ module Skr
|
|
23
26
|
|
24
27
|
has_additional_events :qty_change
|
25
28
|
|
26
|
-
before_validation
|
29
|
+
before_validation :set_defaults_from_associations
|
27
30
|
before_create :allocate_max_available
|
28
31
|
before_destroy :ensure_deleteable
|
29
32
|
|
@@ -70,21 +73,26 @@ module Skr
|
|
70
73
|
pt_lines.picking.each{ |ptl| ptl.cancel! }
|
71
74
|
end
|
72
75
|
|
76
|
+
def total
|
77
|
+
qty * price
|
78
|
+
end
|
79
|
+
|
73
80
|
private
|
74
81
|
|
75
|
-
def
|
76
|
-
inv_qty =
|
77
|
-
update_attributes( :qty_invoiced=> inv_qty,
|
82
|
+
def update_qty_invoiced(inv = nil)
|
83
|
+
inv_qty = inv_lines.ea_qty/uom_size
|
84
|
+
update_attributes( :qty_invoiced=> inv_qty,
|
85
|
+
:qty_allocated => [ qty_allocated - inv_qty, 0 ].max )
|
78
86
|
end
|
79
|
-
|
87
|
+
|
88
|
+
def update_qty_picking(pt = nil)
|
80
89
|
update_attributes( :qty_picking=> pt_lines.ea_picking_qty/uom_size )
|
81
90
|
end
|
82
91
|
|
83
|
-
|
84
92
|
def fire_after_save_events
|
85
93
|
%w{ allocated picking invoiced canceled }.each do | event |
|
86
94
|
if changes[ "qty_#{event}" ]
|
87
|
-
|
95
|
+
fire_pubsub_event( :qty_change )
|
88
96
|
break
|
89
97
|
end
|
90
98
|
end
|
@@ -93,10 +101,12 @@ module Skr
|
|
93
101
|
|
94
102
|
def set_defaults_from_associations
|
95
103
|
self.uom = sku.uoms.default if self.uom_code.blank?
|
96
|
-
self.description = sku.description
|
97
|
-
self.sku_code = sku.code
|
104
|
+
self.description = sku.description if self.description.blank?
|
105
|
+
self.sku_code = sku.code
|
98
106
|
if !price && sales_order && sales_order.customer && sku_loc && uom.present?
|
99
|
-
self.price = Skr.config.pricing_provider.price(
|
107
|
+
self.price = Skr.config.pricing_provider.price(
|
108
|
+
sku_loc:sku_loc, customer:sales_order.customer, uom:uom, qty:qty
|
109
|
+
)
|
100
110
|
end
|
101
111
|
true
|
102
112
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Skr
|
2
|
+
|
3
|
+
class TimeEntry < Model
|
4
|
+
|
5
|
+
belongs_to :customer_project, inverse_of: :time_entries, export: true
|
6
|
+
|
7
|
+
belongs_to :lanes_user, class_name: 'Lanes::User', export: true
|
8
|
+
|
9
|
+
validates :start_at, :end_at, :description, presence: true
|
10
|
+
|
11
|
+
validates :customer_project, :lanes_user, set: true
|
12
|
+
|
13
|
+
|
14
|
+
has_one :inv_line, inverse_of: :time_entry, listen: { create: :mark_as_invoiced }
|
15
|
+
|
16
|
+
export_sort :hours do | q, dir |
|
17
|
+
q.order("end_at-start_at #{dir}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def hours
|
21
|
+
(end_at - start_at) / 1.hour
|
22
|
+
end
|
23
|
+
|
24
|
+
scope :open, ->{
|
25
|
+
where(is_invoiced: false)
|
26
|
+
}
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def mark_as_invoiced(inv_line)
|
31
|
+
update_attributes(is_invoiced: true)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lib/skr/models/uom.rb
CHANGED
@@ -12,6 +12,10 @@ module Skr
|
|
12
12
|
|
13
13
|
export_methods :combined_uom, mandatory: true
|
14
14
|
|
15
|
+
scope :with_combined_uom, lambda { | *args |
|
16
|
+
compose_query_using_detail_view(view: 'skr_combined_uom')
|
17
|
+
}, export: true
|
18
|
+
|
15
19
|
def combined_uom
|
16
20
|
if self.size.nil? || self.code.nil?
|
17
21
|
''
|
@@ -47,17 +51,14 @@ module Skr
|
|
47
51
|
Uom.new({ :code=>'EA',:size=>1, :price=>0.0 })
|
48
52
|
end
|
49
53
|
|
54
|
+
export_scope :for_sku_loc, lambda{ | sku_loc_id = nil |
|
55
|
+
if sku_loc_id
|
56
|
+
Skr::Uom.joins(sku: [:sku_locs]).where(Skr::SkuLoc.table_name => {id: sku_loc_id})
|
57
|
+
else
|
58
|
+
Skr::Uom.none
|
59
|
+
end
|
60
|
+
}
|
50
61
|
end
|
51
62
|
|
52
63
|
|
53
64
|
end # Skr module
|
54
|
-
|
55
|
-
|
56
|
-
__END__
|
57
|
-
|
58
|
-
def for_public(user=nil,options={})
|
59
|
-
as_json({
|
60
|
-
:only=>%w{ code size base_price },
|
61
|
-
:methods=>%w{ combined_uom dimensions volume }
|
62
|
-
})
|
63
|
-
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Skr
|
2
2
|
|
3
3
|
# The UserProxy is a stand-in for the real user
|
4
|
-
# model that will be implementation specific by the user of Stockor
|
4
|
+
# model that will be implementation specific by the user of Stockor
|
5
5
|
class UserProxy
|
6
6
|
|
7
7
|
# The user who's currently interacting with Stockor.
|
data/lib/skr/number.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'numbers_in_words'
|
2
|
+
|
3
|
+
module Skr
|
4
|
+
|
5
|
+
module Number
|
6
|
+
|
7
|
+
def self.ordinalize(number)
|
8
|
+
if (11..13).include?(number % 100)
|
9
|
+
"#{number}th"
|
10
|
+
else
|
11
|
+
case number % 10
|
12
|
+
when 1; "#{number}st"
|
13
|
+
when 2; "#{number}nd"
|
14
|
+
when 3; "#{number}rd"
|
15
|
+
else "#{number}th"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.as_words(number)
|
21
|
+
NumbersInWords.in_words(number)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Skr
|
2
|
+
module Print
|
3
|
+
|
4
|
+
class Form
|
5
|
+
|
6
|
+
def initialize(form, code)
|
7
|
+
@template = Template.get(form) || raise("Unable to find template for #{form}")
|
8
|
+
@record = @template.model.where(hash_code: code).first!
|
9
|
+
@latex = @template.path_for_record(@record)
|
10
|
+
unless @latex.exist?
|
11
|
+
raise("Unable to find template type for record")
|
12
|
+
end
|
13
|
+
Lanes.logger.debug "Printing #{form} #{code} using #{@latex}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def as_pdf
|
17
|
+
template.to_stringio
|
18
|
+
end
|
19
|
+
|
20
|
+
def as_latex
|
21
|
+
template.compile_latex
|
22
|
+
end
|
23
|
+
|
24
|
+
def data
|
25
|
+
vars = {
|
26
|
+
@template.name.underscore => @record,
|
27
|
+
'root_path' => ::Skr::Print::ROOT
|
28
|
+
}
|
29
|
+
if @record.respond_to?(:latex_template_variables)
|
30
|
+
vars.merge!(@record.latex_template_variables)
|
31
|
+
end
|
32
|
+
vars
|
33
|
+
end
|
34
|
+
|
35
|
+
def template
|
36
|
+
ErbLatex::Template.new( @latex,
|
37
|
+
data: data,
|
38
|
+
layout: ROOT.join('layout.tex.erb'),
|
39
|
+
partials_path: ROOT.join('partials'),
|
40
|
+
packages_path: ROOT.join('packages')
|
41
|
+
)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Skr
|
2
|
+
module Print
|
3
|
+
class Template
|
4
|
+
|
5
|
+
class Definition
|
6
|
+
def initialize(path)
|
7
|
+
@path = path
|
8
|
+
end
|
9
|
+
def name
|
10
|
+
@path.basename.to_s
|
11
|
+
end
|
12
|
+
def choices
|
13
|
+
Pathname.glob(@path.join('*.tex.erb')).map{|pn|
|
14
|
+
pn.basename('.tex.erb').to_s
|
15
|
+
}
|
16
|
+
end
|
17
|
+
def model
|
18
|
+
"skr/#{name}".underscore.classify.constantize
|
19
|
+
end
|
20
|
+
def path_for_record(record)
|
21
|
+
form = record.respond_to?(:form) ? record.form : 'default'
|
22
|
+
path = @path.join( form + '.tex.erb' )
|
23
|
+
path.exist? ? path : @path.join( 'default.tex.erb' )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.get(type)
|
28
|
+
Definition.new( Skr::Print::ROOT.join('types', type ) )
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.definitions
|
32
|
+
Pathname.glob(Skr::Print::ROOT.join('types','*')).select { | type |
|
33
|
+
type.directory?
|
34
|
+
}.map { | type |
|
35
|
+
Definition.new( type )
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.as_json
|
40
|
+
json={}
|
41
|
+
definitions.each do | definition |
|
42
|
+
json[definition.name] = definition.choices
|
43
|
+
end
|
44
|
+
json
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/skr/print.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'erb_latex'
|
2
|
+
# need ordinalize
|
3
|
+
require 'active_support/core_ext/integer/inflections'
|
4
|
+
require_relative 'print/template'
|
5
|
+
require_relative 'print/form'
|
6
|
+
|
7
|
+
module Skr
|
8
|
+
module Print
|
9
|
+
ROOT = Pathname.new(__FILE__).dirname.join("../../templates/print")
|
10
|
+
end
|
11
|
+
end
|
data/lib/skr/string.rb
ADDED
data/lib/skr/version.rb
CHANGED
data/lib/skr.rb
CHANGED
@@ -4,14 +4,23 @@ require "lanes/access"
|
|
4
4
|
require_relative "skr/version"
|
5
5
|
require_relative "skr/extension"
|
6
6
|
require_rel "skr/configuration"
|
7
|
+
require_relative "skr/string"
|
8
|
+
require_relative "skr/number"
|
7
9
|
|
8
10
|
# The main namespace for Skr
|
9
11
|
module Skr
|
10
12
|
def self.table_name_prefix
|
11
13
|
"skr_"
|
12
14
|
end
|
15
|
+
|
16
|
+
def self.system_settings
|
17
|
+
Lanes::SystemSettings.for_ext('skr')
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
15
21
|
require_rel "skr/concerns/*.rb"
|
22
|
+
require_rel "skr/jobs/fresh_books/*.rb"
|
23
|
+
require_relative "skr/print"
|
16
24
|
require_relative "skr/model"
|
17
25
|
require_relative "skr/access_roles"
|
26
|
+
require_rel "skr/handlers/*.rb"
|
@@ -1,10 +1,170 @@
|
|
1
1
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
2
|
+
bigco:
|
3
|
+
name: Big Co Inc
|
4
|
+
email: biggy@huge.com
|
5
|
+
phone: "(746) 280-8087"
|
6
|
+
line1: 1 sweet spot
|
7
|
+
line2:
|
8
|
+
city: NY
|
9
|
+
state: NY
|
10
|
+
postal_code: '12345'
|
11
|
+
|
12
|
+
bigcobank:
|
13
|
+
name: Big Co First Federal Bankcorp
|
14
|
+
email: bigbank@biggybank.com
|
15
|
+
phone: "(888) 555-5555"
|
16
|
+
line1: 1 banking lane
|
17
|
+
line2:
|
18
|
+
city: NY
|
19
|
+
state: NY
|
20
|
+
postal_code: '12345'
|
21
|
+
|
22
|
+
surplus:
|
23
|
+
name: Big Co Surplus Location
|
24
|
+
email: biggy@huge.com
|
25
|
+
phone: "(746) 280-8087"
|
26
|
+
line1: 1 sour spot
|
27
|
+
line2:
|
28
|
+
city: NY
|
29
|
+
state: NY
|
30
|
+
postal_code: '12345'
|
2
31
|
|
3
32
|
billy_billing:
|
4
|
-
name: Billy Goat
|
33
|
+
name: Billy Goat Accounting Dept
|
34
|
+
email: yadira_greenholt@moorefeest.biz
|
35
|
+
phone: "(746) 280-8087"
|
36
|
+
line1: 59031 Hyatt Shores
|
37
|
+
line2:
|
38
|
+
city: West Marisoltown
|
39
|
+
state: SD
|
40
|
+
postal_code: '35962'
|
5
41
|
|
6
42
|
billy_shipping:
|
7
|
-
name: Billy Goat
|
43
|
+
name: Billy Goat Warehouse
|
44
|
+
email: lavina_gislason@kleincollier.org
|
45
|
+
phone: 1-589-299-1175 x4979
|
46
|
+
line1: 61852 Reina Prairie
|
47
|
+
line2:
|
48
|
+
city: Dylanland
|
49
|
+
state: DE
|
8
50
|
|
9
|
-
|
10
|
-
name:
|
51
|
+
mh_billing:
|
52
|
+
name: Old Mother Hubbard Acct
|
53
|
+
email: carson_larkin@marquardtaltenwerth.com
|
54
|
+
phone: 524-543-4297 x9823
|
55
|
+
line1: 90025 Heller Route
|
56
|
+
line2:
|
57
|
+
city: Edwinfurt
|
58
|
+
state: CA
|
59
|
+
postal_code: '51050'
|
60
|
+
|
61
|
+
mh_shipping:
|
62
|
+
name: Old Mother Hubbard Shipping
|
63
|
+
name: Schuster Inc
|
64
|
+
email: sylvia.corwin@pagacdaniel.com
|
65
|
+
phone: 505-827-2322
|
66
|
+
line1: 65226 Considine Extension
|
67
|
+
line2:
|
68
|
+
city: Cassinstad
|
69
|
+
state: IA
|
70
|
+
postal_code: '59352'
|
71
|
+
|
72
|
+
rump_billing:
|
73
|
+
name: Rumpelstiltskin
|
74
|
+
email: camylle.ruecker@bogisichrenner.org
|
75
|
+
phone: 406.840.2304
|
76
|
+
line1: 2432 Lakin Flats
|
77
|
+
line2:
|
78
|
+
city: Prosaccofort
|
79
|
+
state: AR
|
80
|
+
postal_code: 26934-1306
|
81
|
+
|
82
|
+
rump_shipping:
|
83
|
+
name: Rumpelstiltskin WH
|
84
|
+
email: amara@lakin.info
|
85
|
+
phone: 470-901-2264 x4376
|
86
|
+
line1: 269 Rice Way
|
87
|
+
line2:
|
88
|
+
city: Joellemouth
|
89
|
+
state: SD
|
90
|
+
postal_code: '20381'
|
91
|
+
|
92
|
+
sb_billing:
|
93
|
+
name: Sleeping Beauty
|
94
|
+
email: sibyl_ratke@baumbach.net
|
95
|
+
phone: "(696) 093-4427 x318"
|
96
|
+
line1: 33001 Lorenz Tunnel
|
97
|
+
line2:
|
98
|
+
city: McCulloughborough
|
99
|
+
state: NH
|
100
|
+
postal_code: '39964'
|
101
|
+
|
102
|
+
sb_shipping:
|
103
|
+
name: Sleeping Beauty Industrial
|
104
|
+
email: cornelius.vonrueden@hegmann.name
|
105
|
+
phone: 1-572-456-4445 x145
|
106
|
+
line1: 2150 Muller Extension
|
107
|
+
line2:
|
108
|
+
city: Naderhaven
|
109
|
+
state: MA
|
110
|
+
postal_code: '94287'
|
111
|
+
|
112
|
+
sw_billing:
|
113
|
+
name: Snow White
|
114
|
+
email: kathlyn.effertz@luettgengulgowski.biz
|
115
|
+
phone: 1-198-363-0174 x619
|
116
|
+
line1: 199 Armstrong Lights
|
117
|
+
line2:
|
118
|
+
city: South Aida
|
119
|
+
state: SD
|
120
|
+
postal_code: 27528-6163
|
121
|
+
|
122
|
+
sw_shipping:
|
123
|
+
name: Snow White and Dwarfs
|
124
|
+
email: davonte@casperjast.net
|
125
|
+
phone: 853.834.6574 x86228
|
126
|
+
line1: 8887 Coty Vista
|
127
|
+
line2:
|
128
|
+
city: East Coralietown
|
129
|
+
state: HI
|
130
|
+
postal_code: '71157'
|
131
|
+
|
132
|
+
hg_billing:
|
133
|
+
name: Hansel and Gretel
|
134
|
+
email: schuyler@krajcik.name
|
135
|
+
phone: 379-772-4947 x945
|
136
|
+
line1: 499 Julianne Radial
|
137
|
+
line2:
|
138
|
+
city: South Timmyville
|
139
|
+
state: WI
|
140
|
+
postal_code: '38200'
|
141
|
+
|
142
|
+
hg_shipping:
|
143
|
+
name: Hansel and Gretel
|
144
|
+
email: marilie_haley@christiansen.name
|
145
|
+
phone: 158-160-0857
|
146
|
+
line1: 447 Mraz Port
|
147
|
+
line2:
|
148
|
+
city: North Markusborough
|
149
|
+
state: MS
|
150
|
+
postal_code: '51700'
|
151
|
+
|
152
|
+
cinder_billing:
|
153
|
+
name: Evil Stepmom Inc
|
154
|
+
email: cinderalla@mom.com
|
155
|
+
phone: 158-160-0857
|
156
|
+
line1: 4 City Way
|
157
|
+
line2:
|
158
|
+
city: Johnston City
|
159
|
+
state: IL
|
160
|
+
postal_code: '91500'
|
161
|
+
|
162
|
+
cinder_shipping:
|
163
|
+
name: Evl Stepmom WH
|
164
|
+
email: cinderalla@mom.com
|
165
|
+
phone: 158-160-0857
|
166
|
+
line1: 19th St WH District
|
167
|
+
line2:
|
168
|
+
city: Johnston City
|
169
|
+
state: IL
|
170
|
+
postal_code: '91500'
|
@@ -1,9 +1,35 @@
|
|
1
|
-
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
2
|
-
|
3
1
|
billy:
|
4
2
|
code: GOAT
|
5
3
|
name: Billy Goat Gruff
|
6
|
-
terms:
|
7
|
-
|
4
|
+
terms: cash
|
5
|
+
notes: Don't allow into the loading dock, eats all the things
|
6
|
+
gl_receivables_account: ar
|
8
7
|
billing_address: billy_billing
|
9
8
|
shipping_address: billy_shipping
|
9
|
+
|
10
|
+
hubbard:
|
11
|
+
code: HUBBARD
|
12
|
+
name: Old Mother Hubbard
|
13
|
+
terms: net30
|
14
|
+
notes: Always ask how her children are doing
|
15
|
+
gl_receivables_account: ar
|
16
|
+
billing_address: mh_billing
|
17
|
+
shipping_address: mh_shipping
|
18
|
+
|
19
|
+
sb:
|
20
|
+
code: SLEEPYB
|
21
|
+
name: Sleeping Beauty
|
22
|
+
terms: credcard
|
23
|
+
notes: Do not sell any sleep aids to
|
24
|
+
gl_receivables_account: ar
|
25
|
+
billing_address: sb_billing
|
26
|
+
shipping_address: sb_shipping
|
27
|
+
|
28
|
+
sw:
|
29
|
+
code: SNOWWHITE
|
30
|
+
name: Snow White
|
31
|
+
terms: check
|
32
|
+
notes: Mention gifts for Prince Charming
|
33
|
+
gl_receivables_account: ar
|
34
|
+
billing_address: sw_billing
|
35
|
+
shipping_address: sw_shipping
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
2
|
+
|
3
|
+
goatpens:
|
4
|
+
code: PENS
|
5
|
+
description: Building goat pens
|
6
|
+
po_num: gruffy
|
7
|
+
sku: labor
|
8
|
+
customer: billy
|
9
|
+
options: { color: 2 }
|
10
|
+
rates: { 'hourly': 25.00 }
|
11
|
+
|
12
|
+
|
13
|
+
mirror:
|
14
|
+
code: MIRROR
|
15
|
+
description: Create magic mirror
|
16
|
+
po_num: STEP-MOM GIFT
|
17
|
+
sku: labor
|
18
|
+
customer: sb
|
19
|
+
options: { color: 4 }
|
20
|
+
rates: { 'hourly': 85.00 }
|