Skip to content

Commit

Permalink
Merged in KAZ-323 (pull request 2600hz#22)
Browse files Browse the repository at this point in the history
[KAZ-323] Add fields to camel_invoice_lines
  • Loading branch information
BorigTheDwarf committed Mar 31, 2016
2 parents 276f896 + d539e2d commit e1e0a87
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
4 changes: 1 addition & 3 deletions applications/crossbar/src/modules/cb_invoices.erl
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ fetch_invoice(Context, Id) ->
try camel_invoice:get(Id) of
{'ok', [#camel_invoice_line{}|_]=Lines} ->
Context0 = cb_context:set_resp_data(Context, [camel_invoice:line_record_to_json(Line) || Line <- Lines]),
cb_context:set_resp_status(Context0, 'success');
{'ok', _} ->
crossbar_util:response_bad_identifier(<<"Could not find invoice">>, Context)
cb_context:set_resp_status(Context0, 'success')
catch
'throw':{Error, Reason} ->
crossbar_util:response('error', wh_util:to_binary(Error), 500, Reason, Context)
Expand Down
22 changes: 22 additions & 0 deletions core/camel-1.0.0/include/camel_invoice_record.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
,price :: api_binary()
,net_amount :: api_binary()
,total_amount :: api_binary()
,description :: api_binary()
,uom_id :: api_binary()
,tax_id :: api_binary()
,product_search_key :: api_binary()
,product_name :: api_binary()
,product_description :: api_binary()
,product_category_id :: api_binary()
,product_type :: api_binary()
,product_category_description :: api_binary()
,product_category_name :: api_binary()
,parent_product_category_name :: api_binary()
}).
-type camel_invoice_line() :: #camel_invoice_line{}.
-type camel_invoice_lines() :: [camel_invoice_line(),...] | [].
Expand All @@ -48,4 +59,15 @@
,{<<"priceActual">>, <<"price">>}
,{<<"lineNetAmt">>, <<"net_amount">>}
,{<<"lineTotalAmt">>, <<"total_amount">>}
,{<<"description">>, <<"description">>}
,{<<"uomId">>, <<"uom_id">>}
,{<<"taxId">>, <<"tax_id">>}
,{<<"productSearchKey">>, <<"product_search_key">>}
,{<<"productName">>, <<"product_name">>}
,{<<"productDescription">>, <<"product_description">>}
,{<<"productCategoryId">>, <<"product_category_id">>}
,{<<"productType">>, <<"product_type">>}
,{<<"productCategoryDescription">>, <<"product_category_description">>}
,{<<"productCategoryName">>, <<"product_category_name">>}
,{<<"parentProductCategoryName">>, <<"parent_product_category_name">>}
]).
22 changes: 22 additions & 0 deletions core/camel-1.0.0/src/camel_invoice.erl
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,17 @@ line_json_to_record(JObj) ->
,price = wh_json:get_binary_value(<<"price">>, JObj)
,net_amount = wh_json:get_binary_value(<<"net_amount">>, JObj)
,total_amount = wh_json:get_binary_value(<<"total_amount">>, JObj)
,description = wh_json:get_binary_value(<<"description">>, JObj)
,uom_id = wh_json:get_binary_value(<<"uom_id">>, JObj)
,tax_id = wh_json:get_binary_value(<<"tax_id">>, JObj)
,product_search_key = wh_json:get_binary_value(<<"product_search_key">>, JObj)
,product_name = wh_json:get_binary_value(<<"product_name">>, JObj)
,product_description = wh_json:get_binary_value(<<"product_description">>, JObj)
,product_category_id = wh_json:get_binary_value(<<"product_category_id">>, JObj)
,product_type = wh_json:get_binary_value(<<"product_type">>, JObj)
,product_category_description = wh_json:get_binary_value(<<"product_category_description">>, JObj)
,product_category_name = wh_json:get_binary_value(<<"product_category_name">>, JObj)
,parent_product_category_name = wh_json:get_binary_value(<<"parent_product_category_name">>, JObj)
}.

%% Transforms an invoice line record into JSON format.
Expand All @@ -176,6 +187,17 @@ line_record_to_json(Line, ToString) ->
,{<<"price">>, Line#camel_invoice_line.price}
,{<<"net_amount">>, Line#camel_invoice_line.net_amount}
,{<<"total_amount">>, Line#camel_invoice_line.total_amount}
,{<<"description">>, Line#camel_invoice_line.description}
,{<<"uom_id">>, Line#camel_invoice_line.uom_id}
,{<<"tax_id">>, Line#camel_invoice_line.tax_id}
,{<<"product_search_key">>, Line#camel_invoice_line.product_search_key}
,{<<"product_name">>, Line#camel_invoice_line.product_name}
,{<<"product_description">>, Line#camel_invoice_line.product_description}
,{<<"product_category_id">>, Line#camel_invoice_line.product_category_id}
,{<<"product_type">>, Line#camel_invoice_line.product_type}
,{<<"product_category_description">>, Line#camel_invoice_line.product_category_description}
,{<<"product_category_name">>, Line#camel_invoice_line.product_category_name}
,{<<"parent_product_category_name">>, Line#camel_invoice_line.parent_product_category_name}
],
Json = wh_json:from_list(props:filter_undefined(Props)),
case ToString of
Expand Down

0 comments on commit e1e0a87

Please sign in to comment.