-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(generator): add generator command
- Add generate invoice command - Add generate all invoice command
- Loading branch information
Showing
9 changed files
with
87 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::error::Error; | ||
|
||
use log::trace; | ||
|
||
use crate::file_manager::context_parameters::ContextParameters; | ||
use crate::file_manager::file_manager::FileManager; | ||
use crate::invoice_manager::invoice_manager::InvoiceManager; | ||
|
||
pub fn generate_all_invoice(context_parameters: ContextParameters) -> Result<(), Box<dyn Error + Sync + Send + 'static>> { | ||
trace!("=== Get invoice"); | ||
|
||
let file_manager = FileManager::new(context_parameters.clone())?; | ||
|
||
let all_invoice = file_manager.get_all_invoices()?; | ||
|
||
|
||
all_invoice.iter().for_each(|invoice| { | ||
let mut invoice_input_path = file_manager.get_invoice_path().to_owned().join(invoice.get_ref().unwrap()); | ||
|
||
invoice_input_path.set_extension("yaml"); | ||
|
||
let invoice_output_name = invoice.get_ref().unwrap() + ".pdf"; | ||
|
||
let output_path = file_manager.generate_invoice(&(invoice_input_path.as_path()), &invoice_output_name); | ||
|
||
println!("Invoice generated in : {}", output_path.unwrap().to_string_lossy()); | ||
}); | ||
|
||
return Ok(()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::error::Error; | ||
|
||
use log::trace; | ||
|
||
use crate::cli::utils::select_invoice_or_use_default::select_invoice_or_use_default; | ||
use crate::entities::invoice::Invoice; | ||
use crate::file_manager::context_parameters::ContextParameters; | ||
use crate::file_manager::file_manager::FileManager; | ||
use crate::invoice_manager::invoice_manager::InvoiceManager; | ||
|
||
pub fn generate_invoice(context_parameters: ContextParameters, invoice_ref: &Option<String>) -> Result<(), Box<dyn Error + Sync + Send + 'static>> { | ||
trace!("=== Get invoice"); | ||
|
||
let file_manager = FileManager::new(context_parameters.clone())?; | ||
|
||
let invoice_selected: Invoice = select_invoice_or_use_default(&file_manager, invoice_ref)?; | ||
|
||
let mut invoice_input_path = file_manager.get_invoice_path().to_owned().join(invoice_selected.get_ref().unwrap()); | ||
|
||
invoice_input_path.set_extension("yaml"); | ||
|
||
let invoice_output_name = invoice_selected.get_ref().unwrap() + ".pdf"; | ||
|
||
let output_path = file_manager.generate_invoice(&(invoice_input_path.as_path()), &invoice_output_name)?; | ||
|
||
println!("Invoice generated in : {}", output_path.to_string_lossy()); | ||
return Ok(()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters